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' => 12, 'min' => 1, 'max' => 50, ] ); $this->add_control( 'columns', [ 'label' => __('Columns', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => '4', 'options' => [ '3' => __('3 Columns', 'cannaiq-menus'), '4' => __('4 Columns', 'cannaiq-menus'), '5' => __('5 Columns', 'cannaiq-menus'), '6' => __('6 Columns', 'cannaiq-menus'), ], ] ); $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, '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_brand', [ 'label' => __('Show Brand', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_thc_cbd', [ 'label' => __('Show THC/CBD', '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_original_price', [ 'label' => __('Show Original Price', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'return_value' => 'yes', 'default' => 'yes', ] ); $this->add_control( 'show_cart_button', [ 'label' => __('Show Add to Cart', '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( 'card_background', [ 'label' => __('Card 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( 'discount_badge_color', [ 'label' => __('Discount Badge Color', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#fbbf24', ] ); $this->add_control( 'button_color', [ 'label' => __('Button Color', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::COLOR, 'default' => '#f97316', ] ); $this->add_control( 'border_radius', [ 'label' => __('Border Radius', 'cannaiq-menus'), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => ['px'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 20, ], ], 'default' => [ 'size' => 8, ], ] ); $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; } $columns = $settings['columns']; $card_bg = $settings['card_background']; $border_color = $settings['border_color']; $discount_color = $settings['discount_badge_color']; $btn_color = $settings['button_color']; $radius = $settings['border_radius']['size'] . 'px'; $col_widths = [ '3' => '33.333%', '4' => '25%', '5' => '20%', '6' => '16.666%', ]; $col_width = $col_widths[$columns] ?? '25%'; ?>
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'] ?? ''; $cbd = $product['cbd_percentage'] ?? ''; ?>
<?php echo esc_attr($product['name']); ?>
Stock photo. Actual product may vary.
THC: % ยท CBD: %
$
$ % off
ADD TO CART