start_controls_section( 'content_section', [ 'label' => __('Content', 'cannaiq-menus'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'store_id', [ 'label' => __('Store ID', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => get_option('cannaiq_default_store_id', 1), 'min' => 1, ] ); $this->add_control( 'limit', [ 'label' => __('Number of Products', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::NUMBER, 'default' => 10, 'min' => 1, 'max' => 50, ] ); $this->add_control( 'category', [ 'label' => __('Category', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '', 'options' => CannaIQ_Menus_Plugin::instance()->get_category_options(), ] ); $this->add_control( 'specials_only', [ 'label' => __('Specials Only', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __('Yes', 'cannaiq-menus'), 'label_off' => __('No', 'cannaiq-menus'), 'return_value' => 'yes', 'default' => 'no', ] ); $this->end_controls_section(); // Display Options $this->start_controls_section( 'display_section', [ 'label' => __('Display Options', 'cannaiq-menus'), 'tab' => \Elementor\Controls_Manager::TAB_CONTENT, ] ); $this->add_control( 'show_image', [ 'label' => __('Show Image', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_brand', [ 'label' => __('Show Brand', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_thc', [ 'label' => __('Show THC', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_weight', [ 'label' => __('Show Weight', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_special_tag', [ 'label' => __('Show Special Tag', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_discount_badge', [ 'label' => __('Show Discount Badge', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_add_button', [ 'label' => __('Show Add Button', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->end_controls_section(); // Style Section $this->start_controls_section( 'style_section', [ 'label' => __('Style', 'cannaiq-menus'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'row_background', [ 'label' => __('Row Background', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#ffffff', ] ); $this->add_control( 'border_color', [ 'label' => __('Border Color', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#e5e7eb', ] ); $this->add_control( 'special_tag_color', [ 'label' => __('Special Tag Color', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#22c55e', ] ); $this->add_control( 'discount_badge_color', [ 'label' => __('Discount Badge Color', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#f97316', ] ); $this->add_control( 'add_button_color', [ 'label' => __('Add Button Color', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#22c55e', ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); $args = [ 'store_id' => $settings['store_id'], 'limit' => $settings['limit'], ]; if (!empty($settings['category'])) { $args['type'] = $settings['category']; } $plugin = CannaIQ_Menus_Plugin::instance(); if ($settings['specials_only'] === 'yes') { $products = $plugin->fetch_specials($args); } else { $products = $plugin->fetch_products($args); } if (!$products) { echo '

' . __('No products found.', 'cannaiq-menus') . '

'; return; } $row_bg = $settings['row_background']; $border_color = $settings['border_color']; $special_color = $settings['special_tag_color']; $discount_color = $settings['discount_badge_color']; $btn_color = $settings['add_button_color']; ?>
0 && $sale_price < $regular_price; $discount_percent = $has_discount ? round((($regular_price - $sale_price) / $regular_price) * 100) : 0; $brand = $product['brand'] ?? ''; $thc = $product['thc_percentage'] ?? ''; $weight = $product['weight'] ?? $product['subcategory'] ?? ''; $special_name = $product['special_name'] ?? ''; ?>
<?php echo esc_attr($product['name']); ?>
THC: %
$
$ % off
+