<?php

use Elementor\Widget_Base;
use Elementor\Controls_Manager;

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


class Amazingoffercarouselkaveh extends Widget_Base
{
  private $options;

  public function __construct($data = [], $args = null) {
    parent::__construct($data, $args);
    $this->options = kaveh_get_options();
  }

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

  public function get_title()
  {
    return esc_html__('Amazing Offer Carousel', 'kavehTheme');
  }

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

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

  protected function register_controls()
  {

    $this->start_controls_section(
      'contentamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Titles', 'kavehTheme'),
        'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
      ]
    );
    $this->add_control(
      'styleboxamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Element Layout', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'one',
        'options' => [
          'one' => esc_html__('First Layout', 'kavehTheme'),
          'two' => esc_html__('Second Layout', 'kavehTheme'),

        ],
      ]
    );
    $this->add_control(
      'tagheadingamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Main 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'),
          'span' => esc_html__('span', 'kavehTheme'),
        ],
      ]
    );
    $this->add_control(
      'titleamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Main Title (Bold)', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => esc_html__('Amazing', 'kavehTheme'),

      ]
    );
    $this->add_control(
      'title2amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Main Title', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => esc_html__('Offer', 'kavehTheme'),

      ]
    );
    $this->add_control(
      'tagheading2amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Subtitle Tag', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::SELECT,
        'default' => 'H6',
        '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(
      'subtitleamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Subtitle', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => esc_html__('Discounted Products', 'kavehTheme'),

      ]
    );
    $this->add_control(
      'moreamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Show More 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(
      'buttonamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Button', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => esc_html__('View All', 'kavehTheme'),
        'condition' => [
          'moreamazingoffercarouselkaveh' => 'yes',
        ],

      ]
    );
    $this->add_control(
      'buttonlinkamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Button Link', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::TEXT,
        'default' => esc_html__('#', 'kavehTheme'),
        'condition' => [
          'moreamazingoffercarouselkaveh' => 'yes',
        ],

      ]
    );
    $this->end_controls_section();

    $this->start_controls_section(
      'content2amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Products', 'kavehTheme'),
        'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
      ]
    );
    $this->add_control(
      'imgbackamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Background Image', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::MEDIA,
        'selectors' => [
          '{{WRAPPER}} .amazing-offer-four::before' =>
          'background-image: url({{URL}})',
        ],
        'condition' => [
          'styleboxamazingoffercarouselkaveh' => 'two',
        ],
      ]
    );
    $options = 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) {
      $options[$category->term_id] = $category->name;
    }
    $this->add_control(
      'catamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Select Category', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::SELECT2,
        'multiple' => true,
        'options' => $options,
      ]
    );
    $this->end_controls_section();
    $this->start_controls_section(
      'content3amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Carousel Settings', 'kavehTheme'),
        'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
      ]
    );
    $this->add_control(
      'productnumberamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Number of Products Displayed', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::NUMBER,
        'min' => 0,
        'max' => 20,
        'step' => 1,
        'default' => 5,
      ]
    );
    $this->add_control(
      'productcolumnamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Number of Product Columns on Desktop', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::NUMBER,
        'min' => 0,
        'max' => 5,
        'step' => 1,
        'default' => 5,

      ]
    );
    $this->add_control(
      'productcolumn2amazingoffercarouselkaveh',
      [
        '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(
      'productcolumn3amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Number of Product Columns on Mobile', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::NUMBER,
        'min' => 0,
        'max' => 5,
        'step' => 1,
        'default' => 2,

      ]
    );
    $this->end_controls_section();
    $this->start_controls_section(
      'style_amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Title Styles', 'kavehTheme'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
      ]
    );
    $this->add_control(
      'textcoloramazingoffercarouselkaveh',
      [
        'label' => esc_html__('Bold Main Title Color', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} .section-heading-title b' => 'color: {{VALUE}}',
        ],
      ]
    );
    $this->add_control(
      'textcolor2amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Main Title Color', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} .section-heading-title' => 'color: {{VALUE}}',
        ],
      ]
    );
    $this->add_group_control(
      \Elementor\Group_Control_Typography::get_type(),
      [
        'name' => 'title_amazingoffercarouselkaveh',
        'label' => esc_html__('Main Title Typography', 'kavehTheme'),
        'selector' => '{{WRAPPER}} .section-heading-title',
      ]
    );
    $this->add_control(
      'textcolor3amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Subtitle Color', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} .section-heading-sub-title' => 'color: {{VALUE}}',
        ],
      ]
    );
    $this->add_group_control(
      \Elementor\Group_Control_Typography::get_type(),
      [
        'name' => 'title2_amazingoffercarouselkaveh',
        'label' => esc_html__('Subtitle Typography', 'kavehTheme'),
        'selector' => '{{WRAPPER}} .section-heading-sub-title',
      ]
    );
    $this->end_controls_section();
    $this->start_controls_section(
      'style2_amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Button Style', 'kavehTheme'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
        'condition' => [
          'moreamazingoffercarouselkaveh' => 'yes',
        ],
      ]
    );

    $this->add_group_control(
      \Elementor\Group_Control_Typography::get_type(),
      [
        'name' => 'button_amazingoffercarouselkaveh',
        'label' => esc_html__('Button Text Typography', 'kavehTheme'),
        'selector' => '{{WRAPPER}} .section-heading-link',
      ]
    );
    $this->add_group_control(
      \Elementor\Group_Control_Text_Shadow::get_type(),
      [
        'name' => 'text_shadowamazingoffercarouselkaveh',
        'label' => esc_html__('Text Shadow', 'kavehTheme'),
        'selector' => '{{WRAPPER}} .section-heading-link',
      ]
    );
    $this->start_controls_tabs(
      'style_tabsamazingoffercarouselkaveh'
    );

    $this->start_controls_tab(
      'style_normal_tabamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Normal', 'kavehTheme'),
      ]
    );
    $this->add_control(
      'textbuttoncoloramazingoffercarouselkaveh',
      [
        'label' => esc_html__('Button Text Color', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} .section-heading-link' => 'color: {{VALUE}}',
        ],
      ]
    );
    $this->add_control(
      'buttoncoloramazingoffercarouselkaveh',
      [
        'label' => esc_html__('Button Background Color', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} .section-heading-link' => 'background-color: {{VALUE}}',
        ],
      ]
    );
    $this->add_control(
      'buttonradiusamazingoffercarouselkaveh',
      [
        'label' => esc_html__('More Button Border Radius', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px'],
        'selectors' => [
          '{{WRAPPER}} .section-heading-link' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
      ]
    );
    $this->add_group_control(
      \Elementor\Group_Control_Border::get_type(),
      [
        'name' => 'borderamazingoffercarouselkaveh',
        'label' => esc_html__('Border', 'kavehTheme'),
        'selector' => '{{WRAPPER}} .section-heading-link',
      ]
    );
    $this->add_control(
      'buttonbordersamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Border Width', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px'],
        'condition' => [
          'borderamazingoffercarouselkaveh!' => '',
        ],
        'selectors' => [
          '{{WRAPPER}} .section-heading-link' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
        ],
      ]
    );
    $this->end_controls_tab();
    $this->start_controls_tab(
      'style_hove_tabamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Hover', 'kavehTheme'),
      ]
    );
    $this->add_control(
      'textbuttoncolorhoveramazingoffercarouselkaveh',
      [
        'label' => esc_html__('Button Text Color', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} .section-heading-link:hover' => 'color: {{VALUE}}',
        ],
      ]
    );
    $this->add_control(
      'buttoncolorhoveramazingoffercarouselkaveh',
      [
        'label' => esc_html__('Button Background Color', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'selectors' => [
          '{{WRAPPER}} .section-heading-link:hover' => 'background-color: {{VALUE}}',
        ],
      ]
    );
    $this->add_control(
      'buttonradiushoveramazingoffercarouselkaveh',
      [
        'label' => esc_html__('More Button Border Radius', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px'],
        'selectors' => [
          '{{WRAPPER}} .section-heading-link:hover' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
      ]
    );
    $this->add_group_control(
      \Elementor\Group_Control_Border::get_type(),
      [
        'name' => 'borderhoveramazingoffercarouselkaveh',
        'label' => esc_html__('Border', 'kavehTheme'),
        'selector' => '{{WRAPPER}} .section-heading-link:hover',
      ]
    );
    $this->add_control(
      'buttonbordershoveramazingoffercarouselkaveh',
      [
        'label' => esc_html__('Border Width', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px'],
        'condition' => [
          'borderhoveramazingoffercarouselkaveh!' => '',
        ],
        'selectors' => [
          '{{WRAPPER}} .section-heading-link:hover' => 'border-width: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}} !important;',
        ],
      ]
    );
    $this->end_controls_tab();
    $this->end_controls_tabs();
    $this->add_group_control(
      \Elementor\Group_Control_Box_Shadow::get_type(),
      [
        'name' => 'box_shadowamazingoffercarouselkavehh',
        'label' => esc_html__('Button Shadow', 'kavehTheme'),
        'selector' => '{{WRAPPER}} .section-heading-link',
      ]
    );
    $this->add_control(
      'hr1amazingoffercarouselkaveh',
      [
        'type' => \Elementor\Controls_Manager::DIVIDER,
      ]
    );
    $this->add_control(
      'buttonpaddingamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Padding', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'size_units' => ['px'],
        'selectors' => [
          '{{WRAPPER}} .section-heading-link' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
      ]
    );
    $this->end_controls_section();
    $this->start_controls_section(
      'style3_amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Box Style', 'kavehTheme'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
      ]
    );
    $this->add_control(
      'boxradiusamazingoffercarouselkaveh',
      [
        'label' => esc_html__('First Box Border Radius', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'condition' => [
          'styleboxamazingoffercarouselkaveh' => 'one',
        ],
        'size_units' => ['px'],
        'selectors' => [
          '{{WRAPPER}} .amazing-offer-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
      ]
    );
    $this->add_control(
      'boxradiusst2amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Box Border Radius', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'condition' => [
          'styleboxamazingoffercarouselkaveh' => 'two',
        ],
        'size_units' => ['px'],
        'selectors' => [
          '{{WRAPPER}} .amazing-offer-four-wrapper' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
      ]
    );
    $this->add_control(
      'boxcolor1amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Second Box Background Color', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'condition' => [
          'styleboxamazingoffercarouselkaveh' => 'one',
        ],
        'selectors' => [
          '{{WRAPPER}} .amazing-offer-wrapper::before' => 'background-color: {{VALUE}}',
        ],
      ]
    );

    $this->add_control(
      'boxradius1amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Second Box Border Radius', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'condition' => [
          'styleboxamazingoffercarouselkaveh' => 'one',
        ],
        'size_units' => ['px'],
        'selectors' => [
          '{{WRAPPER}} .amazing-offer-wrapper::before' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
      ]
    );
    $this->add_control(
      'boxcolor2amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Third Box Background Color', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::COLOR,
        'condition' => [
          'styleboxamazingoffercarouselkaveh' => 'one',
        ],
        'selectors' => [
          '{{WRAPPER}} .amazing-offer-wrapper::after' => 'background-color: {{VALUE}}',
        ],
      ]
    );

    $this->add_control(
      'boxradius2amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Third Box Border Radius', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::DIMENSIONS,
        'condition' => [
          'styleboxamazingoffercarouselkaveh' => 'one',
        ],
        'size_units' => ['px'],
        'selectors' => [
          '{{WRAPPER}} .amazing-offer-wrapper::after' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
        ],
      ]
    );
    $this->end_controls_section();
    $this->start_controls_section(
      'style4_amazingoffercarouselkaveh',
      [
        'label' => esc_html__('Background Image Style', 'kavehTheme'),
        'tab' => \Elementor\Controls_Manager::TAB_STYLE,
      ]
    );
    $this->add_control(
      'widthbgamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Background Image Width', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px', '%'],
        'range' => [
          'px' => [
            'min' => 0,
            'max' => 2000,
            'step' => 5,
          ],
          '%' => [
            'min' => 0,
            'max' => 100,
          ],
        ],
        'default' => [
          'unit' => '%',
          'size' => 100,
        ],
        'selectors' => [
          '{{WRAPPER}} .amazing-offer-four::before' => 'width: {{SIZE}}{{UNIT}};',
        ],
      ]
    );
    $this->add_control(
      'heightbgamazingoffercarouselkaveh',
      [
        'label' => esc_html__('Background Image Height', 'kavehTheme'),
        'type' => \Elementor\Controls_Manager::SLIDER,
        'size_units' => ['px', '%'],
        'range' => [
          'px' => [
            'min' => 0,
            'max' => 2000,
            'step' => 5,
          ],
          '%' => [
            'min' => 0,
            'max' => 100,
          ],
        ],
        'default' => [
          'unit' => '%',
          'size' => 100,
        ],
        'selectors' => [
          '{{WRAPPER}} .amazing-offer-four::before' => 'height: {{SIZE}}{{UNIT}};',
        ],
      ]
    );
    $this->end_controls_section();
  }


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

    <?php if (\Elementor\Plugin::$instance->editor->is_edit_mode()): ?>
      <?php if ('one' === $settings['styleboxamazingoffercarouselkaveh']) { ?>
        <section class="amazing-offer position-relative">
          <div class="container">
            <!-- Start Heading -->
            <div class="section-heading d-flex align-items-sm-center justify-content-sm-between flex-column flex-sm-row">
              <div class="detail position-relative">
                <<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?>
                  class="section-heading-title"><b><?php echo esc_html($settings['titleamazingoffercarouselkaveh']); ?></b>
                  <?php echo esc_html($settings['title2amazingoffercarouselkaveh']); ?></<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?>>
                <<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>
                  class="section-heading-sub-title"><?php echo esc_html($settings['subtitleamazingoffercarouselkaveh']); ?></<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>>
              </div>
              <?php if ("yes" === $settings['moreamazingoffercarouselkaveh']) { ?>
                <a href="<?php echo esc_url($settings['buttonlinkamazingoffercarouselkaveh']); ?>"
                  class="section-heading-link btn btn-outline-dark">
                  <?php echo esc_html($settings['buttonamazingoffercarouselkaveh']); ?></a>
              <?php } ?>
            </div>
            <!-- End Heading -->
            <!-- Start Products -->
            <div class="amazing-offer-wrapper position-relative">
              <div class="swiper swiper-amazing-offer overflow-hidden"
                data-swiper='{"navigation":{"nextEl":".swiper-button-next","prevEl":".swiper-button-prev"},"breakpoints":{"300":{"slidesPerView":<?php echo esc_html($settings['productcolumn3amazingoffercarouselkaveh']); ?>,"spaceBetween":8},"768":{"slidesPerView":<?php echo esc_html($settings['productcolumn2amazingoffercarouselkaveh']); ?>,"spaceBetween":8},"992":{"slidesPerView":<?php echo esc_html($settings['productcolumnamazingoffercarouselkaveh']); ?>,"spaceBetween":11}}}'>
                <div class="swiper-wrapper">
                  <?php

                  // WP_Query args
                  $q_pce_query_args = array(
                    'post_type' => array('product'),
                    'post_status' => array('publish'),
                    'posts_per_page' => $settings['productnumberamazingoffercarouselkaveh'],
                    'order' => 'DESC',
                    'orderby' => 'date',
                    'meta_query' => array(
                      array(
                        'key' => '_stock_status',
                        'value' => 'outofstock',
                        'compare' => '!=',
                      ),
                    ),
                    'post__in' => array_merge(array(0), wc_get_product_ids_on_sale())
                  );

                  // Check if the category variable is empty
                  if (!empty($settings['catamazingoffercarouselkaveh'])) {
                    $q_pce_query_args['tax_query'] = array(
                      array(
                        'taxonomy' => 'product_cat',
                        'field' => 'tag_ID',
                        'terms' => $settings['catamazingoffercarouselkaveh'],
                      ),
                    );
                  }

                  // The Query
                  $pce_query = new \WP_Query($q_pce_query_args);


                  // The Loop
                  if ($pce_query->have_posts()) {
                    while ($pce_query->have_posts()) {
                      $pce_query->the_post(); ?>
                      <div class="swiper-slide">
                        <div class="product product1">
                          <div class="product-image">
                            <?php
                            global $product;
                            $product = wc_get_product();
                            $product_id = $product->get_id();
                            $product_type = $product->get_type();
                            $sale_price_dates_from = $sale_price_dates_to = '';
                            $sale_price = $product->get_sale_price();
                            $normal_price = $product->get_regular_price();
                            $pr_id = get_the_ID();
                            $stocka = $product->get_stock_status();
                            if (!empty($normal_price)) {
                              if ("instock" == $stocka) {
                                if (!empty($sale_price)) { ?>
                                  <div class="discount">
                                    % <?php
                                      $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
                                      echo $percentage;
                                      ?>
                                  </div>
                            <?php }
                              }
                            } ?>

                            <div class="cs-height_10 cs-height_lg_10"></div>
                            <a href="<?php the_permalink(); ?>">
                              <img src="<?php the_post_thumbnail_url(); ?>" alt="product" />
                            </a>
                          </div>
                          <div class="detail">
                            <h2>
                              <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a>
                            </h2>
                            <?php if ("instock" == $stocka) { ?>
                              <?php if (!$product->is_type('variable')) { ?>
                                <?php if (!empty($sale_price)) { ?>
                                  <div class="offer">
                                    <?php echo $normal_price; ?>
                                  </div>
                                  <div class="price mx-auto">
                                    <?php echo number_format($sale_price, 0, '.', ','); ?>
                                    <span> <?php echo get_woocommerce_currency_symbol(); ?> </span>
                                  </div>
                                <?php } else { ?>
                                  <div class="price mx-auto">
                                    <?php if (!empty($normal_price)) {
                                      echo number_format($normal_price, 0, '.', ',');
                                    } ?>
                                    <span> <?php echo get_woocommerce_currency_symbol(); ?></span>
                                  </div>
                                <?php } ?>
                              <?php } else {
                                $price_v = $product->get_price_html();
                                echo str_replace("&ndash;", "<span class=\"dashvar\"> – </span>", $price_v);
                              }
                              ?>
                            <?php }
                            ?>
                            <div class="product-hover">
                              <?php if (!$product->is_type('variable')) { ?>
                                <a href="<?php the_permalink(); ?>" class="btn btn-secondary rounded-pill"> <?php esc_html_e('View Product', 'kavehTheme'); ?></a>
                              <?php } else { ?>
                                <a href="<?php the_permalink(); ?>" class="btn btn-secondary rounded-pill"> <?php esc_html_e('View Options', 'kavehTheme'); ?></a>
                              <?php } ?>
                              <?php if (!$product->is_type('variable')) { ?>
                                <?php if ("instock" == $stocka) { ?>
                                  <button type="submit" name="add-to-cart" value="<?php echo $pr_id ?>"
                                    class="single_add_to_cart_button btn btn-secondary rounded-circle icarrt">
                                    <i class="icon icon-cart-3"></i>
                                  </button>
                              <?php }
                              } ?>
                              <?php if (isset($this->options['kaveh_wishlist_system']) && $this->options['kaveh_wishlist_system'] === '1'): ?>
                                <?php echo do_shortcode('[wlm_button html_tag="button" class="btn btn-secondary rounded-circle"]'); ?>
                              <?php endif; ?>

                            </div>
                          </div>
                        </div>
                      </div>
                  <?php }
                  } else {
                    // There are no posts
                  }

                  // Reset Original Post Data
                  wp_reset_postdata();



                  ?>
                </div>
              </div>
              <?php if ("yes" === $settings['moreamazingoffercarouselkaveh']) { ?>
                <div class="swiper-button-next d-none d-sm-block"></div>
                <div class="swiper-button-prev d-none d-sm-block"></div>
              <?php } ?>
            </div>
            <!-- End Products -->
            <button class="amazing-offer-btn" data-scroll-to="#banners"></button>
          </div>
        </section>
      <?php } elseif ('two' === $settings['styleboxamazingoffercarouselkaveh']) { ?>
        <section class="amazing-offer amazing-offer-four position-relative">
          <div class="container">
            <!-- Start Heading -->
            <div class="section-heading d-flex align-items-sm-center justify-content-sm-between flex-column flex-sm-row">
              <div class="detail position-relative">
                <<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?> class="section-heading-title">
                  <b><?php echo esc_html($settings['titleamazingoffercarouselkaveh']); ?></b>
                  <?php echo esc_html($settings['title2amazingoffercarouselkaveh']); ?>
                </<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?>>
                <<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>
                  class="section-heading-sub-title">
                  <?php echo esc_html($settings['subtitleamazingoffercarouselkaveh']); ?></<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>>
              </div>
              <?php if ("yes" === $settings['moreamazingoffercarouselkaveh']) { ?>
                <a href="<?php echo esc_url($settings['buttonlinkamazingoffercarouselkaveh']); ?>"
                  class="section-heading-link btn btn-outline-dark">
                  <?php echo esc_html($settings['buttonamazingoffercarouselkaveh']); ?> </a>
              <?php } ?>
            </div>
            <!-- End Heading -->
            <!-- Start Products -->
            <div class="amazing-offer-four-wrapper position-relative">
              <div class="swiper swiper-amazing-offer overflow-hidden"
                data-swiper='{"navigation":{"nextEl":".swiper-button-next","prevEl":".swiper-button-prev"},"breakpoints":{"300":{"slidesPerView":<?php echo esc_html($settings['productcolumn3amazingoffercarouselkaveh']); ?>,"spaceBetween":8},"768":{"slidesPerView":<?php echo esc_html($settings['productcolumn2amazingoffercarouselkaveh']); ?>,"spaceBetween":8},"992":{"slidesPerView":<?php echo esc_html($settings['productcolumnamazingoffercarouselkaveh']); ?>,"spaceBetween":11}}}'>
                <div class="swiper-wrapper">
                  <?php

                  // WP_Query args
                  $q_pce_query_args = array(
                    'post_type' => array('product'),
                    'post_status' => array('publish'),
                    'posts_per_page' => $settings['productnumberamazingoffercarouselkaveh'],
                    'order' => 'DESC',
                    'orderby' => 'date',
                    'tax_query' => array(
                      array(
                        "taxonomy" => "product_cat",
                        "field" => "tag_ID",
                        "terms" => $settings['catamazingoffercarouselkaveh'],
                      ),
                    ),
                    'meta_query' => array(
                      array(
                        'key' => '_stock_status',
                        'value' => 'outofstock',
                        'compare' => '!=',
                      ),
                    ),
                    'post__in' => array_merge(array(0), wc_get_product_ids_on_sale())

                  );

                  // The Query
                  $pce_query = new \WP_Query($q_pce_query_args);

                  // The Loop
                  if ($pce_query->have_posts()) {
                    while ($pce_query->have_posts()) {
                      $pce_query->the_post();
                      global $product;
                      $product = wc_get_product();
                      $product_id = $product->get_id();
                      $product_type = $product->get_type();
                      $sale_price_dates_from = $sale_price_dates_to = '';
                      $sale_price = $product->get_sale_price();
                      $normal_price = $product->get_regular_price();
                      $pr_id = get_the_ID();
                      $stocka = $product->get_stock_status();
                  ?>
                      <div class="swiper-slide">
                        <div class="product product1 product-four">
                          <div class="product-image">
                            <?php if (!empty($normal_price)) {
                              if ("instock" == $stocka) {
                                if (!empty($sale_price)) { ?>
                                  <div class="discount">
                                    % <?php
                                      $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
                                      echo $percentage;
                                      ?>
                                  </div>
                            <?php }
                              }
                            } ?>
                            <a href="<?php the_permalink(); ?>">
                              <img src="<?php the_post_thumbnail_url(); ?>" alt="product" />
                            </a>
                          </div>
                          <div class="detail">
                            <h2>
                              <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a>
                            </h2>
                            <?php if ("instock" == $stocka) { ?>
                              <?php if (!$product->is_type('variable')) { ?>
                                <?php if (!empty($sale_price)) { ?>
                                  <div class="offer">
                                    <?php echo $normal_price; ?>
                                  </div>
                                  <div class="price mx-auto">
                                    <?php echo number_format($sale_price, 0, '.', ','); ?>
                                    <span> <?php echo get_woocommerce_currency_symbol(); ?> </span>
                                  </div>
                                <?php } else { ?>
                                  <div class="price mx-auto">
                                    <?php if (!empty($normal_price)) {
                                      echo number_format($normal_price, 0, '.', ',');
                                    } ?>
                                    <span> <?php echo get_woocommerce_currency_symbol(); ?></span>
                                  </div>
                                <?php } ?>
                              <?php } else {
                                $price_v = $product->get_price_html();
                                echo str_replace("&ndash;", "<span class=\"dashvar\"> – </span>", $price_v);
                              }
                              ?>
                            <?php }
                            ?>
                            <div class="product-hover">
                              <?php if (!$product->is_type('variable')) { ?>
                                <a href="<?php the_permalink(); ?>" class="btn btn-secondary rounded-pill"> View Product </a>
                              <?php } else { ?>
                                <a href="<?php the_permalink(); ?>" class="btn btn-secondary rounded-pill"> View Options</a>
                              <?php } ?>
                              <?php if (!$product->is_type('variable')) { ?>
                                <?php if ("instock" == $stocka) { ?>
                                  <button type="submit" name="add-to-cart" value="<?php echo $pr_id ?>"
                                    class="single_add_to_cart_button btn btn-secondary rounded-circle icarrt">
                                    <i class="icon icon-cart-3"></i>
                                  </button>
                              <?php }
                              } ?>
                              <?php if (isset($this->options['kaveh_wishlist_system']) && $this->options['kaveh_wishlist_system'] === '1'): ?>
                                <?php echo do_shortcode('[wlm_button]'); ?>
                              <?php endif; ?>

                            </div>
                          </div>
                        </div>
                      </div>
                  <?php }
                  } else {
                    // There are no posts
                  }
                  // Reset Original Post Data
                  wp_reset_postdata();
                  ?>
                </div>
              </div>
              <?php if ("yes" === $settings['moreamazingoffercarouselkaveh']) { ?>
                <div class="swiper-button-next d-none d-sm-block"></div>
                <div class="swiper-button-prev d-none d-sm-block"></div>
              <?php } ?>
            </div>
            <!-- End Products -->
            <button class="amazing-offer-btn"></button>
          </div>
        </section>
      <?php } ?>

    <?php else: ?>
      <div class="kel-widget">

        <?php if ('one' === $settings['styleboxamazingoffercarouselkaveh']) { ?>
          <section class="amazing-offer position-relative skeleton-display">
            <div class="container">
              <!-- Start Heading -->
              <div class="section-heading d-flex align-items-sm-center justify-content-sm-between flex-column flex-sm-row">
                <div class="detail position-relative">
                  <<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?>
                    class="section-heading-title"><b><?php echo esc_html($settings['titleamazingoffercarouselkaveh']); ?></b>
                    <?php echo esc_html($settings['title2amazingoffercarouselkaveh']); ?></<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?>>
                  <<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>
                    class="section-heading-sub-title"><?php echo esc_html($settings['subtitleamazingoffercarouselkaveh']); ?></<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>>
                </div>
                <?php if ("yes" === $settings['moreamazingoffercarouselkaveh']) { ?>
                  <a href="<?php echo esc_url($settings['buttonlinkamazingoffercarouselkaveh']); ?>"
                    class="section-heading-link btn btn-outline-dark">
                    <?php echo esc_html($settings['buttonamazingoffercarouselkaveh']); ?></a>
                <?php } ?>
              </div>
              <!-- End Heading -->
              <!-- Start Products -->
              <div class="amazing-offer-wrapper position-relative">

                <?php if (wp_is_mobile()): ?>
                  <div class="skeleton-loader">
                    <div class="skeleton-header"></div>
                    <div class="skeleton-content"></div>
                    <div class="skeleton-p"></div>
                    <div class="skeleton-p"></div>
                    <div class="skeleton-footer"></div>
                  </div>
                <?php else: ?>
                  <div class="row">
                    <div class="col">
                      <div class="skeleton-loader">
                        <div class="skeleton-header"></div>
                        <div class="skeleton-content"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-footer"></div>
                      </div>
                    </div>
                    <div class="col">
                      <div class="skeleton-loader">
                        <div class="skeleton-header"></div>
                        <div class="skeleton-content"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-footer"></div>
                      </div>
                    </div>
                    <div class="col">
                      <div class="skeleton-loader">
                        <div class="skeleton-header"></div>
                        <div class="skeleton-content"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-footer"></div>
                      </div>
                    </div>
                    <div class="col">
                      <div class="skeleton-loader">
                        <div class="skeleton-header"></div>
                        <div class="skeleton-content"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-footer"></div>
                      </div>
                    </div>
                    <div class="col">
                      <div class="skeleton-loader">
                        <div class="skeleton-header"></div>
                        <div class="skeleton-content"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-footer"></div>
                      </div>
                    </div>
                  </div>
                <?php endif; ?>
              </div>
              <!-- End Products -->
              <button class="amazing-offer-btn" data-scroll-to="#banners"></button>
            </div>
          </section>
        <?php } elseif ('two' === $settings['styleboxamazingoffercarouselkaveh']) { ?>
          <section class="amazing-offer amazing-offer-four position-relative skeleton-display">
            <div class="container">
              <!-- Start Heading -->
              <div class="section-heading d-flex align-items-sm-center justify-content-sm-between flex-column flex-sm-row">
                <div class="detail position-relative">
                  <<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?> class="section-heading-title">
                    <b><?php echo esc_html($settings['titleamazingoffercarouselkaveh']); ?></b>
                    <?php echo esc_html($settings['title2amazingoffercarouselkaveh']); ?>
                  </<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?>>
                  <<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>
                    class="section-heading-sub-title">
                    <?php echo esc_html($settings['subtitleamazingoffercarouselkaveh']); ?></<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>>
                </div>
                <?php if ("yes" === $settings['moreamazingoffercarouselkaveh']) { ?>
                  <a href="<?php echo esc_url($settings['buttonlinkamazingoffercarouselkaveh']); ?>"
                    class="section-heading-link btn btn-outline-dark">
                    <?php echo esc_html($settings['buttonamazingoffercarouselkaveh']); ?> </a>
                <?php } ?>
              </div>
              <!-- End Heading -->
              <!-- Start Products -->
              <div class="amazing-offer-four-wrapper position-relative">
                <?php if (wp_is_mobile()): ?>
                  <div class="skeleton-loader">
                    <div class="skeleton-header"></div>
                    <div class="skeleton-content"></div>
                    <div class="skeleton-p"></div>
                    <div class="skeleton-p"></div>
                    <div class="skeleton-footer"></div>
                  </div>
                <?php else: ?>
                  <div class="row">
                    <div class="col">
                      <div class="skeleton-loader">
                        <div class="skeleton-header"></div>
                        <div class="skeleton-content"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-footer"></div>
                      </div>
                    </div>
                    <div class="col">
                      <div class="skeleton-loader">
                        <div class="skeleton-header"></div>
                        <div class="skeleton-content"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-footer"></div>
                      </div>
                    </div>
                    <div class="col">
                      <div class="skeleton-loader">
                        <div class="skeleton-header"></div>
                        <div class="skeleton-content"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-footer"></div>
                      </div>
                    </div>
                    <div class="col">
                      <div class="skeleton-loader">
                        <div class="skeleton-header"></div>
                        <div class="skeleton-content"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-footer"></div>
                      </div>
                    </div>
                    <div class="col">
                      <div class="skeleton-loader">
                        <div class="skeleton-header"></div>
                        <div class="skeleton-content"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-p"></div>
                        <div class="skeleton-footer"></div>
                      </div>
                    </div>
                  </div>
                <?php endif; ?>
              </div>
              <!-- End Products -->
              <button class="amazing-offer-btn"></button>
            </div>
          </section>
        <?php } ?>

        <div class="kel-content" style="display:none">
          <?php if ('one' === $settings['styleboxamazingoffercarouselkaveh']) { ?>
            <section class="amazing-offer position-relative">
              <div class="container">
                <!-- Start Heading -->
                <div class="section-heading d-flex align-items-sm-center justify-content-sm-between flex-column flex-sm-row">
                  <div class="detail position-relative">
                    <<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?>
                      class="section-heading-title"><b><?php echo esc_html($settings['titleamazingoffercarouselkaveh']); ?></b>
                      <?php echo esc_html($settings['title2amazingoffercarouselkaveh']); ?></<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?>>
                    <<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>
                      class="section-heading-sub-title"><?php echo esc_html($settings['subtitleamazingoffercarouselkaveh']); ?></<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>>
                  </div>
                  <?php if ("yes" === $settings['moreamazingoffercarouselkaveh']) { ?>
                    <a href="<?php echo esc_url($settings['buttonlinkamazingoffercarouselkaveh']); ?>"
                      class="section-heading-link btn btn-outline-dark">
                      <?php echo esc_html($settings['buttonamazingoffercarouselkaveh']); ?></a>
                  <?php } ?>
                </div>
                <!-- End Heading -->
                <!-- Start Products -->
                <div class="amazing-offer-wrapper position-relative">
                  <div class="swiper swiper-amazing-offer overflow-hidden"
                    data-swiper='{"navigation":{"nextEl":".swiper-button-next","prevEl":".swiper-button-prev"},"breakpoints":{"300":{"slidesPerView":<?php echo esc_html($settings['productcolumn3amazingoffercarouselkaveh']); ?>,"spaceBetween":8},"768":{"slidesPerView":<?php echo esc_html($settings['productcolumn2amazingoffercarouselkaveh']); ?>,"spaceBetween":8},"992":{"slidesPerView":<?php echo esc_html($settings['productcolumnamazingoffercarouselkaveh']); ?>,"spaceBetween":11}}}'>
                    <div class="swiper-wrapper">
                      <?php

                      // WP_Query args
                      $q_pce_query_args = array(
                        'post_type' => array('product'),
                        'post_status' => array('publish'),
                        'posts_per_page' => $settings['productnumberamazingoffercarouselkaveh'],
                        'order' => 'DESC',
                        'orderby' => 'date',
                        'meta_query' => array(
                          array(
                            'key' => '_stock_status',
                            'value' => 'outofstock',
                            'compare' => '!=',
                          ),
                        ),
                        'post__in' => array_merge(array(0), wc_get_product_ids_on_sale())
                      );

                      // Check if the category variable is empty
                      if (!empty($settings['catamazingoffercarouselkaveh'])) {
                        $q_pce_query_args['tax_query'] = array(
                          array(
                            'taxonomy' => 'product_cat',
                            'field' => 'tag_ID',
                            'terms' => $settings['catamazingoffercarouselkaveh'],
                          ),
                        );
                      }

                      // The Query
                      $pce_query = new \WP_Query($q_pce_query_args);


                      // The Loop
                      if ($pce_query->have_posts()) {
                        while ($pce_query->have_posts()) {
                          $pce_query->the_post(); ?>
                          <div class="swiper-slide">
                            <div class="product product1">
                              <div class="product-image">
                                <?php
                                global $product;
                                $product = wc_get_product();
                                $product_id = $product->get_id();
                                $product_type = $product->get_type();
                                $sale_price_dates_from = $sale_price_dates_to = '';
                                $sale_price = $product->get_sale_price();
                                $normal_price = $product->get_regular_price();
                                $pr_id = get_the_ID();
                                $stocka = $product->get_stock_status();
                                if (!empty($normal_price)) {
                                  if ("instock" == $stocka) {
                                    if (!empty($sale_price)) { ?>
                                      <div class="discount">
                                        % <?php
                                          $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
                                          echo $percentage;
                                          ?>
                                      </div>
                                <?php }
                                  }
                                } ?>

                                <div class="cs-height_10 cs-height_lg_10"></div>
                                <a href="<?php the_permalink(); ?>">
                                  <img src="<?php the_post_thumbnail_url(); ?>" alt="product" />
                                </a>
                              </div>
                              <div class="detail">
                                <h2>
                                  <a href="<?php the_permalink(); ?>"> <?php the_title(); ?></a>
                                </h2>
                                <?php if ("instock" == $stocka) { ?>
                                  <?php if (!$product->is_type('variable')) { ?>
                                    <?php if (!empty($sale_price)) { ?>
                                      <div class="offer">
                                        <?php echo $normal_price; ?>
                                      </div>
                                      <div class="price mx-auto">
                                        <?php echo number_format($sale_price, 0, '.', ','); ?>
                                        <span> <?php echo get_woocommerce_currency_symbol(); ?> </span>
                                      </div>
                                    <?php } else { ?>
                                      <div class="price mx-auto">
                                        <?php if (!empty($normal_price)) {
                                          echo number_format($normal_price, 0, '.', ',');
                                        } ?>
                                        <span> <?php echo get_woocommerce_currency_symbol(); ?></span>
                                      </div>
                                    <?php } ?>
                                  <?php } else {
                                    $price_v = $product->get_price_html();
                                    echo str_replace("&ndash;", "<span class=\"dashvar\"> – </span>", $price_v);
                                  }
                                  ?>
                                <?php }
                                ?>
                                <div class="product-hover">
                                  <?php if (!$product->is_type('variable')) { ?>
                                    <a href="<?php the_permalink(); ?>" class="btn btn-secondary rounded-pill"> <?php esc_html_e('View Product', 'kavehTheme'); ?> </a>
                                  <?php } else { ?>
                                    <a href="<?php the_permalink(); ?>" class="btn btn-secondary rounded-pill"> <?php esc_html_e('View Options', 'kavehTheme'); ?></a>
                                  <?php } ?>
                                  <?php if (!$product->is_type('variable')) { ?>
                                    <?php if ("instock" == $stocka) { ?>
                                      <button type="submit" name="add-to-cart" value="<?php echo $pr_id ?>"
                                        class="single_add_to_cart_button btn btn-secondary rounded-circle icarrt">
                                        <i class="icon icon-cart-3"></i>
                                      </button>
                                  <?php }
                                  } ?>
                                  <?php if (isset($this->options['kaveh_wishlist_system']) && $this->options['kaveh_wishlist_system'] === '1'): ?>
                                    <?php echo do_shortcode('[wlm_button html_tag="button" class="btn btn-secondary rounded-circle"]'); ?>
                                  <?php endif; ?>
                                </div>
                              </div>
                            </div>
                          </div>
                      <?php }
                      } else {
                        // There are no posts
                      }
                      // Reset Original Post Data
                      wp_reset_postdata();
                      ?>
                    </div>
                  </div>
                  <?php if ("yes" === $settings['moreamazingoffercarouselkaveh']) { ?>
                    <div class="swiper-button-next d-none d-sm-block"></div>
                    <div class="swiper-button-prev d-none d-sm-block"></div>
                  <?php } ?>
                </div>
                <!-- End Products -->
                <button class="amazing-offer-btn" data-scroll-to="#banners"></button>
              </div>
            </section>
          <?php } elseif ('two' === $settings['styleboxamazingoffercarouselkaveh']) { ?>
            <section class="amazing-offer amazing-offer-four position-relative">
              <div class="container">
                <!-- Start Heading -->
                <div class="section-heading d-flex align-items-sm-center justify-content-sm-between flex-column flex-sm-row">
                  <div class="detail position-relative">
                    <<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?> class="section-heading-title">
                      <b><?php echo esc_html($settings['titleamazingoffercarouselkaveh']); ?></b>
                      <?php echo esc_html($settings['title2amazingoffercarouselkaveh']); ?>
                    </<?php echo esc_attr($settings['tagheadingamazingoffercarouselkaveh']); ?>>
                    <<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>
                      class="section-heading-sub-title">
                      <?php echo esc_html($settings['subtitleamazingoffercarouselkaveh']); ?></<?php echo esc_attr($settings['tagheading2amazingoffercarouselkaveh']); ?>>
                  </div>
                  <?php if ("yes" === $settings['moreamazingoffercarouselkaveh']) { ?>
                    <a href="<?php echo esc_url($settings['buttonlinkamazingoffercarouselkaveh']); ?>"
                      class="section-heading-link btn btn-outline-dark">
                      <?php echo esc_html($settings['buttonamazingoffercarouselkaveh']); ?> </a>
                  <?php } ?>
                </div>
                <!-- End Heading -->
                <!-- Start Products -->
                <div class="amazing-offer-four-wrapper position-relative">
                  <div class="swiper swiper-amazing-offer overflow-hidden"
                    data-swiper='{"navigation":{"nextEl":".swiper-button-next","prevEl":".swiper-button-prev"},"breakpoints":{"300":{"slidesPerView":<?php echo esc_html($settings['productcolumn3amazingoffercarouselkaveh']); ?>,"spaceBetween":8},"768":{"slidesPerView":<?php echo esc_html($settings['productcolumn2amazingoffercarouselkaveh']); ?>,"spaceBetween":8},"992":{"slidesPerView":<?php echo esc_html($settings['productcolumnamazingoffercarouselkaveh']); ?>,"spaceBetween":11}}}'>
                    <div class="swiper-wrapper">
                      <?php

                      // WP_Query args
                      $q_pce_query_args = array(
                        'post_type' => array('product'),
                        'post_status' => array('publish'),
                        'posts_per_page' => $settings['productnumberamazingoffercarouselkaveh'],
                        'order' => 'DESC',
                        'orderby' => 'date',
                        'tax_query' => array(
                          array(
                            "taxonomy" => "product_cat",
                            "field" => "tag_ID",
                            "terms" => $settings['catamazingoffercarouselkaveh'],
                          ),
                        ),
                        'meta_query' => array(
                          array(
                            'key' => '_stock_status',
                            'value' => 'outofstock',
                            'compare' => '!=',
                          ),
                        ),
                        'post__in' => array_merge(array(0), wc_get_product_ids_on_sale())

                      );

                      // The Query
                      $pce_query = new \WP_Query($q_pce_query_args);

                      // The Loop
                      if ($pce_query->have_posts()) {
                        while ($pce_query->have_posts()) {
                          $pce_query->the_post();
                          global $product;
                          $product = wc_get_product();
                          $product_id = $product->get_id();
                          $product_type = $product->get_type();
                          $sale_price_dates_from = $sale_price_dates_to = '';
                          $sale_price = $product->get_sale_price();
                          $normal_price = $product->get_regular_price();
                          $pr_id = get_the_ID();
                          $stocka = $product->get_stock_status();
                      ?>
                          <div class="swiper-slide">
                            <div class="product product1 product-four">
                              <div class="product-image">
                                <?php if (!empty($normal_price)) {
                                  if ("instock" == $stocka) {
                                    if (!empty($sale_price)) { ?>
                                      <div class="discount">
                                        % <?php
                                          $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
                                          echo $percentage;
                                          ?>
                                      </div>
                                <?php }
                                  }
                                } ?>
                                <a href="<?php the_permalink(); ?>">
                                  <img src="<?php the_post_thumbnail_url(); ?>" alt="product" />
                                </a>
                              </div>
                              <div class="detail">
                                <h2>
                                  <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a>
                                </h2>
                                <?php if ("instock" == $stocka) { ?>
                                  <?php if (!$product->is_type('variable')) { ?>
                                    <?php if (!empty($sale_price)) { ?>
                                      <div class="offer">
                                        <?php echo $normal_price; ?>
                                      </div>
                                      <div class="price mx-auto">
                                        <?php echo number_format($sale_price, 0, '.', ','); ?>
                                        <span> <?php echo get_woocommerce_currency_symbol(); ?> </span>
                                      </div>
                                    <?php } else { ?>
                                      <div class="price mx-auto">
                                        <?php if (!empty($normal_price)) {
                                          echo number_format($normal_price, 0, '.', ',');
                                        } ?>
                                        <span> <?php echo get_woocommerce_currency_symbol(); ?></span>
                                      </div>
                                    <?php } ?>
                                  <?php } else {
                                    $price_v = $product->get_price_html();
                                    echo str_replace("&ndash;", "<span class=\"dashvar\"> – </span>", $price_v);
                                  }
                                  ?>
                                <?php }
                                ?>
                                <div class="product-hover">
                                  <?php if (!$product->is_type('variable')) { ?>
                                    <a href="<?php the_permalink(); ?>" class="btn btn-secondary rounded-pill"> View Product </a>
                                  <?php } else { ?>
                                    <a href="<?php the_permalink(); ?>" class="btn btn-secondary rounded-pill"> View Options</a>
                                  <?php } ?>
                                  <?php if (!$product->is_type('variable')) { ?>
                                    <?php if ("instock" == $stocka) { ?>
                                      <button type="submit" name="add-to-cart" value="<?php echo $pr_id ?>"
                                        class="single_add_to_cart_button btn btn-secondary rounded-circle icarrt">
                                        <i class="icon icon-cart-3"></i>
                                      </button>
                                  <?php }
                                  } ?>
                                  <?php if (isset($this->options['kaveh_wishlist_system']) && $this->options['kaveh_wishlist_system'] === '1'): ?>
                                    <?php echo do_shortcode('[wlm_button]'); ?>
                                  <?php endif; ?>
                                </div>
                              </div>
                            </div>
                          </div>
                      <?php }
                      } else {
                        // There are no posts
                      }
                      // Reset Original Post Data
                      wp_reset_postdata();
                      ?>
                    </div>
                  </div>
                  <?php if ("yes" === $settings['moreamazingoffercarouselkaveh']) { ?>
                    <div class="swiper-button-next d-none d-sm-block"></div>
                    <div class="swiper-button-prev d-none d-sm-block"></div>
                  <?php } ?>
                </div>
                <!-- End Products -->
                <button class="amazing-offer-btn"></button>
              </div>
            </section>
          <?php } ?>

        </div>
      </div>
    <?php endif; ?>
<?php
  }
}
