<?php
use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Productscarouselfifthstkaveh extends Widget_Base{

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

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

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

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

  protected function register_controls(){
    
    $this->start_controls_section(
        'contentproductscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Element Title', 'kavehTheme' ),
                  'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
        ]
      );
      $this->add_control(
          'titleproductscarouselfifthstkaveh',
          [
              'label' => esc_html__( 'Subtitle', 'kavehTheme' ),
              'type' => \Elementor\Controls_Manager::TEXT,
              'default' => esc_html__( 'Special Sale', 'kavehTheme' ),
      
          ]
      );
      $this->add_control(
        'title2productscarouselfifthstkaveh',
        [
            'label' => esc_html__( 'Main Title', 'kavehTheme' ),
            'type' => \Elementor\Controls_Manager::TEXT,
            'default' => esc_html__( 'Bodybuilding Supplements', 'kavehTheme' ),
    
        ]
    );
    $this->add_control(
      'tagheadingproductscarouselfifthstkaveh',
      [
        'label' => esc_html__( 'Title 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->end_controls_section();   
    $this->start_controls_section(
      'content2productscarouselfifthstkaveh',
      [
        'label' => esc_html__( 'Images', 'kavehTheme' ),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
      ]
    );
    $this->add_control(
      'imgproductscarouselfifthstkaveh',
      [
        'label' => esc_html__( 'Select Your Image', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::MEDIA,
        'selectors' => [
          '{{WRAPPER}} .buy-vip-right::after' =>
              'background: url({{URL}}) 0 0 no-repeat',
      ],
      ]
    );
    
    $this->add_control(
      'imgbgproductscarouselfifthstkaveh',
      [
        'label' => esc_html__( 'Background Image', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::MEDIA,
        'selectors' => [
          '{{WRAPPER}} .buy-vip-right' =>
              'background: url({{URL}}) 0 0 no-repeat',
      ],
      ]
    );
    
    $this->end_controls_section();   
    $this->start_controls_section(
      'content3productscarouselfifthstkaveh',
      [
        'label' => esc_html__( 'Timer', 'kavehTheme' ),
                'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
      ]
    );
      $this->add_control(
        'showtimercarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Show Timer?', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SWITCHER,
        'yes' => esc_html__( 'Yes', 'kavehTheme' ),
        'no' => esc_html__( 'No', 'kavehTheme' ),
          'return_value' => 'yes',
          'default' => 'yes',
        ]
      );
      $this->add_control(
        'datecarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Group Discount Time?', 'plugin-name' ),
          'type' => \Elementor\Controls_Manager::DATE_TIME,
          'condition' => [
            'showtimercarouselfifthstkaveh' => 'yes',
          ],
        ]
      );
      $this->end_controls_section();   
      $this->start_controls_section(
        'content4productscarouselfifthstkaveh',
        [
          '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(
    'pproductscarouselfifthstkaveh',
    [
      '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(
      'psortproductscarouselfifthstkaveh',
      [
        '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(
        'psortiproductscarouselfifthstkaveh',
        [
          '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(
    'stylecartproductscarouselfifthstkaveh',
    [
      'label' => esc_html__( 'Product Box Layout', 'kavehTheme' ),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'one',
        'options' => [
          'one'  => esc_html__( 'Layout One', 'kavehTheme' ),
          'two'  => esc_html__( 'Layout Two', 'kavehTheme' ),
          'three'  => esc_html__( 'Layout Three', 'kavehTheme' ),
          'four'  => esc_html__( 'Layout Four', 'kavehTheme' ),
          'five'  => esc_html__( 'Layout Five', 'kavehTheme' ),
          'six'  => esc_html__( 'Layout Six', 'kavehTheme' ),
          'seven'  => esc_html__( 'Layout Seven', 'kavehTheme' ),
          'eight'  => esc_html__( 'Layout Eight', 'kavehTheme' ),
          'nine'  => esc_html__( 'Layout Nine', 'kavehTheme' ),
          'ten'  => esc_html__( 'Layout Ten', 'kavehTheme' ),
          'eleven'  => esc_html__( 'Layout Eleven', 'kavehTheme' ),
          'twelve'  => esc_html__( 'Layout Twelve', 'kavehTheme' ),
          'thirteen'  => esc_html__( 'Layout Thirteen', 'kavehTheme' ),
          'fourteen'  => esc_html__( 'Layout Fourteen', 'kavehTheme' ),
          'fifteen'  => esc_html__( 'Layout Fifteen', 'kavehTheme' ),
          'sixteen'  => esc_html__( 'Layout Sixteen', 'kavehTheme' ),
          'seventeen'  => esc_html__( 'Layout Seventeen', 'kavehTheme' ),
          'eighteen'  => esc_html__( 'Layout Eighteen', 'kavehTheme' ),
          'nineteen'  => esc_html__( 'Layout Nineteen', 'kavehTheme' ),
          'twenty'  => esc_html__( 'Layout Twenty', 'kavehTheme' ),
          'twenty-one'  => esc_html__( 'Layout Twenty-One', '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(
    'catproductscarouselfifthstkaveh',
    [
      'label' => esc_html__( 'Select Category', 'kavehTheme' ),
      'type' => \Elementor\Controls_Manager::SELECT2, 
      'multiple' => true,
      'options' => $options5,
      'condition' => [
        'pproductscarouselfifthstkaveh' => 'cat',
      ],
    ]
);
$this->end_controls_section();   
$this->start_controls_section(
  'content5productscarouselfifthstkaveh',
  [
    'label' => esc_html__( 'Carousel Settings', 'kavehTheme' ),
            'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
  ]
);
$this->add_control(
  'showarrowsproductscarouselfifthstkaveh',
  [
    '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(
  'productnumberproductscarouselfifthstkaveh',
  [
    'label' => esc_html__( 'Number of Products Displayed', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 0,
    'max' => 50,
    'step' => 1,
    'default' => 5,
  ]
);
$this->add_control(
  'productcolumnproductscarouselfifthstkaveh',
  [
    'label' => esc_html__( 'Number of Product Columns on Desktop', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 0,
    'max' => 5,
    'step' => 0.5,
    'default' => 3,

  ]
); 
$this->add_control(
  'productcolumn2productscarouselfifthstkaveh',
  [
    '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(
  'productcolumn3productscarouselfifthstkaveh',
  [
    '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(
  'autoplayproductscarouselfifthstkaveh',
  [
    '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(
  'autoplaydelayproductscarouselfifthstkaveh',
  [
    'label' => esc_html__( 'Autoplay Delay (milliseconds)', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 1000,
    'max' => 10000,
    'step' => 500,
    'default' => 3000,
    'condition' => [
      'autoplayproductscarouselfifthstkaveh' => 'yes',
    ],
  ]
);
$this->add_control(
  'pauseonhoverproductscarouselfifthstkaveh',
  [
    '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' => [
      'autoplayproductscarouselfifthstkaveh' => 'yes',
    ],
  ]
);
$this->add_control(
  'loopproductscarouselfifthstkaveh',
  [
    '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(
  'speedproductscarouselfifthstkaveh',
  [
    'label' => esc_html__( 'Transition Speed (milliseconds)', 'kavehTheme' ),
    'type' => \Elementor\Controls_Manager::NUMBER,
    'min' => 300,
    'max' => 3000,
    'step' => 100,
    'default' => 300,
  ]
);
$this->add_control(
  'centeredslidesproductscarouselfifthstkaveh',
  [
    'label' => esc_html__( 'Center 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(
  'freemodeproductscarouselfifthstkaveh',
  [
    '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(
  'effectproductscarouselfifthstkaveh',
  [
    '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(
  'showarrowproductscarouselfifthstkaveh',
  [
    '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(
  'showdotsproductscarouselfifthstkaveh',
  [
    '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_productscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Title Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'textcolor3productscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Subtitle Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}}  .buy-vip-right .prcr5 span' => 'color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'title2_productscarouselfifthstkaveh',
          'label' => esc_html__( 'Subtitle Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}} .buy-vip-right .prcr5 span',
        ]
      );
      $this->add_control(
        'textcolor2productscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Main Title Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}}  .buy-vip-right .prcr5' => 'color: {{VALUE}}',
          ],
        ]
      );
      $this->add_group_control(
        \Elementor\Group_Control_Typography::get_type(),
        [
          'name' => 'title_productscarouselfifthstkaveh',
          'label' => esc_html__( 'Main Title Typography', 'kavehTheme' ),
          'selector' => '{{WRAPPER}}  .buy-vip-right .prcr5',
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style2_productscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Image Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'widthbgproductscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Image Width', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px' ],
          'range' => [
            'px' => [
              'min' => 0,
              'max' => 2000,
              'step' => 5,
            ],
          ],
        ]
      );
      $this->add_control(
        'leftbgproductscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Right Spacing', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::SLIDER,
          'size_units' => [ 'px', '%' ],
          'range' => [
            'px' => [
              'min' => -500,
              'max' => 500,
              'step' => 5,
            ],
            '%' => [
              'min' => -100,
              'max' => 100,
            ],
          ],
          'selectors' => [
            '{{WRAPPER}} .buy-vip-right::after' => 'left: {{SIZE}}{{UNIT}};',
          ],
        ]
      );
      $this->end_controls_section();
      $this->start_controls_section(
        'style3_productscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Box Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        ]
      );
      $this->add_control(
        'borderradiusproductscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Box Border Radius', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::DIMENSIONS,
          'size_units' => [ 'px' ],
          'selectors' => [
            '{{WRAPPER}} .buy-vip-right' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
          ],
        ]
      );
      
      $this->end_controls_section();
      $this->start_controls_section(
        'style5_productscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Carousel Arrows Style', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
          'condition' => [
            'showarrowsproductscarouselfifthstkaveh' => 'yes',
          ],
        ]
      );
      $this->add_control(
        'arrowscolorproductscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Carousel Arrows Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .buy-vip .swiper-button-next::after' => 'color: {{VALUE}}',
            '{{WRAPPER}} .buy-vip .swiper-button-prev::after' => 'color: {{VALUE}}',
            '{{WRAPPER}} .buy-vip .swiper-button-next' => 'border:2px solid  {{VALUE}}',
            '{{WRAPPER}} .buy-vip .swiper-button-prev' => 'border:2px solid  {{VALUE}}',
          ],
        ]
      ); 
      $this->end_controls_section();

      $this->start_controls_section(
        'style4_productscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Timer Styles', 'kavehTheme' ),
          'tab' => \Elementor\Controls_Manager::TAB_STYLE,
          'condition' => [
            'showtimercarouselfifthstkaveh' => 'yes',
          ],
        ]
      );
      $this->add_control(
        'bordercolorproductscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Line Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .buy-vip-left .timear::before' => 'background-color: {{VALUE}}',
            '{{WRAPPER}} .buy-vip-left .timear::after' => 'background-color: {{VALUE}}',

          ],
        ]
      ); 
      $this->add_control(
        'texttimercolorproductscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Timer Text Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .buy-vip-left .timear li span' => 'color: {{VALUE}}',
          ],
        ]
      ); 
      $this->add_control(
        'bgtimercolorproductscarouselfifthstkaveh',
        [
          'label' => esc_html__( 'Timer Background Color', 'kavehTheme' ),
          'type' => \Elementor\Controls_Manager::COLOR,
          'selectors' => [
            '{{WRAPPER}} .buy-vip-left .timear li span' => 'background-color: {{VALUE}}',
          ],
        ]
      ); 
      $this->end_controls_section();

        }
 

  protected function render(){
    $settings = $this->get_settings_for_display();
    $clsid = $this->get_id();
    ?>
    <section class="buy-vip">
      <div class="container d-flex flex-column flex-sm-row position-relative">
        <div class="buy-vip-right position-relative d-none d-md-block">
          <<?php echo  esc_attr($settings['tagheadingproductscarouselfifthstkaveh']); ?> class="prcr5">
            <span class="d-block"> <?php echo  esc_html($settings['titleproductscarouselfifthstkaveh']); ?></span>
            <?php echo  esc_html($settings['title2productscarouselfifthstkaveh']); ?>
          </<?php echo  esc_attr($settings['tagheadingproductscarouselfifthstkaveh']); ?>>
        </div>
      <div class="buy-vip-left position-relative">
          <?php $deal_end_date = $settings['datecarouselfifthstkaveh']; ?>
          <?php if (!empty($deal_end_date)){ ?>
          <ul class="timear d-flex align-items-center ms-auto" data-time="<?php  echo $deal_end_date; ?>">
            <li>
              <span class="second"> 00 </span>
              Second
            </li>
            <li>
              <span class="minute"> 00 </span>
              Minute
            </li>
            <li>
              <span class="hour"> 00 </span>
              Hour
            </li>
            <li>
              <span class="day"> 00 </span>
              Day
            </li>
          </ul>
          <?php }else{}
           ?>
          <!-- Start Products --> 
        <div class="swiper swiper-products-buy-vip overflow-hidden" data-swiper='<?php echo json_encode([
          "loop" => $settings['loopproductscarouselfifthstkaveh'] === "yes",
          "autoplay" => $settings['autoplayproductscarouselfifthstkaveh'] === "yes" ? [
            "delay" => intval($settings['autoplaydelayproductscarouselfifthstkaveh']),
            "pauseOnMouseEnter" => $settings['pauseonhoverproductscarouselfifthstkaveh'] === "yes"
          ] : false,
          "speed" => intval($settings['speedproductscarouselfifthstkaveh']),
          "effect" => $settings['effectproductscarouselfifthstkaveh'],
          "centeredSlides" => $settings['centeredslidesproductscarouselfifthstkaveh'] === "yes",
          "freeMode" => $settings['freemodeproductscarouselfifthstkaveh'] === "yes",
          "navigation" => $settings['showarrowproductscarouselfifthstkaveh'] === "yes" ? [
            "prevEl" => ".swiper-button-prev",
            "nextEl" => ".swiper-button-next"
          ] : false,
          "pagination" => $settings['showdotsproductscarouselfifthstkaveh'] === "yes" ? [
            "el" => ".swiper-pagination",
            "clickable" => true
          ] : false,
          "breakpoints" => [
            320 => ["slidesPerView" => intval($settings['productcolumn3productscarouselfifthstkaveh']), "spaceBetween" => 4],
            576 => ["slidesPerView" => intval($settings['productcolumn3productscarouselfifthstkaveh']), "spaceBetween" => 8],
            768 => ["slidesPerView" => intval($settings['productcolumn2productscarouselfifthstkaveh']), "spaceBetween" => 8],
            992 => ["slidesPerView" => intval($settings['productcolumnproductscarouselfifthstkaveh']), "spaceBetween" => 11],
          ]
        ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); ?>'>
          <div class="swiper-wrapper">
              <div class="swiper-slide d-md-none">
                  <div class="buy-vip-right position-relative">
                    <<?php echo  esc_attr($settings['tagheadingproductscarouselfifthstkaveh']); ?> class="text-white prcr5">
                      <span class="d-block fw-light"> <?php echo  esc_html($settings['titleproductscarouselfifthstkaveh']); ?> </span>
                      <?php echo  esc_html($settings['title2productscarouselfifthstkaveh']); ?>
                    </<?php echo  esc_attr($settings['tagheadingproductscarouselfifthstkaveh']); ?>>
                  </div>
              </div>
            <?php if('cat'===$settings['pproductscarouselfifthstkaveh']){ ?>
                <?php
                // Define your custom query arguments
                $query_args = array(
                  'post_type' => array('product'),
'post_status' => array('publish'),
                  'posts_per_page' => $settings['productnumberproductscarouselfifthstkaveh'],
                  'orderby' => $settings['psortproductscarouselfifthstkaveh'] === 'date' ? 'date' : 'meta_value_num', // Default to date or meta value
                  'order' => $settings['psortiproductscarouselfifthstkaveh'],
                  'tax_query' => array(
                    'relation' => 'AND',
                    array(
                      'taxonomy' => 'product_cat',
                      'field' => 'term_id',
                      'terms' => $settings['catproductscarouselfifthstkaveh'],
                    ),
                  ),
                );
                // Handle specific orderby values
                switch ($settings['psortproductscarouselfifthstkaveh']) {
                  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['stylecartproductscarouselfifthstkaveh']; ?>
                      <?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['pproductscarouselfifthstkaveh']){
                // Define your custom query arguments
                $query_args = array(
                  'post_type' => array('product'),
'post_status' => array('publish'),
                  'posts_per_page' => $settings['productnumberproductscarouselfifthstkaveh'],
                  'orderby' => $settings['psortproductscarouselfifthstkaveh'] === 'date' ? 'date' : 'meta_value_num', // Default to date or meta value
                  'order' => $settings['psortiproductscarouselfifthstkaveh'],
                  'tax_query' => array(
                    'relation' => 'AND',
                  ),
                );
                // Handle specific orderby values
                switch ($settings['psortproductscarouselfifthstkaveh']) {
                  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['stylecartproductscarouselfifthstkaveh']; ?>
                      <?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['showarrowsproductscarouselfifthstkaveh']){ ?>
            <div class="swiper-button-next"></div>
            <div class="swiper-button-prev"></div>
            <?php } ?>
        </div>
          <!-- End Products -->
        </div>
      </div>
    </section>
    <style>
      <?php echo '.elementor-element-' . $clsid . ''; ?> .buy-vip-right::after {
     -webkit-background-size: contain !important;
    -moz-background-size: contain !important;
    -o-background-size: contain !important;
    background-size: contain !important;
    object-fit: cover ;
    width: <?php echo esc_html($settings['widthbgproductscarouselfifthstkaveh']['size']); ?>px !important;
}
<?php echo '.elementor-element-' . $clsid . ''; ?> .buy-vip-right {
    -webkit-background-size: cover !important;
    -moz-background-size: cover !important;
    -o-background-size: cover !important;
    background-size: cover !important;
}
    </style>
    
    <?php
  }


}
