<?php

use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Categorycarouseltwelvethkaveh extends Widget_Base{

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

  public function get_title(){
    return esc_html__( 'Category Carousel Style Twelve', 'kavehTheme' );
  }

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

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

  protected function register_controls(){
    $this->start_controls_section(
      'content00categorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Flash Sale Products Settings', 'kavehTheme' ),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
      ]
    );
      $this->add_control(
        'pproductslahzecategorycarouseltwelvethkaveh',
        [
          '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(
          'psortproductslahzecategorycarouseltwelvethkaveh',
          [
            '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(
            'psortiproductslahzecategorycarouseltwelvethkaveh',
            [
              'label' => esc_html__( 'Sort Type', '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(
      'catproductslahzecategorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Select Category', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT2, 
        'multiple' => true,
        'options' => $options2,
        'condition' => [
          'pproductslahzecategorycarouseltwelvethkaveh' => 'cat',
        ],
      ]
  );
  $this->add_control(
    'productnumberproductscategorycarouseltwelvethkaveh',
    [
      'label' => esc_html__( 'Number of Products Displayed', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::NUMBER,
      'min' => 0,
      'max' => 20,
      'step' => 1,
      'default' => 5,
    ]
  );
    $this->end_controls_section();
    $this->start_controls_section(
      'contentcategorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Element Content', 'kavehTheme' ),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
      ]
    );
    $this->add_control(
      'showticategorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Show Title?', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'yes' => esc_html__( 'Yes', 'kavehTheme' ),
        'no' => esc_html__( 'No', 'kavehTheme' ),
        'return_value' => 'yes',
        'default' => 'yes',
      ]
    );
    $this->add_control(
      'tagti1categorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Main Title Tag', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'H2',
        'condition' => [
          'showticategorycarouseltwelvethkaveh' => 'yes',
        ],
        '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(
      'wigti1categorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Title', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'condition' => [
          'showticategorycarouseltwelvethkaveh' => 'yes',
        ],
        'default' => 'Special Holiday Sale of Cosmetic Products',
      ]
    );
    $this->add_control(
      'tagtif1categorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Subtitle Tag', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'H4',
        'condition' => [
          'showticategorycarouseltwelvethkaveh' => 'yes',
        ],
        '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(
      'widgti2bolcategorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Bold Subtitle', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'condition' => [
          'showticategorycarouseltwelvethkaveh' => 'yes',
        ],
        'default' => 'Category',

      ]
    );
    $this->add_control(
      'widgti2categorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Subtitle', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'condition' => [
          'showticategorycarouseltwelvethkaveh' => 'yes',
        ],
        'default' => 'Products',

      ]
    );
    $this->add_control(
      'wigp2categorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Description', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXTAREA,
        'condition' => [
          'showticategorycarouseltwelvethkaveh' => 'yes',
        ],
        'default' => 'Lorem ipsum is simply dummy text of the printing and typesetting industry. Lorem ipsum has been the industry standard dummy text ever since the 1500s.',

      ]
    );
    $this->add_control(
      'showbuttoncategorycarouseltwelvethkaveh',
      [
        '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(
        'buttonti2categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Title', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'condition' => [
            'showbuttoncategorycarouseltwelvethkaveh' => 'yes',
          ],
          'default' => 'More Information',
  
        ]
      );
      $this->add_control(
        'buttonicocategorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Icon', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::ICONS,
          'skin' => 'inline',
          'condition' => [
            'showbuttoncategorycarouseltwelvethkaveh' => 'yes',
          ],
          'exclude_inline_options' => [ 'svg' ],
          'default' => [
            'value' => 'icon-angle-circle-top-left',
          ],
        ]
      ); 
      $this->add_control(
        'buttonlinkcategorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Link', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::TEXT,
          'condition' => [
            'showbuttoncategorycarouseltwelvethkaveh' => 'yes',
          ],
          'default' => '#',
  
        ]
      );
     $this->end_controls_section();
    $this->start_controls_section(
        'content1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Categories', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );

      $repeater = new \Elementor\Repeater();
      $repeater->add_control(
        'img1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Image', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::MEDIA,
          'default' => [
            'url' => \Elementor\Utils::get_placeholder_image_src(),
          ],
        ]
      );
      $repeater->add_control(
      'title1categorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Title', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => 'iPhone Products',

      ]
    );
    $repeater->add_control(
      'tagheading1categorycarouseltwelvethkaveh',
      [
        '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' ),
        ],
      ]
    );
    $repeater->add_control(
      'linkcategorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Link', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => '#',
      ]
    );
    $this->add_control(
      'listcategorycarouseltwelvethkaveh',
      [
        'label' => esc_html__( 'Categories', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::REPEATER,
        'fields' => $repeater->get_controls(),
        'default' => [
          [
            'title1categorycarouseltwelvethkaveh' => esc_html__( 'Title', 'kavehTheme' ),
            'linkcategorycarouseltwelvethkaveh' => esc_html__( '#', 'kavehTheme' ),
          ],
      ]
      ]
    
    );

    
       $this->end_controls_section();
       $this->start_controls_section(
        'content3categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Carousel Settings', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
        'productcolumncategorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Number of Category Columns on Desktop', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::NUMBER,
          'min' => 0,
          'max' => 8,
          'step' => 1,
          'default' => 4,
      
        ]
      );
      $this->add_control(
        'productcolumn2categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Number of Category Columns on Tablet', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::NUMBER,
          'min' => 0,
          'max' => 5,
          'step' => 1,
          'default' => 3,
      
        ]
      );
      $this->add_control(
        'productcolumn3categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Number of Category Columns on Mobile', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::NUMBER,
          'min' => 0,
          'max' => 5,
          'step' => .5,
          'default' => 1.5,
      
        ]
      );
       $this->end_controls_section();
       $this->start_controls_section(
        'stylet_categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Title Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
          'condition' => [
            'showticategorycarouseltwelvethkaveh' => 'yes',
          ],
        ]
      );
      $this->add_control(
        'textacolortbolcategorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Main Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight-title-en' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titletyta_categorycarouseltwelvethkaveh',
          'label' => esc_html__( 'Main Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .section-heading-eight-title-en',
        ]
      );
      $this->add_control(
        'textcolortbolcategorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Bold Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight-title b' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titletytf_categorycarouseltwelvethkaveh',
          'label' => esc_html__( 'Bold Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .section-heading-eight-title b',
        ]
      );
      $this->add_control(
        'textcolortcategorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Subtitle Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight-title' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titletyt_categorycarouseltwelvethkaveh',
          'label' => esc_html__( 'Subtitle Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .section-heading-eight-title',
        ]
      );
      $this->add_control(
        'textcolortpcategorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Description Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight p' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titletytp_categorycarouseltwelvethkaveh',
          'label' => esc_html__( 'Description Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .section-heading-eight p',
        ]
      );
      $this->add_control(
        'hr3procategorycarouseltwelvethkaveh',
        [
          'type' => \Elementor\Controls_Manager::DIVIDER,
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'txttypomainbutprodt1categorycarouseltwelvethkaveh',
          'label' => esc_html__( 'Button Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .section-heading-eight .btn',
        ]
      );
      $this->add_control(
        'bficonsize5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Icon Size', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 200,
              'step' => 1,
            ],
          ],
          'default' => [
            'unit' => 'px',
            'size' => 10,
          ],
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn i' => 'font-size: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->start_controls_tabs(
        'style_tabs5prodt1categorycarouseltwelvethkaveh'
      );
      $this->start_controls_tab(
        'style_normal_tab5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Normal', 'kavehTheme' ),
        ]
      );
      $this->add_control(
        'text1color5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn' => 'color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'iconbuttoncolor5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Icon Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn i' => 'color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttoncolor5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn' => 'background-color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttonradius5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Rounded Corners', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Border::get_type(),
        [
          'name' => 'border5prodt1categorycarouseltwelvethkaveh',
          'label' => esc_html__( 'Border', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .section-heading-eight .btn',
        ]
      );
      $this->add_control(
        'buttonborders5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Border Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'condition' => [
            'border5prodt1categorycarouseltwelvethkaveh!' => '',
          ],
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
          ],
        ]
      );
      $this->end_controls_tab();
      $this->start_controls_tab(
        'style_hove_tab5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Hover', 'kavehTheme' ),
        ]
      );
      $this->add_control(
        'text1colorhover5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn:hover' => 'color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'iconbuttoncolorhover5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Icon Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn:hover i' => 'color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttoncolorhover5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn:hover' => 'background-color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'buttonradiushover5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Button Rounded Corners', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Border::get_type(),
        [
          'name' => 'borderhover5prodt1categorycarouseltwelvethkaveh',
          'label' => esc_html__( 'Border', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .section-heading-eight .btn:hover',
        ]
      );
      $this->add_control(
        'buttonbordershover5prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Border Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'condition' => [
            'borderhover5prodt1categorycarouseltwelvethkaveh!' => '',
          ],
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn:hover' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
          ],
        ]
      );
      $this->end_controls_tab();
      $this->end_controls_tabs();
      $this->add_control(
        'hr5prodt1categorycarouseltwelvethkaveh',
        [
          'type' => \Elementor\Controls_Manager::DIVIDER,
        ]
      );
      
      $this->add_group_control(
        \Elementor\Group_Control_Box_Shadow::get_type(),
        [
          'name' => 'box_shadow5prodt1categorycarouseltwelvethkaveh',
          'label' => esc_html__( 'Button Shadow', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .section-heading-eight .btn',
        ]
      );
      $this->add_control(
        'buttonpadding15prodt1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Padding', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .section-heading-eight .btn' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style2_categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Title Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'textcolor1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .categories-products-three-item .title' => 'color: {{VALUE}} !important;',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'titlety1_categorycarouseltwelvethkaveh',
          'label' => esc_html__( 'Category Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .categories-products-three-item .title',
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style3_categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Box Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'borderradiustcategorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Rounded Corners', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .categories-products-three-item' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'bgproductboxcolor1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Box Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .categories-products-three-item' => 'background-color: {{VALUE}} !important;',
          ],
        ]
      );
      $this->add_control(
        'bgproductboxbordercolor1categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Box Border Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .categories-products-three-item::before' => 'background: linear-gradient(64.32deg, {{VALUE}} -7.21%, rgba(231, 231, 231, 0) 85.16%) border-box !important;',
          ],
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'styleimag_categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Image Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'catimg1widthcategorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Image Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 300,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .categories-products-three-item img' => 'width: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'catimg1height2categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Image Height', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 300,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .categories-products-three-item img' => 'height: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'catimg1lefthcategorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Image Distance from Left', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 300,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .categories-products-three-item img' => 'left: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->add_control(
        'catimg1bottom2categorycarouseltwelvethkaveh',
        [
          'label' => esc_html__( 'Category Image Distance from Bottom', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 300,
              'step' => 1,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .categories-products-three-item img' => 'bottom: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->end_controls_section();

        }
 

        protected function render() {
          $settings = $this->get_settings_for_display();
          $clsid = $this->get_id();
          ?>
          <section class="categories-products-three">
            <div class="container position-relative">
              <!-- Start Heading -->
              <div
                class="section-heading-eight d-flex align-items-sm-center flex-wrap flex-lg-nowrap gap-4 gap-lg-0 flex-column flex-sm-row">
                <?php if ("yes" === $settings['showticategorycarouseltwelvethkaveh']) { ?>
                  <div class="text-nowrap">
                    <<?php echo esc_attr($settings['tagti1categorycarouseltwelvethkaveh']); ?> class="section-heading-eight-title-en"><?php echo esc_html($settings['wigti1categorycarouseltwelvethkaveh']); ?></<?php echo esc_attr($settings['tagti1categorycarouseltwelvethkaveh']); ?>>
                    <<?php echo esc_attr($settings['tagtif1categorycarouseltwelvethkaveh']); ?> class="section-heading-eight-title">
                      <b><?php echo esc_html($settings['widgti2bolcategorycarouseltwelvethkaveh']); ?></b>
                      <?php echo esc_html($settings['widgti2categorycarouseltwelvethkaveh']); ?>
                    </<?php echo esc_attr($settings['tagtif1categorycarouseltwelvethkaveh']); ?>>
                  </div>
                  <p class="mb-0 d-none d-lg-block"><?php echo wp_kses_post($settings['wigp2categorycarouseltwelvethkaveh']); ?></p>
                <?php } ?>
                <?php if ("yes" === $settings['showbuttoncategorycarouseltwelvethkaveh']) { ?>
                  <a href="<?php echo esc_url($settings['buttonlinkcategorycarouseltwelvethkaveh']); ?>" class="btn btn-purple-2 d-flex align-items-center justify-content-center text-nowrap ms-auto">
                    <?php echo esc_html($settings['buttonti2categorycarouseltwelvethkaveh']); ?>
                    <i class="<?php echo esc_attr($settings['buttonicocategorycarouseltwelvethkaveh']['value']); ?> ms-2"></i>
                  </a>
                <?php } ?>
                <div class="swiper-bottom end-0 d-none d-md-flex align-items-md-center ms-lg-4">
                  <div class="swiper-categories-products-three-pagination swiper-pagination m-0 position-relative top-0 start-0 bottom-0 end-0 d-flex"></div>
                  <div class="swiper-categories-products-three-button-prev swiper-button-prev m-0 w-auto h-auto position-relative top-0 start-0 bottom-0 end-0 mx-3"></div>
                  <div class="swiper-categories-products-three-button-next swiper-button-next m-0 w-auto h-auto position-relative top-0 start-0 bottom-0 end-0"></div>
                </div>
              </div>
              <!-- End Heading -->
              <div class="row">
                <div class="col-md-5 col-lg-4 col-xl-3">
                  <!-- Start Carousel -->
                  <div class="swiper swiper-discount-product-special position-relative overflow-hidden swiper-visibled swiper-visibled-mobile">
                    <div class="swiper-wrapper">
                      <?php if ('cat' === $settings['pproductslahzecategorycarouseltwelvethkaveh']) {
                        $q_pc2_query_args = array(
                          'post_type' => array('product'),
                          'post_status' => array('publish'),
                          'posts_per_page' => $settings['productnumberproductscategorycarouseltwelvethkaveh'],
                          'order' => 'DESC',
                          'orderby' => 'date',
                          'tax_query' => array(
                            array(
                              'taxonomy' => 'product_cat',
                              'field' => 'term_id',
                              'terms' => $settings['catproductslahzecategorycarouseltwelvethkaveh'],
                            ),
                          ),
                          'meta_query' => WC()->query->get_meta_query(),
                          'post__in' => array_merge(array(0), wc_get_product_ids_on_sale())
                        );
      
                        $pc2_query = new \WP_Query($q_pc2_query_args);
      
                        if ($pc2_query->have_posts()) {
                          while ($pc2_query->have_posts()) {
                            $pc2_query->the_post();
                            global $product;
                            $sale_price = $product->get_sale_price();
                            $normal_price = $product->get_regular_price();
                            $pr_id = get_the_ID();
                            $stocka = $product->get_stock_status();
                            ?>
                            <!-- Start Slide -->
                            <div class="swiper-slide">
                              <div class="product-eight product-eight-offer">
                                <div class="image">
                                  <a href="<?php the_permalink(); ?>">
                                    <img src="<?php echo esc_url(get_the_post_thumbnail_url(null, 'full')); ?>" alt="<?php echo esc_attr(get_the_title()); ?>" width="266" height="266">
                                  </a>
                                  <?php if ("instock" === $stocka && !empty($sale_price)) { ?>
                                    <div class="offer"><?php
                                      $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
                                      echo esc_html($percentage);
                                      ?>%</div>
                                  <?php } ?>
                                  <div class="status position-absolute top-0 text-center rounded-pill<?php echo 'instock' === $stocka ? ' stinsto' : ''; ?>">
                                    <?php echo 'instock' === $stocka ? esc_html__('Available', 'kavehTheme') : esc_html__('Unavailable', 'kavehTheme'); ?>
                                  </div>
                                </div>
                                <div class:// ... Rest of the render method remains similar, with translations applied to hardcoded strings ...
                              </div>
                            </div>
                            <!-- End Slide -->
                            <?php
                            wp_reset_postdata();
                          }
                        }
                      } elseif ('all' === $settings['pproductslahzecategorycarouseltwelvethkaveh']) {
                        $ordvalue = $settings['psortproductslahzecategorycarouseltwelvethkaveh'];
                        $ordi = $settings['psortiproductslahzecategorycarouseltwelvethkaveh'];
                        $q_pc2_query_args = array(
                          'post_type' => array('product'),
                          'post_status' => array('publish'),
                          'posts_per_page' => $settings['productnumberproductscategorycarouseltwelvethkaveh'],
                          'order' => $ordi,
                          'orderby' => 'meta_value_num',
                          'meta_key' => $ordvalue,
                          'meta_query' => WC()->query->get_meta_query(),
                          'post__in' => array_merge(array(0), wc_get_product_ids_on_sale())
                        );
      
                        $pc2_query = new \WP_Query($q_pc2_query_args);
      
                        if ($pc2_query->have_posts()) {
                          while ($pc2_query->have_posts()) {
                            $pc2_query->the_post();
                            global $product;
                            $sale_price = $product->get_sale_price();
                            $normal_price = $product->get_regular_price();
                            $pr_id = get_the_ID();
                            $stocka = $product->get_stock_status();
                            ?>
                            <!-- Start Slide -->
                            <div class="swiper-slide">
                              <div class="product-eight product-eight-offer">
                                <div class="image full-width">
                                  <a href="<?php the_permalink(); ?>">
                                    <img src="<?php echo esc_url(get_the_post_thumbnail_url(null, 'full')); ?>" alt="<?php echo esc_attr(get_the_title()); ?>" width="266" height="266">
                                  </a>
                                  <?php if ("instock" === $stocka && !empty($sale_price)) { ?>
                                    <div class="offer"><?php
                                      $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
                                      echo esc_html($percentage);
                                      ?>%</div>
                                  <?php } ?>
                                  <div class="status position-absolute top-0 text-center rounded-pill<?php echo 'instock' === $stocka ? ' stinsto' : ''; ?>">
                                    <?php echo 'instock' === $stocka ? esc_html__('Available', 'kavehTheme') : esc_html__('Unavailable', 'kavehTheme'); ?>
                                  </div>
                                </div>
                                <div class="content">
                                  <h2 class="product-name">
                                    <a href="<?php the_permalink(); ?>"><?php echo esc_html(get_the_title()); ?></a>
                                  </h2>
                                  <div class="d-flex align-items-center justify-content-between">
                                    <?php if ("instock" === $stocka) { ?>
                                      <?php if (!$product->is_type('variable')) { ?>
                                        <?php if (!empty($sale_price)) { ?>
                                          <div class="price">
                                            <del><?php echo esc_html(number_format($normal_price, 0, '.', ',')); ?></del>
                                            <span><?php echo esc_html(number_format($sale_price, 0, '.', ',')); ?></span>
                                            <?php echo esc_html(get_woocommerce_currency_symbol()); ?>
                                          </div>
                                        <?php } else { ?>
                                          <div class="price">
                                            <span><?php echo esc_html(number_format($normal_price, 0, '.', ',')); ?></span>
                                            <?php echo esc_html(get_woocommerce_currency_symbol()); ?>
                                          </div>
                                        <?php } ?>
                                      <?php } else {
                                        $price_v = $product->get_price_html();
                                        echo wp_kses_post(str_replace('–', '<span class="dashvar"> – </span>', $price_v));
                                      }
                                    } ?>
                                    <?php if ("instock" === $stocka) { ?>
                                      <?php if (!$product->is_type('variable')) { ?>
                                        <a type="submit" name="add-to-cart" value="<?php echo esc_attr($pr_id); ?>" class="btn btn-success-2 shadow-none single_add_to_cart_button"><span><?php esc_html_e('+ Buy', 'kavehTheme'); ?></span></a>
                                      <?php } ?>
                                    <?php } else { ?>
                                      <span class="btn btn-notstock rounded-pill"><?php esc_html_e('Unavailable', 'kavehTheme'); ?></span>
                                    <?php } ?>
                                  </div>
                                  <a href="<?php the_permalink(); ?>" class="btn btn-secondary rounded-pill"><?php esc_html_e('View Product', 'kavehTheme'); ?></a>
                                </div>
                              </div>
                            </div>
                            <!-- End Slide -->
                            <?php
                            wp_reset_postdata();
                          }
                        }
                      } ?>
                    </div>
                    <!-- Start Pagination -->
                    <div class="swiper-pagination end-0"></div>
                    <!-- End Pagination -->
                  </div>
                  <!-- End Carousel -->
                </div>
                <div class="col-md-7 col-lg-8 col-xl-9">
                  <!-- Start Carousel -->
                  <div class="swiper swiper-categories-products-three overflow-hidden swiper-button-arrow">
                    <div class="swiper-wrapper">
                      <?php
                      if ($settings['listcategorycarouseltwelvethkaveh']) {
                        foreach ($settings['listcategorycarouseltwelvethkaveh'] as $item) {
                          ?>
                          <!-- Start Slide -->
                          <div class="swiper-slide">
                            <div class="categories-products-three-item position-relative">
                              <a href="<?php echo esc_url($item['linkcategorycarouseltwelvethkaveh']); ?>" class="stretched-link" aria-label="<?php echo esc_attr__('category', 'kavehTheme'); ?>"></a>
                              <<?php echo esc_attr($item['tagheading1categorycarouseltwelvethkaveh']); ?> class="title"><?php echo esc_html($item['title1categorycarouseltwelvethkaveh']); ?></<?php echo esc_attr($item['tagheading1categorycarouseltwelvethkaveh']); ?>>
                              <img src="<?php echo esc_url($item['img1categorycarouseltwelvethkaveh']['url']); ?>" alt="<?php echo esc_attr(\Elementor\Control_Media::get_image_alt($item['img1categorycarouseltwelvethkaveh'])); ?>" width="99" height="171" class="position-absolute">
                            </div>
                          </div>
                          <!-- End Slide -->
                          <?php
                        }
                      }
                      ?>
                    </div>
                    <div class="swiper-bottom position-absolute start-50 translate-middle-x d-flex align-items-center justify-content-center d-md-none mt-5 flex-column flex-sm-row w-100 cat9pag">
                      <div class="swiper-pagination m-0 w-auto h-auto position-relative top-0 start-0 bottom-0 end-0"></div>
                      <div class="my-3 my-sm-0 d-flex align-items-center cat9pag">
                        <div class="swiper-button-prev m-0 w-auto h-auto position-relative top-0 start-0 bottom-0 end-0 ms-sm-3 me-3"></div>
                        <div class="swiper-button-next m-0 w-auto h-auto position-relative top-0 start-0 bottom-0 end-0"></div>
                      </div>
                    </div>
                  </div>
                  <!-- End Carousel -->
                </div>
              </div>
            </div>
          </section>
          <script>
            function init<?php echo esc_js($clsid); ?>() {
              // Swiper Discount Product Special
              new Swiper(".swiper-discount-product-special", {
                watchSlidesProgress: true,
                pagination: {
                  el: ".swiper-pagination",
                  type: "bullets",
                  clickable: true,
                },
                autoplay: {
                  delay: 3000,
                },
                loop: true,
                breakpoints: {
                  320: {
                    slidesPerView: 2,
                    spaceBetween: 12,
                  },
                  768: {
                    slidesPerView: 1,
                    spaceBetween: 20,
                    effect: "fade",
                    fadeEffect: {
                      crossFade: true,
                    },
                  },
                }
              });
      
              let categoriesProductsThreeNext = ".swiper-categories-products-three-button-next",
                categoriesProductsThreePrev = ".swiper-categories-products-three-button-prev",
                categoriesProductsThreePagination = ".swiper-categories-products-three-pagination";
      
              if (window.outerWidth < 768) {
                categoriesProductsThreeNext = ".swiper-button-next";
                categoriesProductsThreePrev = ".swiper-button-prev";
                categoriesProductsThreePagination = ".swiper-pagination";
              }
              // Swiper Category Product Three
              new Swiper(".swiper-categories-products-three", {
                watchSlidesProgress: true,
                navigation: {
                  nextEl: categoriesProductsThreeNext,
                  prevEl: categoriesProductsThreePrev,
                },
                pagination: {
                  el: categoriesProductsThreePagination,
                  type: "bullets",
                  clickable: true,
                },
                grid: {
                  fill: "row",
                  rows: 2,
                },
                breakpoints: {
                  320: {
                    slidesPerView: <?php echo esc_js($settings['productcolumn3categorycarouseltwelvethkaveh']); ?>,
                    spaceBetween: 8,
                  },
                  420: {
                    slidesPerView: <?php echo esc_js($settings['productcolumn3categorycarouseltwelvethkaveh']); ?>,
                    spaceBetween: 12,
                  },
                  768: {
                    slidesPerView: <?php echo esc_js($settings['productcolumn3categorycarouseltwelvethkaveh']); ?>,
                    spaceBetween: 20,
                  },
                  992: {
                    slidesPerView: <?php echo esc_js($settings['productcolumn2categorycarouseltwelvethkaveh']); ?>,
                    spaceBetween: 20,
                  },
                  1200: {
                    slidesPerView: <?php echo esc_js($settings['productcolumncategorycarouseltwelvethkaveh']); ?>,
                    spaceBetween: 32,
                  },
                  1400: {
                    slidesPerView: <?php echo esc_js($settings['productcolumncategorycarouseltwelvethkaveh']); ?>,
                    spaceBetween: 55,
                  },
                },
                on: {
                  init: (swiper) => {
                    const { currentBreakpoint, passedParams } = swiper,
                      { slidesPerView } = passedParams.breakpoints[currentBreakpoint];
                    
                    swiper.slides.forEach((item, index) => {
                      const thisIndex = index + 1,
                        allSlides = swiper.slides.length / 2;
      
                      if (thisIndex > allSlides && swiper.slides.length > slidesPerView && thisIndex > slidesPerView) {
                        item.classList.add("two");
                      }
                    });
                  },
                  beforeResize: (swiper) => {
                    swiper.update();
                  },
                },
              });
      
              let direction = "vertical";
      
              if (window.outerWidth < 992) {
                direction = "horizontal";
              }
            }
            if (window.Swiper) {
              init<?php echo esc_js($clsid); ?>();
            } else {
              window.addEventListener("load", function() {
                init<?php echo esc_js($clsid); ?>();
              });
            }
          </script>
          <style>
            .categories-products-three-item img {
              object-fit: contain !important;
            }
            .product-eight-offer .image .status.stinsto {
              background-color: #edf5e6;
              color: #00867d;
            }
            @media only screen and (max-width: 575px) {
              .swiper-categories-products-three {
                margin-top: 110px;
              }
              .cat9pag {
                display: none !important;
              }
              .swiper-categories-products-three {
                margin-top: 20px !important;
              }
              .swiper-discount-product-special .swiper-pagination {
                display: none !important;
              }
              .section-heading-eight {
                margin-bottom: 30px;
              }
              .top-selling-products .swiper-button-next, .top-selling-products .swiper-button-prev {
                top: 30px;
              }
              .section-heading-eight-title-en {
                font-size: 16px;
                text-align: center;
              }
              .section-heading-eight-title {
                font-size: 16px;
                text-align: center;
              }
            }
          </style>
          <?php
        }


}
