<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;
use Elementor\Repeater;
use Elementor\Scheme_Color;
use Elementor\Group_Control_Typography;
Use Elementor\Core\Schemes\Typography;
use Elementor\Group_Control_Border;
use Elementor\Utils;
use Elementor\Group_Control_Text_Shadow;

if (!defined('ABSPATH')) exit; // Exit if accessed directly

class Widgetkit_Pro_Woo_Single_Product_Upsell_Product extends Widget_Base
{

    public function get_name()
    {
        return 'widgetkit-pro-woo-single-product-upsell-product';
    }

    public function get_title()
    {
        return __('Upsell Product', 'widgetkit-pro');
    }

    public function get_icon()
    {
        return 'eicon-woocommerce';
    }

    public function get_categories()
    {
        return ['widgetkit_pro_woo_single_product'];
    }

    /**
	 * A list of style that the widgets is depended in
	 **/
	public function get_style_depends() {
        return [
            'widgetkit_bs',
            'widgetkit_pro_default',
        ];
    }
	/**
	 * A list of scripts that the widgets is depended in
	 **/
	public function get_script_depends() {
		return [ 
			// 'layout',
		 ];
	}

    protected function register_controls()
    {
        // /**
        //  * get all product category
        //  */
        // $parent_cats = array();
        // $parent_terms = get_terms( array(
        //     'taxonomy' => 'product_cat',
        //     'parent' => 0
        // ) );
        // foreach( $parent_terms as $p ):
        //     $parent_cats[$p->term_id] = $p->name;
        // endforeach;
        /**
         * all cat
         */
        $specific_cats = array();
        $terms = get_terms( array(
            'taxonomy' => 'product_cat',
            'hide_empty' => false,
        ) );
        if(wkp_check_dependent_plugin('woocommerce', 'woocommerce.php') && $terms):
            foreach( $terms as $t ):
                $specific_cats[$t->term_id] = $t->name;
            endforeach;
        endif;

// # region content tab

        /**
         * Header
         */
        $this->start_controls_section(
            'section_control_header',
            [
                'label' => __('Header', 'widgetkit-pro'),
            ]
        );
        
        $this->add_control(
            'category_layout_header',
            [
                'label'       => __( 'Header', 'widgetkit-pro' ),
                'type'        => Controls_Manager::TEXT,
                'default'     => __( 'Product Categories', 'widgetkit-pro' ),
                'placeholder' => __( 'Product Categories', 'widgetkit-pro' ),
            ]
        );
        $this->end_controls_section();

        /**
         * Layout 
         */
        $this->start_controls_section(
            'section_control_layout',
            [
                'label' => __('Layout', 'widgetkit-pro'),
            ]
        );
        $this->add_control(
            'cat_layout',
            [
                'label'       => __( 'Style', 'widgetkit-pro' ),
                'type' => Controls_Manager::SELECT,
                'default' => 'grid',
                'options' => [
                    'grid'  => __( 'Grid', 'widgetkit-pro' ),
                    'layout'  => __( 'Layout', 'widgetkit-pro' ),
                ],
            ]
        );
        $this->add_control(
            'grid_text_layout',
            [
                'label'       => __( 'Content Postion', 'widgetkit-pro' ),
                'type' => Controls_Manager::SELECT,
                'default' => 'outside',
                'options' => [
                    'inside'  => __( 'Inside Image', 'widgetkit-pro' ),
                    'outside'  => __( 'Outside Image', 'widgetkit-pro' ),
                ],
                'condition' => [
                    'cat_layout' => 'grid'
                ]
            ]
        );
        $this->add_control(
            'category_column',
            [
                'label'   => __( 'Column', 'widgetkit-pro' ),
                'type'    => Controls_Manager::NUMBER,
                'default' => 4,
                'min'     => 1,
                'max'     => 8,
                'step'    => 1,
                'condition' => [
                    'cat_layout' => 'grid'
                ]
            ]
        );
        $this->add_control(
            'layout_skin',
            [
                'label'       => __( 'Skin', 'widgetkit-pro' ),
                'type' => Controls_Manager::SELECT,
                'default' => 'skin-1',
                'options' => [
                    'skin-1'  => __( 'Skin 1', 'widgetkit-pro' ),
                    'skin-2'  => __( 'Skin 2', 'widgetkit-pro' ),
                    'skin-3'  => __( 'Skin 3', 'widgetkit-pro' ),
                    'skin-4'  => __( 'Skin 4', 'widgetkit-pro' ),
                ],
                'condition' => [
                    'cat_layout' => 'layout'
                ]
            ]
        );
        $this->add_control(
            'layout-row-min-height',
            [
                'label' => __( 'Row Min Height', 'widgetkit-pro' ),
                'type' => Controls_Manager::SLIDER,
                'default' => [
                    'size' => 300,
                ],
                'range' => [
                    'px' => [
                        'min' => 100,
                        'max' => 1000,
                        'step' => 1,
                    ],
                ],
                'size_units' => [ 'px' ],
                'selectors' => [
					'{{WRAPPER}} .woo-product-categories .grid-skin-1' => 'grid-template-rows: repeat(2, minmax({{SIZE}}{{UNIT}}, 1fr));',
					'{{WRAPPER}} .woo-product-categories .grid-skin-2' => 'grid-template-rows: repeat(2, minmax({{SIZE}}{{UNIT}}, 1fr));',
					'{{WRAPPER}} .woo-product-categories .grid-skin-3 .column' => 'min-height: {{SIZE}}{{UNIT}};',
					'{{WRAPPER}} .woo-product-categories .grid-skin-4' => 'grid-template-rows: repeat(2, minmax({{SIZE}}{{UNIT}}, 1fr));',
                ],
                'condition' => [
                    'cat_layout' => 'layout'
                ]
            ]
        );
        
        $this->add_control(
            'show_category_count',
            [
                'label' => __( 'Product Count', 'widgetkit-pro' ),
                'type' => Controls_Manager::SWITCHER,
                'default' => 'yes',
                'label_on' => __( 'Yes', 'widgetkit-pro' ),
                'label_off' => __( 'No', 'widgetkit-pro' ),
                'return_value' => 'yes',
                'condition' => [
                    'cat_layout' => 'grid'
                ]
            ]
        );
        $this->add_responsive_control(
            'layout_grid_gap',
            [
                'label'   => esc_html__( 'Grid Gap', 'widgetkit-pro' ),
                'type'    => Controls_Manager::SLIDER,
                'default' => [
                    'size' =>15,
                ],
                'range'  => [
                    'px' => [
                        'min' => 0,
                        'max' => 50,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .woo-product-categories .product-category-wrapper .grid' => 'grid-gap: {{SIZE}}{{UNIT}};',
                    '{{WRAPPER}} .woo-product-categories .grid-skin-3 .column' => 'margin: {{SIZE}}{{UNIT}};',
                ],
            ]
        );
        // $this->add_control(
        //     'cat_layout_style',
        //     [
        //         'label'       => __( 'Style', 'widgetkit-pro' ),
        //         'type' => Controls_Manager::SELECT,
        //         'default' => 'overlay',
        //         'options' => [
        //             'overlay'  => __( 'Overaly', 'widgetkit-pro' ),
        //             'inside_content'  => __( 'Normal', 'widgetkit-pro' ),
        //         ],
        //         'condition' => [
        //             'product_layout_style' => 'image_top',
        //             'show_cart_button' => 'yes'
        //         ]
        //     ]
        // );
        $this->end_controls_section();

        /**
         * product 
         */
        $this->start_controls_section(
            'section_control_categories',
            [
                'label' => __('Query', 'widgetkit-pro'),
            ]
        );
        $this->add_control(
            'cat_query_type',
            [
                'label'       => __( 'Type', 'widgetkit-pro' ),
                'type' => Controls_Manager::SELECT,
                'default' => 'all_cat',
                'options' => [
                    'all_cat'  => __( 'All Category', 'widgetkit-pro' ),
                    'specific_cat'  => __( 'Specific Category', 'widgetkit-pro' ),
                    // 'group_cat'  => __( 'Group Category', 'widgetkit-pro' ),
                ],
            ]
        );
        // $this->add_control(
        //     'select_parent_category',
        //     [
        //         'label'       => __( 'Select Categories', 'widgetkit-pro' ),
        //         'type' => Controls_Manager::SELECT2,
        //         'default' => '',
        //         'multiple' => true,
        //         'options' => $parent_cats,
        //         'condition' => [
        //             'cat_query_type' => 'group_cat'
        //         ]
        //     ]
        // );
        $this->add_control(
            'select_specific_category',
            [
                'label'       => __( 'Select Categories', 'widgetkit-pro' ),
                'type' => Controls_Manager::SELECT2,
                'default' => '',
                'multiple' => true,
                'options' => $specific_cats,
                'condition' => [
                    'cat_query_type' => 'specific_cat'
                ]
            ]
        );
        $this->add_control(
            'category_num_to_show',
            [
                'label'   => __( 'Number of Category to Show', 'widgetkit-pro' ),
                'type'    => Controls_Manager::NUMBER,
                'default' => 4,
                'min'     => 1,
                'max'     => 50,
                'step'    => 1,
                'condition' => [
                    'cat_query_type' => 'all_cat',
                    'cat_layout' => 'grid'
                ]
            ]
        );
        $this->add_control(
            'category_num_to_show_for_layout',
            [
                'label'   => __( 'Number of Category to Show', 'widgetkit-pro' ),
                'type'    => Controls_Manager::NUMBER,
                'default' => 5,
                'min'     => 1,
                'max'     => 50,
                'step'    => 1,
                'condition' => [
                    'cat_query_type' => 'all_cat',
                    'cat_layout' => 'layout'
                ]
            ]
        );
        
        $this->add_control(
            'category_order',
            [
                'label'       => __( 'Order', 'widgetkit-pro' ),
                'type' => Controls_Manager::SELECT,
                'default' => 'ASC',
                'options' => [
                    'ASC'  => __( 'Ascending', 'widgetkit-pro' ),
                    'DESC'  => __( 'Descending', 'widgetkit-pro' ),
                ],
                'condition' => [
                    'cat_query_type' => 'all_cat'
                ]
            ]
        );
        $this->add_control(
            'category_hide_empty',
            [
                'label' => __( 'Hide empty', 'widgetkit-pro' ),
                'type' => Controls_Manager::SWITCHER,
                'default' => 'yes',
                'label_on' => __( 'Yes', 'widgetkit-pro' ),
                'label_off' => __( 'No', 'widgetkit-pro' ),
                'return_value' => 'yes',
                'condition' => [
                    'cat_query_type' => 'all_cat'
                ]
            ]
        );
        $this->end_controls_section();
        /**
         * primary layout
         */
        /**
         * Layout 
         */
        $this->start_controls_section(
            'section_control_primary_column',
            [
                'label' => __('Primary', 'widgetkit-pro'),
                'condition' => [
                    'cat_layout' => 'layout',
                    'layout_skin' => ['skin-1','skin-2', 'skin-4']
                ]
            ]
        );
            $this->add_control(
                'primary_column_number',
                [
                    'label'       => __( 'Choose Number', 'widgetkit-pro' ),
                    'type' => Controls_Manager::SELECT,
                    'default' => '1',
                    'options' => [
                        '1'  => __( '1', 'widgetkit-pro' ),
                        '2'  => __( '2', 'widgetkit-pro' ),
                        '3'  => __( '3', 'widgetkit-pro' ),
                        '4'  => __( '4', 'widgetkit-pro' ),
                        '5'  => __( '5', 'widgetkit-pro' ),
                    ],
                    
                ]
            );
        $this->end_controls_section();

// #endregion        


// # region style tab

    // #region header style
        /**
         * header style
         */
        $this->start_controls_section(
            'section_style_header',
            [
                'label' => __( 'Header', 'widgetkit-pro' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'section_title_typography',
                'selector' => '{{WRAPPER}} h2.woo-layout-header',
            ]
        );
        $this->add_control(
            'header_bottom_spacing',
            [
                'label' => __( 'Bottom Spacing', 'widgetkit-pro' ),
                'type' => Controls_Manager::SLIDER,
                'default' => [
                    'size' => 35,
                ],
                'range' => [
                    'px' => [
                        'min' => 0,
                        'max' => 100,
                        'step' => 1,
                    ],
                ],
                'size_units' => [ 'px' ],
                'selectors' => [
					'{{WRAPPER}} h2.woo-layout-header' => 'margin-bottom: {{SIZE}}{{UNIT}};',
				],
            ]
        );
        
        $this->end_controls_section();
    // #endregion

    
    // #region layout style
        /**
         * Layout
         */
        $this->start_controls_section(
            'section_style_layout',
            [
                'label' => __( 'Layout', 'widgetkit-pro' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_responsive_control(
            'content-align',
            [
                'label' => __( 'Alignment', 'widgetkit-pro' ),
                'type' => Controls_Manager::CHOOSE,
                'default' => 'center',
                'options' => [
                    'left'    => [
                        'title' => __( 'Left', 'widgetkit-pro' ),
                        'icon' => 'fa fa-align-left',
                    ],
                    'center' => [
                        'title' => __( 'Center', 'widgetkit-pro' ),
                        'icon' => 'fa fa-align-center',
                    ],
                    'right' => [
                        'title' => __( 'Right', 'widgetkit-pro' ),
                        'icon' => 'fa fa-align-right',
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .column .cat-content' => 'text-align: {{VALUE}};',
                ],
            ]
        );
        
        $this->end_controls_section();
    // #endregion


    // #region primary column style
        /**
         * Primary Column
         */
        $this->start_controls_section(
            'primary_section_style_content',
            [
                'label' => __( 'Primary Column', 'widgetkit-pro' ),
                'tab' => Controls_Manager::TAB_STYLE,
                'condition' => [
                    'cat_layout' => 'layout'
                ]
            ]
        );
        $this->add_control(
            'primary_title_section',
            [
            'label' => __( 'Title ', 'widgetkit-pro' ),
            'type' => Controls_Manager::HEADING,
            'separator' => 'before',
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'primary_content_title_typography',
                'selector' => '{{WRAPPER}} .grid-skin-1 .primary .cat-content a h3, {{WRAPPER}} .grid-skin-2 .primary .cat-content a h3, {{WRAPPER}} .grid-skin-3 .column:nth-child(1) .cat-content a h3, {{WRAPPER}} .grid-skin-3 .column:nth-child(2) .cat-content a h3, {{WRAPPER}} .grid-skin-4 .primary .cat-content a h3',
            ]
        );

        /**
         * tab start for title
         */
        $this->start_controls_tabs('primary_section_title_style_tabs');
            /**
             * Normal Tab
             */
            $this->start_controls_tab(
                'primary_section_title_style_normal',
                [
                    'label' => __( 'Normal', 'widgetkit-pro' ),
                ]
            );
            $this->add_control(
                'primary_content_title_color',
                [
                    'label' => __( 'Color', 'widgetkit-pro' ),
                    'type' => Controls_Manager::COLOR,
                    'default' => '#3d3d3d',
                    'selectors' => [
                        '{{WRAPPER}} .grid-skin-1  .primary .cat-content a h3' => 'color: {{VALUE}} ',
                        '{{WRAPPER}} .grid-skin-2  .primary .cat-content a h3' => 'color: {{VALUE}} ',
                        '{{WRAPPER}} .grid-skin-3  .column:nth-child(1) .cat-content a h3' => 'color: {{VALUE}} ',
                        '{{WRAPPER}} .grid-skin-3  .column:nth-child(2) .cat-content a h3' => 'color: {{VALUE}} ',
                        '{{WRAPPER}} .grid-skin-4  .primary .cat-content a h3' => 'color: {{VALUE}} ',
                    ],
                ]
            );
            $this->end_controls_tab();
            /**
             * Hover style
             */
            $this->start_controls_tab(
                'primary_section_title_style_hover',
                [
                    'label' => __( 'Hover', 'widgetkit-pro' ),
                ]
            );
            $this->add_control(
                'primary_content_title_color_hover',
                [
                    'label' => __( 'Color', 'widgetkit-pro' ),
                    'type' => Controls_Manager::COLOR,
                    'default' => '#7c7000',
                    'selectors' => [
                        '{{WRAPPER}} .grid-skin-1  .primary .cat-content a h3:hover' => 'color: {{VALUE}} ',
                        '{{WRAPPER}} .grid-skin-2  .primary .cat-content a h3:hover' => 'color: {{VALUE}} ',
                        '{{WRAPPER}} .grid-skin-3 .column:nth-child(1) .cat-content a h3:hover' => 'color: {{VALUE}} ',
                        '{{WRAPPER}} .grid-skin-3 .column:nth-child(2) .cat-content a h3:hover' => 'color: {{VALUE}} ',
                        '{{WRAPPER}} .grid-skin-4  .primary .cat-content a h3:hover' => 'color: {{VALUE}} ',
                    ],
                ]
            );
            $this->end_controls_tab();
        $this->end_controls_tabs();

        /**
         * Meta
         */
        $this->add_control(
            'primary_meta_section',
            [
            'label' => __( 'Meta ', 'widgetkit-pro' ),
            'type' => Controls_Manager::HEADING,
            'separator' => 'before',
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'primary_content_meta_typography',
                'selector' => '{{WRAPPER}} .grid-skin-1  .primary .cat-content .product-count, {{WRAPPER}} .grid-skin-2  .primary .cat-content .product-count, {{WRAPPER}} .grid-skin-3 .column:nth-child(1) .cat-content a h3, {{WRAPPER}} .grid-skin-3 .column:nth-child(2) .cat-content a h3, {{WRAPPER}} .grid-skin-4  .primary .cat-content .product-count',
            ]
        );
        $this->add_control(
            'primary_content_meta_color',
            [
                'label' => __( 'Color', 'widgetkit-pro' ),
                'type' => Controls_Manager::COLOR,
                'default' => '#707070',
                'selectors' => [
                    '{{WRAPPER}} .grid-skin-1  .primary .cat-content .product-count' => 'color: {{VALUE}} ',
                    '{{WRAPPER}} .grid-skin-2  .primary .cat-content .product-count' => 'color: {{VALUE}} ',
                    '{{WRAPPER}} .grid-skin-3 .column:nth-child(1) .cat-content .product-count' => 'color: {{VALUE}} ',
                    '{{WRAPPER}} .grid-skin-3 .column:nth-child(2) .cat-content .product-count' => 'color: {{VALUE}} ',
                    '{{WRAPPER}} .grid-skin-4  .primary .cat-content .product-count' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_responsive_control(
            'primary_content_padding',
            [
                'label'         => __('Content Padding', 'widgetkit-pro'),
                'type'          => Controls_Manager::DIMENSIONS,
                'size_units'    => ['px','%'],
                'separator'     => 'before',
                'selectors'     => [
                    '{{WRAPPER}} .grid-skin-1  .primary .cat-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                    '{{WRAPPER}} .grid-skin-2  .primary .cat-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                    '{{WRAPPER}} .grid-skin-3 .column:nth-child(1) .cat-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                    '{{WRAPPER}} .grid-skin-3 .column:nth-child(2) .cat-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                    '{{WRAPPER}} .grid-skin-4  .primary .cat-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                ],
                'default' => [
                    'top' => '15',
                    'right' => '15',
                    'bottom' => '15',
                    'left' => '15',
                    'unit' => 'px',
                    'isLinked' => false,
                ],
            ]
        );
        $this->add_control(
            'primary_content_background_color',
            [
                'label' => __( 'Content Background', 'widgetkit-pro' ),
                'type' => Controls_Manager::COLOR,
                'default' => '',
                'selectors' => [
                    '{{WRAPPER}} .grid-skin-1 .primary .cat-content' => 'background-color: {{VALUE}} ',
                    '{{WRAPPER}} .grid-skin-2 .primary .cat-content' => 'background-color: {{VALUE}} ',
                    '{{WRAPPER}} .grid-skin-3 .column:nth-child(1) .cat-content' => 'background-color: {{VALUE}} ',
                    '{{WRAPPER}} .grid-skin-3 .column:nth-child(2) .cat-content' => 'background-color: {{VALUE}} ',
                    '{{WRAPPER}} .grid-skin-4 .primary .cat-content' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->end_controls_section();
    // #endregion

    // #region image
        /**
         * image control
         */
        $this->start_controls_section(
            'section_style_image',
            [
                'label' => __( 'Image', 'widgetkit-pro' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
            $this->add_control(
                'cat_image_border_radius',
                [
                    'label' => esc_html__( 'Radius', 'widgetkit-for-elementor' ),
                    'type'  => Controls_Manager::DIMENSIONS,
                    'size_units' => [ 'px', '%' ],
                    'selectors'  => [
                        '{{WRAPPER}} .column .cat-thumb a' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}}; overflow:hidden;',
                        '{{WRAPPER}} .product-category-wrapper .grid-skin-1 .column ' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                        '{{WRAPPER}} .product-category-wrapper .grid-skin-2 .column ' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                        '{{WRAPPER}} .product-category-wrapper .grid-skin-3 .column ' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                        '{{WRAPPER}} .product-category-wrapper .grid-skin-4 .column ' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
                    ],
                ]
            );
            $this->add_group_control(
                Group_Control_Border::get_type(), 
                [
                'name'          => 'image-border',
                'selector'      => '{{WRAPPER}} .column .cat-thumb a, {{WRAPPER}} .product-category-wrapper .grid-skin-1 .column, {{WRAPPER}} .product-category-wrapper .grid-skin-2 .column, {{WRAPPER}} .product-category-wrapper .grid-skin-3 .column, {{WRAPPER}} .product-category-wrapper .grid-skin-4 .column',
                ]
            );
            $this->add_control(
                'cat_image_overlay',
                [
                    'label' => __( 'Overlay', 'widgetkit-pro' ),
                    'type' => Controls_Manager::COLOR,
                    'default' => '#707070',
                    'selectors' => [
                        '{{WRAPPER}} .column .cat-thumb .thumb-wrapper:before' => 'background: {{VALUE}} ',
                    ],
                    'condition' => [
                        'cat_layout' => 'grid',
                        'grid_text_layout' => 'inside'
                    ]
                ]
            );

        $this->end_controls_section();
    // #endregion
    
    // #region column style
        /**
         * Secondary Column
         */
        $this->start_controls_section(
            'section_style_content',
            [
                'label' => __( 'Column', 'widgetkit-pro' ),
                'tab' => Controls_Manager::TAB_STYLE,
            ]
        );
        $this->add_control(
            'title_section',
            [
            'label' => __( 'Title ', 'widgetkit-pro' ),
            'type' => Controls_Manager::HEADING,
            'separator' => 'before',
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'content_title_typography',
                'selector' => '{{WRAPPER}} .column .cat-content a h3',
            ]
        );

        /**
         * tab start for title
         */
        $this->start_controls_tabs('section_title_style_tabs');
            /**
             * Normal Tab
             */
            $this->start_controls_tab(
                'section_title_style_normal',
                [
                    'label' => __( 'Normal', 'widgetkit-pro' ),
                ]
            );
            $this->add_control(
                'content_title_color',
                [
                    'label' => __( 'Color', 'widgetkit-pro' ),
                    'type' => Controls_Manager::COLOR,
                    'default' => '#3d3d3d',
                    'selectors' => [
                        '{{WRAPPER}} .column .cat-content a h3' => 'color: {{VALUE}} ',
                    ],
                ]
            );
            $this->end_controls_tab();
            /**
             * Hover style
             */
            $this->start_controls_tab(
                'section_title_style_hover',
                [
                    'label' => __( 'Hover', 'widgetkit-pro' ),
                ]
            );
            $this->add_control(
                'content_title_color_hover',
                [
                    'label' => __( 'Color', 'widgetkit-pro' ),
                    'type' => Controls_Manager::COLOR,
                    'default' => '#7c7000',
                    'selectors' => [
                        '{{WRAPPER}} .column .cat-content a h3:hover' => 'color: {{VALUE}} ',
                    ],
                ]
            );
            $this->end_controls_tab();
        $this->end_controls_tabs();
        $this->add_responsive_control(
            'title_spacing_bottom',
            [
                'label'   => esc_html__( 'Bottom Spacing', 'widgetkit-for-elementor' ),
                'type'    => Controls_Manager::SLIDER,
                'default' => [
                    'size' =>20,
                ],
                'range'  => [
                    'px' => [
                        'min' => 0,
                        'max' => 200,
                    ],
                ],
                'selectors' => [
                    '{{WRAPPER}} .column .cat-content a h3' => 'margin-bottom: {{SIZE}}{{UNIT}};',
                ],
                'condition' => [
                    'cat_layout' => 'grid'
                ]
            ]
        );

        /**
         * Meta
         */
        $this->add_control(
            'meta_section',
            [
            'label' => __( 'Meta ', 'widgetkit-pro' ),
            'type' => Controls_Manager::HEADING,
            'separator' => 'before',
            ]
        );
        $this->add_group_control(
            Group_Control_Typography::get_type(),
            [
                'label' => __( 'Typography', 'widgetkit-pro' ),
                'name' => 'content_meta_typography',
                'selector' => '{{WRAPPER}} .column .cat-content .product-count',
            ]
        );
        $this->add_control(
            'content_meta_color',
            [
                'label' => __( 'Color', 'widgetkit-pro' ),
                'type' => Controls_Manager::COLOR,
                'default' => '#707070',
                'selectors' => [
                    '{{WRAPPER}} .column .cat-content .product-count' => 'color: {{VALUE}} ',
                ],
            ]
        );
        $this->add_responsive_control(
            'content_padding',
            [
                'label'         => __('Content Padding', 'widgetkit-pro'),
                'type'          => Controls_Manager::DIMENSIONS,
                'size_units'    => ['px','%'],
                'separator'     => 'before',
                'selectors'     => [
                    '{{WRAPPER}} .column .cat-content' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};'
                ],
                'default' => [
                    'top' => '15',
                    'right' => '15',
                    'bottom' => '15',
                    'left' => '15',
                    'unit' => 'px',
                    'isLinked' => false,
                ],
            ]
        );
        $this->add_control(
            'content_background_color',
            [
                'label' => __( 'Content Background', 'widgetkit-pro' ),
                'type' => Controls_Manager::COLOR,
                'default' => '',
                'selectors' => [
                    '{{WRAPPER}} .column .cat-content' => 'background-color: {{VALUE}} ',
                ],
            ]
        );
        $this->end_controls_section();
    // #endregion

// #endregion

    }


    protected function render()
    {
        $settings = $this->get_settings();
        $cat_query_type = widgetkit_pro_array_get($settings, 'cat_query_type');
        ?>

        <div id="woo-single-product-upsell-product<?php echo $this->get_id(); ?>" class="woo-single-product-upsell-product woo-single-product-upsell-product-<?php echo $this->get_id() ?>">

            <?php 
            include( plugin_dir_path( __FILE__ ) . '../layout/woo/single-product/upsell-product.php'); 
            // if($cat_query_type === 'specific_cat'){
            // }else{
            //     include( plugin_dir_path( __FILE__ ) . '../layout/woo/category/all-category.php'); 
            // }
            ?>
        </div>
        <script>
            jQuery(function($){
                if(!$('body').hasClass('wkpro-woo-single-product-upsell-product')){
                    $('body').addClass('wkpro-woo-single-product-upsell-product');
                }
            });
        </script>

    <?php
    }
    protected function _content_template()
    {
    }
}
