start_controls_section( 'content_section', [ 'label' => __('Content', 'dutchie-menus'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'store_id', [ 'label' => __('Store ID', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => get_option('dutchie_default_store_id', 1), 'min' => 1, ] ); $this->add_control( 'category_id', [ 'label' => __('Category ID', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => '', 'description' => __('Leave empty to show all categories', 'dutchie-menus'), ] ); $this->add_control( 'limit', [ 'label' => __('Number of Products', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => 12, 'min' => 1, 'max' => 100, ] ); $this->add_control( 'columns', [ 'label' => __('Columns', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '3', 'options' => [ '2' => __('2 Columns', 'dutchie-menus'), '3' => __('3 Columns', 'dutchie-menus'), '4' => __('4 Columns', 'dutchie-menus'), '6' => __('6 Columns', 'dutchie-menus'), ], ] ); $this->add_control( 'in_stock_only', [ 'label' => __('In Stock Only', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __('Yes', 'dutchie-menus'), 'label_off' => __('No', 'dutchie-menus'), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'search', [ 'label' => __('Search Filter', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::TEXT, 'default' => '', 'description' => __('Filter products by name', 'dutchie-menus'), ] ); $this->end_controls_section(); // Display Options Section $this->start_controls_section( 'display_section', [ 'label' => __('Display Options', 'dutchie-menus'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'show_image', [ 'label' => __('Show Image', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __('Yes', 'dutchie-menus'), 'label_off' => __('No', 'dutchie-menus'), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_price', [ 'label' => __('Show Price', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __('Yes', 'dutchie-menus'), 'label_off' => __('No', 'dutchie-menus'), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_thc', [ 'label' => __('Show THC', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __('Yes', 'dutchie-menus'), 'label_off' => __('No', 'dutchie-menus'), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_cbd', [ 'label' => __('Show CBD', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __('Yes', 'dutchie-menus'), 'label_off' => __('No', 'dutchie-menus'), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_description', [ 'label' => __('Show Description', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __('Yes', 'dutchie-menus'), 'label_off' => __('No', 'dutchie-menus'), 'return_value' => 'yes', 'default' => 'no', ] ); $this->end_controls_section(); // Style Section $this->start_controls_section( 'style_section', [ 'label' => __('Style', 'dutchie-menus'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'card_background', [ 'label' => __('Card Background', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', 'selectors' => [ '{{WRAPPER}} .dutchie-product-card' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'card_border_radius', [ 'label' => __('Border Radius', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => ['px'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, ], ], 'default' => [ 'size' => 8, ], 'selectors' => [ '{{WRAPPER}} .dutchie-product-card' => 'border-radius: {{SIZE}}{{UNIT}};', ], ] ); $this->add_control( 'text_color', [ 'label' => __('Text Color', 'dutchie-menus'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#333333', 'selectors' => [ '{{WRAPPER}} .dutchie-product-card' => 'color: {{VALUE}};', ], ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $args = [ 'store_id' => $settings['store_id'], 'limit' => $settings['limit'], 'in_stock' => $settings['in_stock_only'] === 'yes' ? 'true' : 'false', ]; if (!empty($settings['category_id'])) { $args['category_id'] = $settings['category_id']; } if (!empty($settings['search'])) { $args['search'] = $settings['search']; } $plugin = Dutchie_Menus_Plugin::instance(); $products = $plugin->fetch_products($args); if (!$products) { echo '
' . __('No products found.', 'dutchie-menus') . '
'; return; } $columns = $settings['columns']; ?>