feat(wordpress): Add new Elementor widgets and dynamic selectors v1.6.0

New Widgets:
- Brand Grid: Display brands in a grid with product counts
- Category List: Show categories in grid/list/pills layouts
- Specials Grid: Display products on sale with discount badges

Enhanced Product Grid Widget:
- Dynamic category dropdown (fetches from API)
- Dynamic brand dropdown (fetches from API)
- "On Special Only" toggle filter

New Plugin Methods:
- fetch_categories() - Get categories from API
- fetch_brands() - Get brands from API
- fetch_specials() - Get products on sale
- get_category_options() - Cached options for Elementor
- get_brand_options() - Cached options for Elementor

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Kelly
2025-12-10 13:41:17 -07:00
parent 2d035c46cf
commit 74957a9ec5
7 changed files with 1052 additions and 9 deletions

View File

@@ -47,12 +47,37 @@ class CannaIQ_Menus_Product_Grid_Widget extends \Elementor\Widget_Base {
);
$this->add_control(
'category_id',
'category',
[
'label' => __('Category ID', 'cannaiq-menus'),
'type' => \Elementor\Controls_Manager::NUMBER,
'label' => __('Category', 'cannaiq-menus'),
'type' => \Elementor\Controls_Manager::SELECT,
'default' => '',
'description' => __('Leave empty to show all categories', 'cannaiq-menus'),
'options' => CannaIQ_Menus_Plugin::instance()->get_category_options(),
'description' => __('Filter by product category', 'cannaiq-menus'),
]
);
$this->add_control(
'brand',
[
'label' => __('Brand', 'cannaiq-menus'),
'type' => \Elementor\Controls_Manager::SELECT,
'default' => '',
'options' => CannaIQ_Menus_Plugin::instance()->get_brand_options(),
'description' => __('Filter by brand', 'cannaiq-menus'),
]
);
$this->add_control(
'on_special',
[
'label' => __('On Special Only', 'cannaiq-menus'),
'type' => \Elementor\Controls_Manager::SWITCHER,
'label_on' => __('Yes', 'cannaiq-menus'),
'label_off' => __('No', 'cannaiq-menus'),
'return_value' => 'yes',
'default' => 'no',
'description' => __('Show only products on sale', 'cannaiq-menus'),
]
);
@@ -243,8 +268,16 @@ class CannaIQ_Menus_Product_Grid_Widget extends \Elementor\Widget_Base {
'in_stock' => $settings['in_stock_only'] === 'yes' ? 'true' : 'false',
];
if (!empty($settings['category_id'])) {
$args['category_id'] = $settings['category_id'];
if (!empty($settings['category'])) {
$args['type'] = $settings['category'];
}
if (!empty($settings['brand'])) {
$args['brandName'] = $settings['brand'];
}
if ($settings['on_special'] === 'yes') {
$args['on_special'] = 'true';
}
if (!empty($settings['search'])) {