<?php



use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Productscarouseleighthstkaveh extends Widget_Base{

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

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

  public function get_categories(){
    return ['kavehelements'];
  }
 
  protected function register_controls(){
    
    $this->start_controls_section(
        'contentproductscarouseleighthstkaveh',
        [
          'label' => esc_html__( 'Title Settings', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
    
      $this->add_control(
          'titleproductscarouseleighthstkaveh',
          [
              'label' => esc_html__( 'Title', 'kavehTheme' ),
              'type' => \Elementor\Controls_Manager::TEXT,
              'default' => esc_html__( 'Best Selling Products', 'kavehTheme' ),
      
          ]
      );
      $this->add_control(
        'title3productscarouseleighthstkaveh',
        [
            'label' => esc_html__( 'Bold Title', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::TEXT,
            'default' => esc_html__( 'Kaveh', 'kavehTheme' ),
    
        ]
    );

      $this->add_control(
        'tagheadingproductscarouseleighthstkaveh',
        [
          'label' => esc_html__( 'Title Tag', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SELECT,
          'default' => 'H2',
          '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' ),
            'span' => esc_html__( 'span', 'kavehTheme' ),
          ],
        ]
      );

      $this->add_control(
        'title2productscarouseleighthstkaveh',
        [
            'label' => esc_html__( 'Subtitle', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::TEXT,
            'default' => esc_html__( 'See the best sellers here', 'kavehTheme' ),
    
        ]
    );
    $this->add_control(
      'tag2headingproductscarouseleighthstkaveh',
      [
        'label' => esc_html__( 'Subtitle 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' ),
          'span' => esc_html__( 'span', 'kavehTheme' ),
        ],
      ]
    );
    $this->add_control(
      'showbutton1productscarouseleighthstkaveh',
      [
        'label' => esc_html__( 'Show Button?', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'yes' => esc_html__( 'Yes', 'kavehTheme' ),
        'no' => esc_html__( 'No', 'kavehTheme' ),
        'return_value' => 'yes',
        'default' => 'yes',
      ]
      );
      $this->add_control(
        'buttons2productscarouseleighthstkaveh',
        [
            'label' => esc_html__( 'Button Title', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::TEXT,
            'default' => esc_html__( 'Products', 'kavehTheme' ),
            'condition' => [
              'showbutton1productscarouseleighthstkaveh' => 'yes',
            ],
        ]
    );
    $this->add_control(
      'iconbutts2productscarouseleighthstkaveh',
      [
        'label' => esc_html__( 'Icon', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::ICONS,
        'skin' => 'inline',
        'condition' => [
          'showbutton1productscarouseleighthstkaveh' => 'yes',
        ],
        'exclude_inline_options' => [ 'svg' ],
        'default' => [
          'value' => 'icon-eye-2',
        ],
      ]
    );
    $this->add_control(
      'linkbuttons2productscarouseleighthstkaveh',
      [
          'label' => esc_html__( 'Button Link', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'condition' => [
              'showbutton1productscarouseleighthstkaveh' => 'yes',
            ],
          'default' => esc_html__( '#', 'kavehTheme' ),
  
      ]
  );
  $this->end_controls_section();

  $this->start_controls_section(
    'content2productscarouseleighthstkaveh',
    [
      'label' => esc_html__( 'Product Settings', 'kavehTheme' ),
              'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
    ]
  );
  $this->add_control(
    'stylecartproductscarouseleighthstkaveh',
    [
      'label' => esc_html__( 'Product Box Layout', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::SELECT,
      'default' => 'one',
      'options' => [
        'one'  => esc_html__( 'First Layout', 'kavehTheme' ),
        'two'  => esc_html__( 'Second Layout', 'kavehTheme' ),
        'three'  => esc_html__( 'Third Layout', 'kavehTheme' ),
        'four'  => esc_html__( 'Fourth Layout', 'kavehTheme' ),
        'five'  => esc_html__( 'Fifth Layout', 'kavehTheme' ),
        'six'  => esc_html__( 'Sixth Layout', 'kavehTheme' ),
        'seven'  => esc_html__( 'Seventh Layout', 'kavehTheme' ),
        'eight'  => esc_html__( 'Eighth Layout', 'kavehTheme' ),
        'nine'  => esc_html__( 'Ninth Layout', 'kavehTheme' ),
        'ten'  => esc_html__( 'Tenth Layout', 'kavehTheme' ),
        'eleven'  => esc_html__( 'Eleventh Layout', 'kavehTheme' ),
        'twelve'  => esc_html__( 'Twelfth Layout', 'kavehTheme' ),
        'thirteen'  => esc_html__( 'Thirteenth Layout', 'kavehTheme' ),
        'fourteen'  => esc_html__( 'Fourteenth Layout', 'kavehTheme' ),
        'fifteen'  => esc_html__( 'Fifteenth Layout', 'kavehTheme' ),
        'sixteen'  => esc_html__( 'Sixteenth Layout', 'kavehTheme' ),
        'seventeen'  => esc_html__( 'Seventeenth Layout', 'kavehTheme' ),
        'eighteen'  => esc_html__( 'Eighteenth Layout', 'kavehTheme' ),
        'nineteen'  => esc_html__( 'Nineteenth Layout', 'kavehTheme' ),
        'twenty'  => esc_html__( 'Twentieth Layout', 'kavehTheme' ),
        'twenty-one'  => esc_html__( 'Twenty-First Layout', 'kavehTheme' ),
        'twenty-two'  => esc_html__( 'Twenty-Second Layout', 'kavehTheme' ),
        'twenty-three'  => esc_html__( 'Twenty-Third Layout', 'kavehTheme' ),
        'twenty-four'  => esc_html__( 'Twenty-Fourth Layout', 'kavehTheme' ),
        'twenty-five'  => esc_html__( 'Twenty-Fifth Layout', 'kavehTheme' ),
        'twenty-six'  => esc_html__( 'Twenty-Sixth Layout', 'kavehTheme' ),
        'twenty-seven'  => esc_html__( 'Twenty-Seventh Layout', 'kavehTheme' ),
        'twenty-eight'  => esc_html__( 'Twenty-Eighth Layout', 'kavehTheme' ),
      ],
    ]
    );
    
    $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(
      'pproductscarouseleighthstkaveh',
      [
        'label' => esc_html__( 'Display Products', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'all',
        'options' => [
          'all'  => esc_html__( 'All', 'kavehTheme' ),
          'cat'  => esc_html__( 'Category', 'kavehTheme' ),
  
        ],
      ]
      );
      $this->add_control(
        'psortproductscarouseleighthstkaveh',
        [
          '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 Volume', 'kavehTheme' ),
    
          ],
        ]
        );
        $this->add_control(
          'psortiproductscarouseleighthstkaveh',
          [
            'label' => esc_html__( 'Sort Order', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::SELECT,
            'default' => 'desc',
            'options' => [
              'asc'  => esc_html__( 'Ascending', 'kavehTheme' ),
              'desc'  => esc_html__( 'Descending', 'kavehTheme' ),
            ],
          ]
          );
  $options2 = 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 ) {
    $options2[$category->term_id] = $category->name;
}
$this->add_control(
    'catproductscarouseleighthstkaveh',
    [
      'label' => esc_html__( 'Select Category', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::SELECT2, 
      'multiple' => true,
      'options' => $options2,
      'condition' => [
        'pproductscarouseleighthstkaveh' => 'cat',
      ],
    ]
);
$this->end_controls_section();
$this->start_controls_section(
  'content3productscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Carousel Settings', 'kavehTheme' ),
            'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
  ]
);
$this->add_control(
  'showarrowproductscarouseleighthstkaveh',
  [
    '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(
  'productnumberproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Number of Products Displayed', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 0,
    'max' => 50,
    'step' => 1,
    'default' => 5,
  ]
);
$this->add_control(
  'productcolumnproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Number of Product Columns on Desktop', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 0,
    'max' => 5,
    'step' => 1,
    'default' => 4,

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

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

  ]
); 
$this->add_control(
  'autoplayproductscarouseleighthstkaveh',
  [
    '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(
  'autoplaydelayproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Autoplay Delay (milliseconds)', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 1000,
    'max' => 10000,
    'step' => 500,
    'default' => 3000,
    'condition' => [
      'autoplayproductscarouseleighthstkaveh' => 'yes',
    ],
  ]
);
$this->add_control(
  'pauseonhoverproductscarouseleighthstkaveh',
  [
    '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' => [
      'autoplayproductscarouseleighthstkaveh' => 'yes',
    ],
  ]
);
$this->add_control(
  'loopproductscarouseleighthstkaveh',
  [
    '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(
  'speedproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Transition Speed (milliseconds)', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 300,
    'max' => 3000,
    'step' => 100,
    'default' => 300,
  ]
);
$this->add_control(
  'centeredslidesproductscarouseleighthstkaveh',
  [
    '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(
  'freemodeproductscarouseleighthstkaveh',
  [
    '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(
  'effectproductscarouseleighthstkaveh',
  [
    '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(
  'showdotsproductscarouseleighthstkaveh',
  [
    '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_productscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Title Styles', 'kavehTheme' ),
    'tab' => \Elementor\Controls_Manager::TAB_STYLE,
  ]
);
$this->add_control(
  'textcolor2productscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Main Title Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .title' => 'color: {{VALUE}}',
    ],
  ]
);
$this->add_control(
  'textcolor3productscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Bold Title Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .title span' => 'color: {{VALUE}}',
    ],
  ]
);
$this->add_group_control(
  \Elementor\Group_Control_Typography::get_type(),
  [
    'name' => 'titleproductscarouseleighthstkaveh',
    'label' => esc_html__( 'Main Title Typography', 'kavehTheme' ),
    'selector' => '{{WRAPPER}} .latest-products-book-heading .title',
  ]
);
$this->add_control(
  'textcolor22productscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Subtitle Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .sub-title' => 'color: {{VALUE}}',
    ],
  ]
);
$this->add_group_control(
  \Elementor\Group_Control_Typography::get_type(),
  [
    'name' => 'title2productscarouseleighthstkaveh',
    'label' => esc_html__( 'Subtitle Typography', 'kavehTheme' ),
    'selector' => '{{WRAPPER}} .latest-products-book-heading .sub-title',
  ]
);
$this->add_control(
  'iconcolor22productscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Icon Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading::before' => ' border-color: {{VALUE}} {{VALUE}} transparent transparent;',
    ],
  ]
);
$this->end_controls_section();
$this->start_controls_section(
  'styleb_productscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Button Style', 'kavehTheme' ),
    'tab' => \Elementor\Controls_Manager::TAB_STYLE,
    'condition' => [
      'showbutton1productscarouseleighthstkaveh' => 'yes',
    ],
  ]
);
$this->add_group_control(
  \Elementor\Group_Control_Typography::get_type(),
  [
    'name' => 'button_nchbproductscarouseleighthstkaveh',
    'label' => esc_html__( 'Button Text Typography', 'kavehTheme' ),
    'selector' => '{{WRAPPER}} .latest-products-book-heading .btn',
  ]
);
$this->add_control(
  'iconsizenchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Icon Size', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::SLIDER,
    'size_units' => [ 'px' ],
    'range' => [
      'px' => [
        'min' => 0,
        'max' => 200,
        'step' => 1,
      ],
    ],
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn i' => 'font-size: {{SIZE}}{{UNIT}};',
    ],
  ]
);
$this->add_group_control(
  \Elementor\Group_Control_Text_Shadow::get_type(),
  [
    'name' => 'text_shadownchbproductscarouseleighthstkaveh',
    'label' => esc_html__( 'Text Shadow', 'kavehTheme' ),
    'selector' => '{{WRAPPER}} .latest-products-book-heading .btn',
  ]
);
$this->start_controls_tabs(
  'style_tabsnchbproductscarouseleighthstkaveh'
);

$this->start_controls_tab(
  'style_normal_tabnchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Normal', 'kavehTheme' ),
  ]
);
$this->add_control(
  'textbuttoncolornchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Button Text Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn' => 'color: {{VALUE}}',
    ],
  ]
); 
$this->add_control(
  'iconcolornchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Icon Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn i' => 'color: {{VALUE}}',
    ],
  ]
); 
$this->add_control(
  'buttoncolornchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Button Background Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn' => 'background-color: {{VALUE}}',
    ],
  ]
); 
$this->add_control(
  'buttonradiusnchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Button Border Radius', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::DIMENSIONS,
    'size_units' => [ 'px' ],
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
    ],
  ]
);
$this->add_group_control(
  \Elementor\Group_Control_Border::get_type(),
  [
    'name' => 'bordernchbproductscarouseleighthstkaveh',
    'label' => esc_html__( 'Border', 'kavehTheme' ),
    'selector' => '{{WRAPPER}} .latest-products-book-heading .btn',
  ]
);
$this->add_control(
  'buttonbordersnchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Border Width', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::DIMENSIONS,
    'size_units' => [ 'px' ],
    'condition' => [
      'bordernchbproductscarouseleighthstkaveh!' => '',
    ],
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
    ],
  ]
);
$this->end_controls_tab();
$this->start_controls_tab(
  'style_hove_tabnchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Hover', 'kavehTheme' ),
  ]
);
$this->add_control(
  'textbuttoncolorhovernchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Button Text Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn:hover' => 'color: {{VALUE}}',
    ],
  ]
); 
$this->add_control(
  'iconcolorhovernchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Icon Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn:hover i' => 'color: {{VALUE}}',
    ],
  ]
); 
$this->add_control(
  'buttoncolorhovernchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Button Background Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn:hover' => 'background-color: {{VALUE}}',
    ],
  ]
); 
$this->add_control(
  'buttonradiushovernchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Button Border Radius', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::DIMENSIONS,
    'size_units' => [ 'px' ],
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
    ],
  ]
);
$this->add_group_control(
  \Elementor\Group_Control_Border::get_type(),
  [
    'name' => 'borderhovernchbproductscarouseleighthstkaveh',
    'label' => esc_html__( 'Border', 'kavehTheme' ),
    'selector' => '{{WRAPPER}} .latest-products-book-heading .btn:hover',
  ]
);
$this->add_control(
  'buttonbordershovernchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Border Width', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::DIMENSIONS,
    'size_units' => [ 'px' ],
    'condition' => [
      'borderhovernchbproductscarouseleighthstkaveh!' => '',
    ],
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn:hover' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
    ],
  ]
);
$this->end_controls_tab();
$this->end_controls_tabs();
$this->add_control(
  'hr1nchbproductscarouseleighthstkaveh',
  [
    'type' => \Elementor\Controls_Manager::DIVIDER,
  ]
);
$this->add_group_control(
  \Elementor\Group_Control_Box_Shadow::get_type(),
  [
    'name' => 'box_shadownchbproductscarouseleighthstkavehh',
    'label' => esc_html__( 'Button Shadow', 'kavehTheme' ),
    'selector' => '{{WRAPPER}} .latest-products-book-heading .btn',
  ]
);
$this->add_control(
  'buttonpaddingnchbproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Padding', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::DIMENSIONS,
    'size_units' => [ 'px' ],
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-heading .btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
    ],
  ]
);

$this->end_controls_section();
$this->start_controls_section(
  'style3_productscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Box Style', 'kavehTheme' ),
    'tab' => \Elementor\Controls_Manager::TAB_STYLE,
  ]
);
$this->add_control(
  'bgcolorproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Background Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-wrapper' => 'background-color: {{VALUE}}',
    ],
  ]
); 
$this->add_control(
  'boxradiusproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Box Border Radius', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::DIMENSIONS,
    'size_units' => [ 'px' ],
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
    ],
  ]
);
$this->add_control(
  'boxpaddingproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Box Padding', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::DIMENSIONS,
    'size_units' => [ 'px' ],
    'selectors' => [
      '{{WRAPPER}} .latest-products-book-wrapper' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
    ],
  ]
);
$this->add_control(
  'bgcoloriconproductscarouseleighthstkaveh',
  [
    'label' => esc_html__( 'Arrow Color', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::COLOR,
    'condition' => [
      'showarrowproductscarouseleighthstkaveh' => 'yes',
    ],
    'selectors' => [
      '{{WRAPPER}} .swiper-button-next::after' => 'color: {{VALUE}}',
      '{{WRAPPER}} .swiper-button-prev::after' => 'color: {{VALUE}}',

    ],
  ]
); 
$this->end_controls_section();
        }


  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id(); 
    ?>

    <section class="latest-products-book">
      <div class="container">
        <div class="latest-products-book-wrapper position-relative overflow-hidden">
          <!-- Start Heading -->
          <div
            class="latest-products-book-heading d-flex align-items-md-center position-relative flex-column flex-md-row gap-4 gap-md-0 flex-column">
            <div class="me-3">
              <<?php echo  esc_attr($settings['tagheadingproductscarouseleighthstkaveh']); ?> class="title">
              <?php echo esc_html($settings['titleproductscarouseleighthstkaveh']); ?>
                <span><?php echo esc_html($settings['title3productscarouseleighthstkaveh']); ?></span>
              </<?php echo  esc_attr($settings['tagheadingproductscarouseleighthstkaveh']); ?>>
              <<?php echo  esc_attr($settings['tag2headingproductscarouseleighthstkaveh']); ?> class="sub-title mb-0"><?php echo esc_html($settings['title2productscarouseleighthstkaveh']); ?> </<?php echo  esc_attr($settings['tag2headingproductscarouseleighthstkaveh']); ?>>
            </div>
            <div class="d-flex align-items-center ms-md-auto flex-row-reverse flex-md-row">
            <?php if("yes"===$settings['showarrowproductscarouseleighthstkaveh']){?>
              <div class="d-flex ms-3 ms-md-0 me-md-3">
                <div class="swiper-button-prev clsid<?php echo $clsid; ?> position-relative top-0 start-0 bottom-0 end-0 m-0 w-auto h-auto"></div>
                <div class="swiper-button-next clsid<?php echo $clsid; ?> position-relative top-0 start-0 bottom-0 end-0 m-0 w-auto h-auto ms-2">
                </div>
              </div>
              <?php } ?>
              <?php if("yes"===$settings['showbutton1productscarouseleighthstkaveh']){?>
              <a href="<?php echo esc_url($settings['linkbuttons2productscarouseleighthstkaveh']); ?>" class="btn btn-light-2 d-flex align-items-center text-nowrap justify-content-center">
                <i class="<?php echo esc_attr($settings['iconbutts2productscarouseleighthstkaveh']['value']); ?> me-1"></i>
                <?php echo esc_html($settings['buttons2productscarouseleighthstkaveh']); ?>
              </a>
              <?php } ?>
            </div>
          </div>
          <!-- End Heading -->
          <!-- Start Carousel -->
          <div class="swiper swiper-products-two swiper-visible" data-swiper='<?php echo json_encode([
            "loop" => $settings['loopproductscarouseleighthstkaveh'] === "yes",
            "autoplay" => $settings['autoplayproductscarouseleighthstkaveh'] === "yes" ? [
              "delay" => intval($settings['autoplaydelayproductscarouseleighthstkaveh']),
              "pauseOnMouseEnter" => $settings['pauseonhoverproductscarouseleighthstkaveh'] === "yes"
            ] : false,
            "speed" => intval($settings['speedproductscarouseleighthstkaveh']),
            "centeredSlides" => $settings['centeredslidesproductscarouseleighthstkaveh'] === "yes",
            "freeMode" => $settings['freemodeproductscarouseleighthstkaveh'] === "yes",
            "navigation" => $settings['showarrowproductscarouseleighthstkaveh'] === "yes" ? [
              "prevEl" => ".swiper-button-prev.clsid$clsid",
              "nextEl" => ".swiper-button-next.clsid$clsid"
            ] : false,
            "pagination" => $settings['showdotsproductscarouseleighthstkaveh'] === "yes" ? [
              "el" => ".swiper-pagination.clsid$clsid",
              "clickable" => true
            ] : false,
            "breakpoints" => [
              300 => ["slidesPerView" => intval($settings['productcolumn3productscarouseleighthstkaveh']), "spaceBetween" => 12],
              768 => ["slidesPerView" => intval($settings['productcolumn2productscarouseleighthstkaveh']), "spaceBetween" => 12],
              992 => ["slidesPerView" => intval($settings['productcolumnproductscarouseleighthstkaveh']), "spaceBetween" => 16],
              1200 => ["slidesPerView" => intval($settings['productcolumnproductscarouseleighthstkaveh']), "spaceBetween" => 24],
            ]
          ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>'>
          <div class="swiper-wrapper">
            <?php if('cat'===$settings['pproductscarouseleighthstkaveh']){ ?>

                  <?php
                // Define your custom query arguments
                $query_args = array(
                  'post_type' => array('product'),
                  'post_status' => array('publish'),
                  'posts_per_page' => $settings['productnumberproductscarouseleighthstkaveh'],
                  'orderby' => $settings['psortproductscarouseleighthstkaveh'] === 'date' ? 'date' : 'meta_value_num', // Default to date or meta value
                  'order' => $settings['psortiproductscarouseleighthstkaveh'],
                  'tax_query' => array(
                    'relation' => 'AND',
                    array(
                      'taxonomy' => 'product_cat',
                      'field' => 'term_id',
                      'terms' => $settings['catproductscarouseleighthstkaveh'],
                    ),
                  ),
                );
                // Handle specific orderby values
                switch ($settings['psortproductscarouseleighthstkaveh']) {
                  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['stylecartproductscarouseleighthstkaveh']; ?>
                      <?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['pproductscarouseleighthstkaveh']){
                ?>
                <?php
                // Define your custom query arguments
                $query_args = array(
                  'post_type' => array('product'),
                  'post_status' => array('publish'),
                  'posts_per_page' => $settings['productnumberproductscarouseleighthstkaveh'],
                  'orderby' => $settings['psortproductscarouseleighthstkaveh'] === 'date' ? 'date' : 'meta_value_num', // Default to date or meta value
                  'order' => $settings['psortiproductscarouseleighthstkaveh'],
                  'tax_query' => array(
                    'relation' => 'AND',
                  ),
                );
                // Handle specific orderby values
                switch ($settings['psortproductscarouseleighthstkaveh']) {
                  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['stylecartproductscarouseleighthstkaveh']; ?>
                      <?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($settings['showdotsproductscarouseleighthstkaveh'] === 'yes'){ ?>
              <div class="swiper-pagination clsid<?php echo $clsid; ?>"></div>
            <?php } ?>
          </div>
          <!-- End Carousel -->
        </div>
      </div>
    </section>
    
    <?php
  }


}
