start_controls_section( 'addonnest_woo_product', [ 'label' => __('Product Settings', 'addonnest') ] ); $this->add_control( 'woo_number', [ 'label' => __('Number of Products', 'addonnest'), 'type' => \Elementor\Controls_Manager::NUMBER, 'min' => 1, 'max' => 50, 'step' => 1, 'default' => 9, ] ); $this->add_control( 'woo_column', [ 'label' => __('Number of Columns', 'addonnest'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 4, 'options' => [ '12' => __('1 Column', 'addonnest'), '6' => __('2 Columns', 'addonnest'), '4' => __('3 Columns', 'addonnest'), '3' => __('4 Columns', 'addonnest'), ], ] ); $this->add_control( 'woo_cat', [ 'label' => __('Product Category', 'addonnest'), 'type' => \Elementor\Controls_Manager::SELECT2, 'options' => addonnest_all_category_list('product_cat'), 'multiple' => true, 'label_block' => true, ] ); $this->add_control( 'woo_order_by', [ 'label' => __('Order By', 'addonnest'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'DESC', 'options' => [ 'DESC' => __('Descending', 'addonnest'), 'ASC' => __('Ascending', 'addonnest'), ], ] ); $this->add_control( 'woo_order', [ 'label' => __('Order', 'addonnest'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'date', 'options' => [ 'date' => __('Date', 'addonnest'), 'title' => __('Title', 'addonnest'), 'price' => __('Price', 'addonnest'), 'popularity' => __('Popularity', 'addonnest'), 'rating' => __('Rating', 'addonnest'), 'rand' => __('Random', 'addonnest'), ], ] ); $this->add_control( 'woo_pagination', [ 'label' => __('Show Pagination', 'addonnest'), 'type' => \Elementor\Controls_Manager::SWITCHER, 'label_on' => __('Show', 'addonnest'), 'label_off' => __('Hide', 'addonnest'), 'return_value' => 'yes', 'default' => 'yes', ] ); $this->end_controls_section(); // Style Tab - Product Card $this->start_controls_section( 'product_card_style', [ 'label' => __('Product Card', 'addonnest'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => 'product_card_border', 'selector' => '{{WRAPPER}} .addonnest-product-card', ] ); $this->add_control( 'product_card_border_radius', [ 'label' => __('Border Radius', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ '{{WRAPPER}} .addonnest-product-card' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Box_Shadow::get_type(), [ 'name' => 'product_card_shadow', 'selector' => '{{WRAPPER}} .addonnest-product-card', ] ); $this->add_control( 'product_card_bg_color', [ 'label' => __('Background Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-product-card' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'product_card_hover_bg_color', [ 'label' => __('Hover Background Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-product-card:hover' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'product_card_hover_border_color', [ 'label' => __('Hover Border Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-product-card:hover' => 'border-color: {{VALUE}};', ], ] ); $this->add_responsive_control( 'product_card_padding', [ 'label' => __('Padding', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em', '%'], 'selectors' => [ '{{WRAPPER}} .addonnest-product-card' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'product_card_margin', [ 'label' => __('Margin', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em', '%'], 'selectors' => [ '{{WRAPPER}} .addonnest-product-card' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style Tab - Image $this->start_controls_section( 'image_style', [ 'label' => __('Product Image', 'addonnest'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'image_spacing', [ 'label' => __('Spacing', 'addonnest'), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => ['px', 'em'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 100, ], ], 'selectors' => [ '{{WRAPPER}} .addonnest-product-image' => 'margin-bottom: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style Tab - Badges $this->start_controls_section( 'badges_style', [ 'label' => __('Badges', 'addonnest'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'badge_position', [ 'label' => __('Position', 'addonnest'), 'type' => \Elementor\Controls_Manager::SELECT, 'default' => 'top-left', 'options' => [ 'top-left' => __('Top Left', 'addonnest'), 'top-right' => __('Top Right', 'addonnest'), ], ] ); $this->add_control( 'discount_badge_heading', [ 'label' => __('Discount Badge', 'addonnest'), 'type' => \Elementor\Controls_Manager::HEADING, 'separator' => 'before', ] ); $this->add_control( 'discount_badge_bg_color', [ 'label' => __('Background Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-products-list .addonnest-product-card .addonnest-product-image-wrapper .addonnest-product-badges .addonnest-discount-badge' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'discount_badge_text_color', [ 'label' => __('Text Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-products-list .addonnest-product-card .addonnest-product-image-wrapper .addonnest-product-badges .addonnest-discount-badge' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'discount_badge_typography', 'selector' => '{{WRAPPER}} .addonnest-products-list .addonnest-product-card .addonnest-product-image-wrapper .addonnest-product-badges .addonnest-discount-badge', ] ); $this->add_control( 'discount_badge_border_radius', [ 'label' => __('Border Radius', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ '{{WRAPPER}} .addonnest-products-list .addonnest-product-card .addonnest-product-image-wrapper .addonnest-product-badges .addonnest-discount-badge' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_control( 'discount_badge_padding', [ 'label' => __('Padding', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em'], 'selectors' => [ '{{WRAPPER}} .addonnest-products-list .addonnest-product-card .addonnest-product-image-wrapper .addonnest-product-badges .addonnest-discount-badge' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style Tab - Category $this->start_controls_section( 'category_style', [ 'label' => __('Category', 'addonnest'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'category_text_color', [ 'label' => __('Text Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-product-category' => 'color: {{VALUE}};', '{{WRAPPER}} .addonnest-product-category a' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'category_hover_color', [ 'label' => __('Hover Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-product-category a:hover' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'category_typography', 'selector' => '{{WRAPPER}} .addonnest-product-category a', ] ); $this->add_responsive_control( 'category_spacing', [ 'label' => __('Spacing', 'addonnest'), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => ['px', 'em'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, ], ], 'selectors' => [ '{{WRAPPER}} .addonnest-product-category' => 'margin-bottom: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style Tab - Title $this->start_controls_section( 'title_style', [ 'label' => __('Title', 'addonnest'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'title_text_color', [ 'label' => __('Text Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-product-title' => 'color: {{VALUE}};', '{{WRAPPER}} .addonnest-product-title a' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'title_hover_color', [ 'label' => __('Hover Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-product-title:hover' => 'color: {{VALUE}};', '{{WRAPPER}} .addonnest-product-title a:hover' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'title_typography', 'selector' => '{{WRAPPER}} .addonnest-product-title', ] ); $this->add_responsive_control( 'title_spacing', [ 'label' => __('Spacing', 'addonnest'), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => ['px', 'em'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, ], ], 'selectors' => [ '{{WRAPPER}} .addonnest-product-title' => 'margin-bottom: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style Tab - Price $this->start_controls_section( 'price_style', [ 'label' => __('Price', 'addonnest'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'price_text_color', [ 'label' => __('Text Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-products-list .addonnest-product-card .addonnest-product-details .addonnest-product-price ins .woocommerce-Price-amount.amount' => 'color: {{VALUE}};', '{{WRAPPER}} .addonnest-products-list .addonnest-product-card .addonnest-product-details .addonnest-product-price>.woocommerce-Price-amount.amount' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'price_sale_color', [ 'label' => __('Sale Price Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-products-list .addonnest-product-card .addonnest-product-details .addonnest-product-price del .woocommerce-Price-amount.amount' => 'color: {{VALUE}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'price_typography', 'selector' => '{{WRAPPER}} .addonnest-product-price', ] ); $this->add_responsive_control( 'price_spacing', [ 'label' => __('Spacing', 'addonnest'), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => ['px', 'em'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 50, ], ], 'selectors' => [ '{{WRAPPER}} .addonnest-product-price' => 'margin-bottom: {{SIZE}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style Tab - Button $this->start_controls_section( 'button_style', [ 'label' => __('Add to Cart Button', 'addonnest'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->start_controls_tabs('button_tabs'); $this->start_controls_tab( 'button_normal', [ 'label' => __('Normal', 'addonnest'), ] ); $this->add_control( 'button_text_color', [ 'label' => __('Text Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-add-to-cart' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'button_bg_color', [ 'label' => __('Background Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-add-to-cart' => 'background-color: {{VALUE}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => 'button_border', 'selector' => '{{WRAPPER}} .addonnest-add-to-cart', ] ); $this->end_controls_tab(); $this->start_controls_tab( 'button_hover', [ 'label' => __('Hover', 'addonnest'), ] ); $this->add_control( 'button_hover_text_color', [ 'label' => __('Text Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-add-to-cart:hover' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'button_hover_bg_color', [ 'label' => __('Background Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-add-to-cart:hover' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'button_hover_border_color', [ 'label' => __('Border Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-add-to-cart:hover' => 'border-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'button_typography', 'selector' => '{{WRAPPER}} .addonnest-add-to-cart', ] ); $this->add_control( 'button_border_radius', [ 'label' => __('Border Radius', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ '{{WRAPPER}} .addonnest-add-to-cart' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'button_padding', [ 'label' => __('Padding', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em'], 'selectors' => [ '{{WRAPPER}} .addonnest-add-to-cart' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'button_margin', [ 'label' => __('Margin', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em'], 'selectors' => [ '{{WRAPPER}} .addonnest-add-to-cart' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); // Style Tab - Pagination $this->start_controls_section( 'pagination_style', [ 'label' => __('Pagination', 'addonnest'), 'tab' => \Elementor\Controls_Manager::TAB_STYLE, ] ); $this->add_control( 'pagination_alignment', [ 'label' => __('Alignment', 'addonnest'), 'type' => \Elementor\Controls_Manager::CHOOSE, 'options' => [ 'left' => [ 'title' => __('Left', 'addonnest'), 'icon' => 'eicon-text-align-left', ], 'center' => [ 'title' => __('Center', 'addonnest'), 'icon' => 'eicon-text-align-center', ], 'right' => [ 'title' => __('Right', 'addonnest'), 'icon' => 'eicon-text-align-right', ], ], 'default' => 'center', 'selectors' => [ '{{WRAPPER}} .addonnest-pagination' => 'text-align: {{VALUE}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Typography::get_type(), [ 'name' => 'pagination_typography', 'selector' => '{{WRAPPER}} .addonnest-pagination .page-numbers a, {{WRAPPER}} .addonnest-pagination .page-numbers span', ] ); $this->start_controls_tabs('pagination_tabs'); $this->start_controls_tab( 'pagination_normal', [ 'label' => __('Normal', 'addonnest'), ] ); $this->add_control( 'pagination_text_color', [ 'label' => __('Text Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers a, {{WRAPPER}} .addonnest-pagination .page-numbers span' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'pagination_bg_color', [ 'label' => __('Background Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers a, {{WRAPPER}} .addonnest-pagination .page-numbers span' => 'background-color: {{VALUE}};', ], ] ); $this->add_group_control( \Elementor\Group_Control_Border::get_type(), [ 'name' => 'pagination_border', 'selector' => '{{WRAPPER}} .addonnest-pagination .page-numbers a, {{WRAPPER}} .addonnest-pagination .page-numbers span', ] ); $this->end_controls_tab(); $this->start_controls_tab( 'pagination_hover', [ 'label' => __('Hover', 'addonnest'), ] ); $this->add_control( 'pagination_hover_text_color', [ 'label' => __('Text Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers a:hover' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'pagination_hover_bg_color', [ 'label' => __('Background Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers a:hover' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'pagination_hover_border_color', [ 'label' => __('Border Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers a:hover' => 'border-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->start_controls_tab( 'pagination_active', [ 'label' => __('Active', 'addonnest'), ] ); $this->add_control( 'pagination_active_text_color', [ 'label' => __('Text Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers .current' => 'color: {{VALUE}};', ], ] ); $this->add_control( 'pagination_active_bg_color', [ 'label' => __('Background Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers .current' => 'background-color: {{VALUE}};', ], ] ); $this->add_control( 'pagination_active_border_color', [ 'label' => __('Border Color', 'addonnest'), 'type' => \Elementor\Controls_Manager::COLOR, 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers .current' => 'border-color: {{VALUE}};', ], ] ); $this->end_controls_tab(); $this->end_controls_tabs(); $this->add_control( 'pagination_border_radius', [ 'label' => __('Border Radius', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', '%'], 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers a, {{WRAPPER}} .addonnest-pagination .page-numbers span' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'pagination_padding', [ 'label' => __('Padding', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em'], 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers a, {{WRAPPER}} .addonnest-pagination .page-numbers span' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'pagination_spacing', [ 'label' => __('Spacing Between Items', 'addonnest'), 'type' => \Elementor\Controls_Manager::SLIDER, 'size_units' => ['px', 'em'], 'range' => [ 'px' => [ 'min' => 0, 'max' => 30, ], ], 'selectors' => [ '{{WRAPPER}} .addonnest-pagination .page-numbers li:not(:last-child)' => 'margin-right: {{SIZE}}{{UNIT}};', ], ] ); $this->add_responsive_control( 'pagination_margin', [ 'label' => __('Margin', 'addonnest'), 'type' => \Elementor\Controls_Manager::DIMENSIONS, 'size_units' => ['px', 'em'], 'selectors' => [ '{{WRAPPER}} .addonnest-pagination' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', ], ] ); $this->end_controls_section(); } protected function render() { $settings = $this->get_settings_for_display(); // Query arguments $args = [ 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => $settings['woo_number'], 'order' => $settings['woo_order_by'], 'orderby' => $settings['woo_order'], 'paged' => max(1, get_query_var('paged'), get_query_var('page')), ]; // Category filter if (!empty($settings['woo_cat']) && !in_array('allpost', $settings['woo_cat'])) { // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query $args['tax_query'] = [ [ 'taxonomy' => 'product_cat', 'field' => 'slug', 'terms' => $settings['woo_cat'], ] ]; } $products = new \WP_Query($args); // Column class $column_class = 'addonnest-col-' . $settings['woo_column']; // Badge position class $badge_position_class = 'addonnest-badge-' . $settings['badge_position']; ?>