<?php

use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Productscarouselfourteenthstkaveh extends Widget_Base{

  public function get_name(){
    return 'productscarouselfourteenthstkaveh';
  }

  public function get_title(){
    return esc_html__( 'Products Carousel Style Fourteen', 'kavehTheme' );
  }

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Element Title', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'imgproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Select Your Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading::before' =>
                'background: url({{URL}}) 0 0 no-repeat',
                '{{WRAPPER}} .top-selling-products-two-heading::after' =>
                'background: url({{URL}}) 0 0 no-repeat',
        ],
        ]
      );
      $this->add_control(
        'title2productscarouselfourteenthstkaveh',
        [
            'label' => esc_html__( 'Subtitle', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::TEXT,
            'default' => esc_html__( 'Most Popular', 'kavehTheme' ),
    
        ]
    );
    $this->add_control(
      'tagheadingproductscarouselfourteenthstkaveh',
      [
        'label' => esc_html__( 'Subtitle Tag', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'H3',
        'options' => [
          'H1'  => esc_html__( 'H1', 'kavehTheme' ),
          'H2' => esc_html__( 'H2', 'kavehTheme' ),
          'H3' => esc_html__( 'H3', 'kavehTheme' ),
          'H4' => esc_html__( 'H4', 'kavehTheme' ),
          'H5' => esc_html__( 'H5', 'kavehTheme' ),
          'H6' => esc_html__( 'H6', 'kavehTheme' ),
          'p' => esc_html__( 'p', 'kavehTheme' ),
          'div' => esc_html__( 'div', 'kavehTheme' ),
        ],
      ]
    );
      $this->add_control(
        'titleproducts2carouseleleventhstkaveh',
        [
            'label' => esc_html__( 'Main Title', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::TEXT,
            'default' => esc_html__( 'Best Sellers', 'kavehTheme' ),
    
        ]
    );
      $this->add_control(
        'tagheadingfproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Title Tag', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'H4',
          'options' => [
            'H1'  => esc_html__( 'H1', 'kavehTheme' ),
            'H2' => esc_html__( 'H2', 'kavehTheme' ),
            'H3' => esc_html__( 'H3', 'kavehTheme' ),
            'H4' => esc_html__( 'H4', 'kavehTheme' ),
            'H5' => esc_html__( 'H5', 'kavehTheme' ),
            'H6' => esc_html__( 'H6', 'kavehTheme' ),
            'p' => esc_html__( 'p', 'kavehTheme' ),
            'div' => esc_html__( 'div', 'kavehTheme' ),
          ],
        ]
      );
    $this->add_control(
      'buttonti2productscarouselfourteenthstkaveh',
      [
          'label' => esc_html__( 'Button Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'default' => esc_html__( 'View Special Offer', 'kavehTheme' ),
  
      ]
  );
  $this->add_control(
    'iconbuttproductscarouselfourteenthstkaveh',
    [
      'label' => esc_html__( 'Icon', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::ICONS,
      'skin' => 'inline',
      'exclude_inline_options' => [ 'svg' ],
      'default' => [
        'value' => 'icon-arrow-left-3',
      ],
    ]
  );
  $this->add_control(
    'buttontilink2productscarouselfourteenthstkaveh',
    [
        'label' => esc_html__( 'Button Link', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => esc_html__( '#', 'kavehTheme' ),

    ]
);
    $this->end_controls_section();   
  
      $this->start_controls_section(
        'content4productscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Product Settings', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'kaveh_exclude_out_of_stock',
        [
          'label' => esc_html__( 'Hide Out of Stock Products', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SWITCHER,
          'yes' => esc_html__( 'Yes', 'kavehTheme' ),
          'no' => esc_html__( 'No', 'kavehTheme' ),
          'return_value' => 'yes',
          'default' => 'yes',
        ]
      );
  $this->add_control(
    'pproductscarouselfourteenthstkaveh',
    [
      'label' => esc_html__( 'Show Products', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::SELECT,
      'default' => 'all',
      'options' => [
        'all'  => esc_html__( 'All', 'kavehTheme' ),
        'cat'  => esc_html__( 'Category', 'kavehTheme' ),

      ],
    ]
    );
    $this->add_control(
      'psortproductscarouselfourteenthstkaveh',
      [
        'label' => esc_html__( 'Sort Products By', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'date',
        'options' => [
          'date'  => esc_html__( 'Date', 'kavehTheme' ),
          '_price'  => esc_html__( 'Price', 'kavehTheme' ),
          '_wc_average_rating'  => esc_html__( 'Most Popular', 'kavehTheme' ),
          'total_sales'  => esc_html__( 'Sales Amount', 'kavehTheme' ),
  
        ],
      ]
      );
      $this->add_control(
        'psortiproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Sort Type', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'desc',
          'options' => [
            'asc'  => esc_html__( 'Ascending', 'kavehTheme' ),
            'desc'  => esc_html__( 'Descending', 'kavehTheme' ),
          ],
        ]
        );
  $this->add_control(
    'stylecartproductscarouselfourteenthstkaveh',
    [
      'label' => esc_html__( 'Product Box Layout', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::SELECT,
      'default' => 'one',
        'options' => [
          'one'  => esc_html__( 'Style One', 'kavehTheme' ),
          'two'  => esc_html__( 'Style Two', 'kavehTheme' ),
          'three'  => esc_html__( 'Style Three', 'kavehTheme' ),
          'four'  => esc_html__( 'Style Four', 'kavehTheme' ),
          'five'  => esc_html__( 'Style Five', 'kavehTheme' ),
          'six'  => esc_html__( 'Style Six', 'kavehTheme' ),
          'seven'  => esc_html__( 'Style Seven', 'kavehTheme' ),
          'eight'  => esc_html__( 'Style Eight', 'kavehTheme' ),
          'nine'  => esc_html__( 'Style Nine', 'kavehTheme' ),
          'ten'  => esc_html__( 'Style Ten', 'kavehTheme' ),
          'eleven'  => esc_html__( 'Style Eleven', 'kavehTheme' ),
          'twelve'  => esc_html__( 'Style Twelve', 'kavehTheme' ),
          'thirteen'  => esc_html__( 'Style Thirteen', 'kavehTheme' ),
          'fourteen'  => esc_html__( 'Style Fourteen', 'kavehTheme' ),
          'fifteen'  => esc_html__( 'Style Fifteen', 'kavehTheme' ),
          'sixteen'  => esc_html__( 'Style Sixteen', 'kavehTheme' ),
          'seventeen'  => esc_html__( 'Style Seventeen', 'kavehTheme' ),
          'eighteen'  => esc_html__( 'Style Eighteen', 'kavehTheme' ),
          'nineteen'  => esc_html__( 'Style Nineteen', 'kavehTheme' ),
          'twenty'  => esc_html__( 'Style Twenty', 'kavehTheme' ),
          'twenty-one'  => esc_html__( 'Style Twenty One', 'kavehTheme' ),
          'twenty-two'  => esc_html__( 'Style Twenty Two', 'kavehTheme' ),
          'twenty-three'  => esc_html__( 'Style Twenty Three', 'kavehTheme' ),
          'twenty-four'  => esc_html__( 'Style Twenty Four', 'kavehTheme' ),
          'twenty-five'  => esc_html__( 'Style Twenty Five', 'kavehTheme' ),
          'twenty-six'  => esc_html__( 'Style Twenty Six', 'kavehTheme' ),
          'twenty-seven'  => esc_html__( 'Style Twenty Seven', 'kavehTheme' ),
          'twenty-eight'  => esc_html__( 'Style Twenty Eight', 'kavehTheme' ),
        ],
    ]
    );
  $options5 = array();
$orderby = 'name';
$order = 'asc';
$hide_empty = false ;
$cat_args = array(
    'orderby'    => $orderby,
    'order'      => $order,
    'hide_empty' => $hide_empty,
);

$product_categories = get_terms( 'product_cat', $cat_args );

foreach ( $product_categories as $key => $category ) {
    $options5[$category->term_id] = $category->name;
}
$this->add_control(
    'catproductscarouselfourteenthstkaveh',
    [
      'label' => esc_html__( 'Select Category', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::SELECT2, 
      'multiple' => true,
      'options' => $options5,
      'condition' => [
        'pproductscarouselfourteenthstkaveh' => 'cat',
      ],
    ]
);
$this->end_controls_section();   
$this->start_controls_section(
  'content5productscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Carousel Settings', 'kavehTheme' ),
            'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
  ]
);
$this->add_control(
  'showarrowsproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Show Arrows?', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SWITCHER,
    'yes' => esc_html__( 'Yes', 'kavehTheme' ),
    'no' => esc_html__( 'No', 'kavehTheme' ),
    'return_value' => 'yes',
    'default' => 'yes',
  ]
);
$this->add_control(
  'productnumberproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Number of Products Displayed', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 0,
    'max' => 50,
    'step' => 1,
    'default' => 5,
  ]
);
$this->add_control(
  'productcolumnproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Number of Product Columns on Desktop', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 0,
    'max' => 5,
    'step' => 0.5,
    'default' => 4,

  ]
); 
$this->add_control(
  'productcolumn2productscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Number of Product Columns on Tablet', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 0,
    'max' => 5,
    'step' => 0.5,
    'default' => 2,

  ]
);
$this->add_control(
  'productcolumn3productscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Number of Product Columns on Mobile', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 0,
    'max' => 5,
    'step' => 0.5,
    'default' => 1.5,

  ]
);
$this->add_control(
  'autoplayproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Enable Autoplay', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SWITCHER,
    'yes' => esc_html__( 'Yes', 'kavehTheme' ),
    'no' => esc_html__( 'No', 'kavehTheme' ),
    'return_value' => 'yes',
    'default' => 'no',
  ]
);
$this->add_control(
  'autoplaydelayproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Autoplay Delay (milliseconds)', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 1000,
    'max' => 10000,
    'step' => 500,
    'default' => 3000,
    'condition' => [
      'autoplayproductscarouselfourteenthstkaveh' => 'yes',
    ],
  ]
);
$this->add_control(
  'pauseonhoverproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Pause on Hover', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SWITCHER,
    'yes' => esc_html__( 'Yes', 'kavehTheme' ),
    'no' => esc_html__( 'No', 'kavehTheme' ),
    'return_value' => 'yes',
    'default' => 'yes',
    'condition' => [
      'autoplayproductscarouselfourteenthstkaveh' => 'yes',
    ],
  ]
);
$this->add_control(
  'loopproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Infinite Loop', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SWITCHER,
    'yes' => esc_html__( 'Yes', 'kavehTheme' ),
    'no' => esc_html__( 'No', 'kavehTheme' ),
    'return_value' => 'yes',
    'default' => 'yes',
  ]
);
$this->add_control(
  'speedproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Transition Speed (milliseconds)', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 300,
    'max' => 3000,
    'step' => 100,
    'default' => 300,
  ]
);
$this->add_control(
  'centeredslidesproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Centered Slides', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SWITCHER,
    'yes' => esc_html__( 'Yes', 'kavehTheme' ),
    'no' => esc_html__( 'No', 'kavehTheme' ),
    'return_value' => 'yes',
    'default' => 'no',
  ]
);
$this->add_control(
  'freemodeproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Free Mode', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SWITCHER,
    'yes' => esc_html__( 'Yes', 'kavehTheme' ),
    'no' => esc_html__( 'No', 'kavehTheme' ),
    'return_value' => 'yes',
    'default' => 'no',
    'description' => esc_html__( 'Slides move freely', 'kavehTheme' ),
  ]
);
$this->add_control(
  'effectproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Transition Effect', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SELECT,
    'default' => 'slide',
    'options' => [
      'slide' => esc_html__( 'Slide', 'kavehTheme' ),
      'fade' => esc_html__( 'Fade', 'kavehTheme' ),
      'cube' => esc_html__( 'Cube', 'kavehTheme' ),
      'coverflow' => esc_html__( 'Coverflow', 'kavehTheme' ),
      'flip' => esc_html__( 'Flip', 'kavehTheme' ),
    ],
  ]
);
$this->add_control(
  'showarrowproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Show Arrows', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SWITCHER,
    'yes' => esc_html__( 'Yes', 'kavehTheme' ),
    'no' => esc_html__( 'No', 'kavehTheme' ),
    'return_value' => 'yes',
    'default' => 'no',
  ]
);
$this->add_control(
  'showdotsproductscarouselfourteenthstkaveh',
  [
    'label' => esc_html__( 'Show Pagination Dots', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SWITCHER,
    'yes' => esc_html__( 'Yes', 'kavehTheme' ),
    'no' => esc_html__( 'No', 'kavehTheme' ),
    'return_value' => 'yes',
    'default' => 'no',
  ]
);
       $this->end_controls_section();
       $this->start_controls_section(
        'style_productscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Title Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'textcolor3productscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Subtitle Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .title' => 'color: {{VALUE}} !important;',
          ],
        ]
      ); 
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'title2_productscarouselfourteenthstkaveh',
          'label' => esc_html__( 'Subtitle Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-selling-products-two-heading .title',
        ]
      );

      
      $this->add_control(
        'textcolor21productscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Main Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .sub-title' => 'color: {{VALUE}} !important;',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'title_productscarouselfourteenthstkaveh',
          'label' => esc_html__( 'Main Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-selling-products-two-heading .sub-title',
        ]
      );
      $this->add_control(
        'bgcolorboldbolproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Title Bar Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading' => 'background-image: linear-gradient(268.1deg, {{VALUE}} 8.23%, rgba(242, 229, 221, 0.142986) 92.92%, rgba(242, 229, 221, 0) 128.56%)',
          ],
        ]
      );
      $this->add_control(
        'buttonradiusnavarproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Title Bar Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
          ],
        ]
      );
      $this->add_control(
        'navarpaddingproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Title Bar Padding', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'styleb_productscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Button Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'button_productscarouselfourteenthstkaveh',
          'label' => esc_html__( 'Button Text Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-selling-products-two-heading .btn',
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Text_Shadow::get_type(),
        [
          'name' => 'text_shadowproductscarouselfourteenthstkaveh',
          'label' => esc_html__( 'Text Shadow', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-selling-products-two-heading .btn',
        ]
      );
      $this->add_control(
        'iconsizenchbproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Icon Size', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 200,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn i' => 'font-size: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->start_controls_tabs(
        'style_tabsproductscarouselfourteenthstkaveh'
      );
    
      $this->start_controls_tab(
        'style_normal_tabproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Normal', 'kavehTheme' ),
        ]
      );
      $this->add_control(
        'textbuttoncolorproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Button Text Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn' => 'color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'textbutton1colorproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Icon Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn i' => 'color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttoncolorproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Button Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn' => 'background-color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttonradiusproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'More Button Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Border::get_type(),
        [
          'name' => 'borderproductscarouselfourteenthstkaveh',
          'label' => esc_html__( 'Border', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-selling-products-two-heading .btn',
        ]
      );
      $this->add_control(
        'buttonbordersproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Border Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'condition' => [
            'borderproductscarouselfourteenthstkaveh!' => '',
          ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
          ],
        ]
      );
      $this->end_controls_tab();
      $this->start_controls_tab(
        'style_hove_tabproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Hover', 'kavehTheme' ),
        ]
      );
      $this->add_control(
        'textbuttoncolorhoverproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Button Text Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn:hover' => 'color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'textbutton1hovercolorproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Icon Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn:hover i' => 'color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttoncolorhoverproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Button Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn:hover' => 'background-color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttonradiushoverproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'More Button Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Border::get_type(),
        [
          'name' => 'borderhoverproductscarouselfourteenthstkaveh',
          'label' => esc_html__( 'Border', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-selling-products-two-heading .btn:hover',
        ]
      );
      $this->add_control(
        'buttonbordershoverproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Border Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'condition' => [
            'borderhoverproductscarouselfourteenthstkaveh!' => '',
          ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn:hover' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
          ],
        ]
      );
      $this->end_controls_tab();
      $this->end_controls_tabs();
      $this->add_group_control(
        \Elementor\Group_Control_Box_Shadow::get_type(),
        [
          'name' => 'box_shadowproductscarouselfourteenthstkaveh',
          'label' => esc_html__( 'Button Shadow', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .top-selling-products-two-heading .btn',
        ]
      );
      $this->add_control(
        'hr2productscarouselfourteenthstkaveh',
        [
          'type' => \Elementor\Controls_Manager::DIVIDER,
        ]
      );
      $this->add_control(
        'buttonpaddingproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Padding', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading .btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style3_productscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Image Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'imagewidth3productscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Image Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 500,
              'step' => 5,
            ],

          ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading::before' => 'width: {{SIZE}}{{UNIT}};',
            '{{WRAPPER}} .top-selling-products-two-heading::after' => 'width: {{SIZE}}{{UNIT}};',

          ],
        ]
      );
      $this->add_control(
        'imageheight3amazingoffersecondstkaveh',
        [
          'label' => esc_html__( 'Image Height', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 500,
              'step' => 5,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two-heading::before' => 'height: {{SIZE}}{{UNIT}};',
            '{{WRAPPER}} .top-selling-products-two-heading::after' => 'height: {{SIZE}}{{UNIT}};',

          ],
        ]
      );
      
      $this->end_controls_section();
      $this->start_controls_section(
        'style5_productscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Carousel Arrow Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
          'condition' => [
            'showarrowsproductscarouselfourteenthstkaveh' => 'yes',

          ],
        ]
      );
      $this->add_control(
        'arrowscolorproductscarouselfourteenthstkaveh',
        [
          'label' => esc_html__( 'Carousel Arrow Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .top-selling-products-two .swiper-button-next::after' => 'color: {{VALUE}} !important;',
            '{{WRAPPER}}  .top-selling-products-two .swiper-button-prev::after' => 'color: {{VALUE}} !important;',
          ],
        ]
      ); 
      $this->end_controls_section();

        }
 

  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id();
    ?>
    <section class="top-selling-products-two">
      <div class="container position-relative">
        <!-- Start Heading -->
        <div class="top-selling-products-two-heading position-relative d-flex align-items-md-center justify-content-md-between flex-column flex-md-row gap-4 gap-md-0">
          <div>
            <<?php echo  esc_attr($settings['tagheadingproductscarouselfourteenthstkaveh']); ?> class="title d-flex align-items-center">
            <?php echo  esc_html($settings['title2productscarouselfourteenthstkaveh']); ?>
            </<?php echo  esc_attr($settings['tagheadingproductscarouselfourteenthstkaveh']); ?>>
            <<?php echo  esc_attr($settings['tagheadingfproductscarouselfourteenthstkaveh']); ?> class="sub-title">  <?php echo  esc_html($settings['titleproducts2carouseleleventhstkaveh']); ?> </<?php echo  esc_attr($settings['tagheadingfproductscarouselfourteenthstkaveh']); ?>>
          </div>
          <a href="<?php echo  esc_url($settings['buttontilink2productscarouselfourteenthstkaveh']); ?>" class="btn btn-dark-3 d-flex align-items-center justify-content-center position-relative">
            <?php echo  esc_html($settings['buttonti2productscarouselfourteenthstkaveh']); ?>
            <i class="<?php echo  esc_html($settings['iconbuttproductscarouselfourteenthstkaveh']['value']); ?>"></i>
          </a>
        </div>
        <!-- End Heading -->
        <!-- Start Carousel -->
        <div class="swiper swiper-top-selling-products-two" data-swiper='<?php echo json_encode([
          "loop" => $settings['loopproductscarouselfourteenthstkaveh'] === "yes",
          "autoplay" => $settings['autoplayproductscarouselfourteenthstkaveh'] === "yes" ? [
            "delay" => intval($settings['autoplaydelayproductscarouselfourteenthstkaveh']),
            "pauseOnMouseEnter" => $settings['pauseonhoverproductscarouselfourteenthstkaveh'] === "yes"
          ] : false,
          "speed" => intval($settings['speedproductscarouselfourteenthstkaveh']),
          "effect" => $settings['effectproductscarouselfourteenthstkaveh'],
          "centeredSlides" => $settings['centeredslidesproductscarouselfourteenthstkaveh'] === "yes",
          "freeMode" => $settings['freemodeproductscarouselfourteenthstkaveh'] === "yes",
          "navigation" => $settings['showarrowproductscarouselfourteenthstkaveh'] === "yes" ? [
            "prevEl" => ".swiper-button-prev",
            "nextEl" => ".swiper-button-next"
          ] : false,
          "pagination" => $settings['showdotsproductscarouselfourteenthstkaveh'] === "yes" ? [
            "el" => ".swiper-pagination",
            "clickable" => true
          ] : false,
          "breakpoints" => [
            320 => ["slidesPerView" => intval($settings['productcolumn3productscarouselfourteenthstkaveh']), "spaceBetween" => 4],
            576 => ["slidesPerView" => intval($settings['productcolumn3productscarouselfourteenthstkaveh']), "spaceBetween" => 8],
            768 => ["slidesPerView" => intval($settings['productcolumn2productscarouselfourteenthstkaveh']), "spaceBetween" => 8],
            992 => ["slidesPerView" => intval($settings['productcolumnproductscarouselfourteenthstkaveh']), "spaceBetween" => 11],
          ]
        ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>'>
          <div class="swiper-wrapper">
          <?php if('cat'===$settings['pproductscarouselfourteenthstkaveh']){ ?>

              <?php
                // Define your custom query arguments
                $query_args = array(
                  'post_type' => array('product'),
'post_status' => array('publish'),
                  'posts_per_page' => $settings['productnumberproductscarouselfourteenthstkaveh'],
                  'orderby' => $settings['psortproductscarouselfourteenthstkaveh'] === 'date' ? 'date' : 'meta_value_num', // Default to date or meta value
                  'order' => $settings['psortiproductscarouselfourteenthstkaveh'],
                  'tax_query' => array(
                    'relation' => 'AND',
                    array(
                      'taxonomy' => 'product_cat',
                      'field' => 'term_id',
                      'terms' => $settings['catproductscarouselfourteenthstkaveh'],
                    ),
                  ),
                );
                // Handle specific orderby values
                switch ($settings['psortproductscarouselfourteenthstkaveh']) {
                  case '_price':
                    $query_args['meta_key'] = '_price';
                    $query_args['orderby'] = 'meta_value_num';
                    break;

                  case '_wc_average_rating':
                    $query_args['meta_key'] = '_wc_average_rating';
                    $query_args['orderby'] = 'meta_value_num';
                    break;

                  case 'total_sales':
                    $query_args['meta_key'] = 'total_sales';
                    $query_args['orderby'] = 'meta_value_num';
                    break;
                }

                if ("yes" === $settings['kaveh_exclude_out_of_stock']) {
                  $query_args['tax_query'][] = array(
                    'taxonomy' => 'product_visibility',
                    'field' => 'name',
                    'terms' => array('outofstock'),
                    'operator' => 'NOT IN'
                  );
                }
                // Get the cached query results
                $cached_query = KavehCustomQuery::get_cached_query($query_args);
                if ($cached_query->have_posts()):
                  while ($cached_query->have_posts()):
                    $cached_query->the_post();
                    ?>
                    <div class="swiper-slide h-auto">
                      <?php $styleproduct2 = $settings['stylecartproductscarouselfourteenthstkaveh']; ?>
                      <?php get_template_part("template-part/product-cart-$styleproduct2"); ?>
                    </div>
                    <?php
                  endwhile;
                  wp_reset_postdata();
                else:
                  echo 'No posts found.';
                endif;
                ?>


              <?php }elseif('all'===$settings['pproductscarouselfourteenthstkaveh']){
                // Define your custom query arguments
                $query_args = array(
                  'post_type' => array('product'),
'post_status' => array('publish'),
                  'posts_per_page' => $settings['productnumberproductscarouselfourteenthstkaveh'],
                  'orderby' => $settings['psortproductscarouselfourteenthstkaveh'] === 'date' ? 'date' : 'meta_value_num', // Default to date or meta value
                  'order' => $settings['psortiproductscarouselfourteenthstkaveh'],
                  'tax_query' => array(
                    'relation' => 'AND',
                  ),
                );
                // Handle specific orderby values
                switch ($settings['psortproductscarouselfourteenthstkaveh']) {
                  case '_price':
                    $query_args['meta_key'] = '_price';
                    $query_args['orderby'] = 'meta_value_num';
                    break;

                  case '_wc_average_rating':
                    $query_args['meta_key'] = '_wc_average_rating';
                    $query_args['orderby'] = 'meta_value_num';
                    break;

                  case 'total_sales':
                    $query_args['meta_key'] = 'total_sales';
                    $query_args['orderby'] = 'meta_value_num';
                    break;
                }

                if ("yes" === $settings['kaveh_exclude_out_of_stock']) {
                  $query_args['tax_query'][] = array(
                    'taxonomy' => 'product_visibility',
                    'field' => 'name',
                    'terms' => array('outofstock'),
                    'operator' => 'NOT IN'
                  );
                }
                // Get the cached query results
                $cached_query = KavehCustomQuery::get_cached_query($query_args);
                if ($cached_query->have_posts()):
                  while ($cached_query->have_posts()):
                    $cached_query->the_post();
                    ?>
                    <div class="swiper-slide h-auto">
                      <?php $styleproduct2 = $settings['stylecartproductscarouselfourteenthstkaveh']; ?>
                      <?php get_template_part("template-part/product-cart-$styleproduct2"); ?>
                    </div>
                    <?php
                  endwhile;
                  wp_reset_postdata();
                else:
                  echo 'No posts found.';
                endif;
                ?>
             
                <?php } ?>
          </div>
          <?php if('yes'===$settings['showarrowsproductscarouselfourteenthstkaveh']){ ?>
          <!-- Start Button -->
          <div class="swiper-button-next top-0 end-0"></div>
          <div class="swiper-button-prev top-0"></div>
          <!-- End Button -->
          <?php } ?>
          <?php if($settings['showdotsproductscarouselfourteenthstkaveh'] === 'yes'){ ?>
            <div class="swiper-pagination"></div>
          <?php } ?>
        </div>
        <!-- End Carousel -->
      </div>
    </section>
    <style>
      .top-selling-products-two-heading::before, .top-selling-products-two-heading::after{
        background-size : contain !important;
      }
    </style>
      
    <?php
  }


}
