<?php

namespace Elementor;

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

class offer1 extends Widget_Base {

    public function get_name() {
        return 'offer';
    }
    
    public function get_title() {
        return __( 'محصولات شگفت انگیز 4', 'woolentor' );
    }

  public function get_icon() {
		return 'eicon eicon-bag-medium';
    }
    
    public function get_categories() {
        return [ 'farnam' ];
    }

    public function get_script_depends() {
        return [
            'woolentor-widgets-scripts',
            'slick',
        ];
    }

    protected function register_controls() {


        $this->start_controls_section(
            'woolentor-products',
            [
                'label' => esc_html__( 'Product Settings', 'woolentor' ),
            ]
        );
        
            

            $this->add_control(
                'woolentor_product_grid_product_filter',
                [
                    'label' => esc_html__( 'فیلتر شده', 'woolentor' ),
                    'type' => Controls_Manager::SELECT,
                    'default' => 'recent',
                    'options' => [
                        'recent' => esc_html__( 'آخرین محصولات', 'woolentor' ),
                        'featured' => esc_html__( 'محضولات ویژه', 'woolentor' ),
                        'best_selling' => esc_html__( 'محصولات پر فروش', 'woolentor' ),
                        'sale' => esc_html__( 'محصولات تخفیفی', 'woolentor' ),
                        'top_rated' => esc_html__( 'محصولات محبوب', 'woolentor' ),
                    ],
                ]
            );
           
            $this->add_control(
              'woolentor_product_grid_row',
              [
                 'label'   => __( 'ستون ( فعلا فقط ۱ )', 'woolentor' ),
                 'type'    => Controls_Manager::NUMBER,
                 'default' => 1,
                 'min'     => 1,
                 'max'     => 20,
                 'step'    => 1,
              ]
            );

            $this->add_control(
              'woolentor_product_grid_products_count',
              [
                 'label'   => __( 'تعداد محصولات', 'woolentor' ),
                 'type'    => Controls_Manager::NUMBER,
                 'default' => 4,
                 'min'     => 1,
                 'max'     => 100,
                 'step'    => 1,
              ]
            );

            $this->add_control(
                'woolentor_product_grid_categories',
                [
                    'label' => esc_html__( 'دسته بندی محصولات', 'woolentor' ),
                    'type' => Controls_Manager::SELECT2,
                    'label_block' => true,
                    'multiple' => true,
                    'options' => woolentor_woocommerce_product_categories(),
                ]
            );
           

           

        $this->end_controls_section();


        

             
		       $this->start_controls_section(
            'farnam_product_style_1',
            [
                'label' => esc_html__( 'تنظیمات فعال سازی', 'woolentor' ),
            ]
        );
	
		       $this->add_control(
			'farnamoneshow1',
			[
				'label' => __( 'نمایش تعداد فروش', 'plugin-domain' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'نمایش', 'your-plugin' ),
				'label_off' => __( 'مخفی', 'your-plugin' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);

       $this->add_control(
			'farnamoneshow2',
			[
				'label' => __( 'نمایش عنوان انگلیسی', 'plugin-domain' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'نمایش', 'your-plugin' ),
				'label_off' => __( 'مخفی', 'your-plugin' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);
		
		  $this->add_control(
			'farnamoneshow3',
			[
				'label' => __( 'نمایش درصد تخفیف', 'plugin-domain' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'نمایش', 'your-plugin' ),
				'label_off' => __( 'مخفی', 'your-plugin' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);
		
		  $this->add_control(
			'farnamoneshow4',
			[
				'label' => __( 'نمایش قیمت', 'plugin-domain' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'نمایش', 'your-plugin' ),
				'label_off' => __( 'مخفی', 'your-plugin' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);
		
		  $this->add_control(
			'farnamoneshow5',
			[
				'label' => __( 'نمایش ویژگی ها', 'plugin-domain' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'نمایش', 'your-plugin' ),
				'label_off' => __( 'مخفی', 'your-plugin' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);
		
		  $this->add_control(
			'farnamoneshow6',
			[
				'label' => __( 'نمایش تایمر', 'plugin-domain' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'نمایش', 'your-plugin' ),
				'label_off' => __( 'مخفی', 'your-plugin' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);
		
		  $this->add_control(
			'farnamoneshow7',
			[
				'label' => __( 'نمایش تصاویر کوچک اسلاید ها', 'plugin-domain' ),
				'type' => \Elementor\Controls_Manager::SWITCHER,
				'label_on' => __( 'نمایش', 'your-plugin' ),
				'label_off' => __( 'مخفی', 'your-plugin' ),
				'return_value' => 'yes',
				'default' => 'yes',
			]
		);
		
        $this->end_controls_section();


        
	       $this->start_controls_section(
            'farnam_product_style_2',
            [
                'label' => esc_html__( 'تنظیمات استایل و ظاهر', 'woolentor' ),
            ]
        );
             


$this->add_control(
'color_farnam_1',
			[
				'label' => __( 'رنگ پس زمینه درصد تخفیف', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .darsad-new-mank' => 'background: {{VALUE}} !important',
				],
			]
           );
		   
		   $this->add_control(
'color_farnam_2',
			[
				'label' => __( 'رنگ متن درصد تخفیف', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .darsad-new-mank' => 'color: {{VALUE}} !important',
				],
			]
           );
		   
		   $this->add_control(
'color_farnam_3',
			[
				'label' => __( 'رنگ پس زمینه تعداد فروش', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .outofstock-new-2' => 'background: {{VALUE}} !important',
				],
			]
           );

		   $this->add_control(
'color_farnam_4',
			[
				'label' => __( 'رنگ متن تعداد فروش', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
	
				'selectors' => [
					'{{WRAPPER}} .outofstock-new-2' => 'color: {{VALUE}} !important',
				],
			]
           );
		   
		   
		   
		   $this->add_control(
'color_farnam_5',
			[
				'label' => __( 'رنگ کادر تصویر بزرگ', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .product-style.htpp.ir-owl.offer-00-1.slide-new-4-slide .sdfds-3w4 .img-iora-1' => 'border-color: {{VALUE}} !important',
				],
			]
           );
		   
		   	   $this->add_control(
'color_farnam_6',
			[
				'label' => __( 'رنگ کادر تصویر کوچک', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .owl-slide-new-5 .current .item-thumbin' => 'border-color: {{VALUE}} !important',
				],
			]
           );
		   
		   		   	   $this->add_control(
'color_farnam_7',
			[
				'label' => __( 'رنگ کادر ثانیه شمار', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .product-style.htpp.ir-owl.offer-00-1.slide-new-4-slide .iran-pak.in-offer-2.rgggfgff .mini-1-time' => 'border-color: {{VALUE}} !important',
				],
			]
           );
		   
		      		   	   $this->add_control(
'color_farnam_8',
			[
				'label' => __( 'رنگ متن ثانیه شمار', 'plugin-domain' ),
				'type' => Controls_Manager::COLOR,
			
				'selectors' => [
					'{{WRAPPER}} .product-style.htpp.ir-owl.offer-00-1.slide-new-4-slide .iran-pak.in-offer-2.rgggfgff .mini-1-time' => 'color: {{VALUE}} !important',
				],
			]
           );
		   
		   $this->add_responsive_control(
                        'farnamborder1',
                        [
                            'label' => esc_html__( 'گردی دور اسلایدر', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .product-style.htpp.ir-owl.offer-00-1.slide-new-4-slide' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );

  $this->add_responsive_control(
                        'farnamborder2',
                        [
                            'label' => esc_html__( 'گردی دور درصد تخفیف', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .darsad-new-mank' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );
					
				  $this->add_responsive_control(
                        'farnamborder3',
                        [
                            'label' => esc_html__( 'گردی کادر تصویر بزرگ', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .product-style.htpp.ir-owl.offer-00-1.slide-new-4-slide .sdfds-3w4 .img-iora-1' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );
						
							  $this->add_responsive_control(
                        'farnamborder4',
                        [
                            'label' => esc_html__( 'گردی کادر تصویر کوچک', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} #thumbs .item-thumbin' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );
					
								  $this->add_responsive_control(
                        'farnamborder5',
                        [
                            'label' => esc_html__( 'گردی دور تعداد فروش', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .outofstock-new-2' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );
					
					
							  $this->add_responsive_control(
                        'farnamborder6',
                        [
                            'label' => esc_html__( 'گردی تایمر', 'woolentor' ),
                            'type' => Controls_Manager::DIMENSIONS,
                            'selectors' => [
                                '{{WRAPPER}} .time1' => 'border-radius: {{TOP}}px {{RIGHT}}px {{BOTTOM}}px {{LEFT}}px !important;',
                            ],
                        ]
                    );
					
					
        $this->end_controls_section();


          



    }

    protected function render( $instance = [] ) {

        $settings           = $this->get_settings_for_display();
        $product_type       = $this->get_settings_for_display('woolentor_product_grid_product_filter');
        $per_page           = $this->get_settings_for_display('woolentor_product_grid_products_count');
        $custom_order_ck    = $this->get_settings_for_display('custom_order');
        $orderby            = $this->get_settings_for_display('orderby');
        $order              = $this->get_settings_for_display('order');
        $columns            = $this->get_settings_for_display('woolentor_product_grid_column');
        $rows               = $this->get_settings_for_display('woolentor_product_grid_row');
        $tabuniqid          = $this->get_id();
        $proslider          = $this->get_settings_for_display('proslider');
        $producttab          = $this->get_settings_for_display('producttab');

        $is_rtl = is_rtl();
        $direction = $is_rtl ? 'rtl' : 'ltr';
        $slider_settings = [
  
        ];

        $slider_responsive_settings = [
     

        ];

        $slider_settings = array_merge($slider_settings, $slider_responsive_settings);

        // WooCommerce Category
        $args = array(
            'post_type'             => 'product',
            'post_status'           => 'publish',
            'ignore_sticky_posts'   => 1,
            'posts_per_page'        => $per_page,
        );

        switch( $product_type ){

                case 'sale':
  $args['meta_key']   = '_sale_price';
                $args['orderby']    = 'meta_value_num';
                $args['order']      = 'desc';
            break;

            case 'featured':
                $args['tax_query'][] = array(
                    'taxonomy' => 'product_visibility',
                    'field'    => 'name',
                    'terms'    => 'featured',
                    'operator' => 'IN',
                );
            break;

            case 'best_selling':
                $args['meta_key']   = 'total_sales';
                $args['orderby']    = 'meta_value_num';
                $args['order']      = 'desc';
            break;

            case 'top_rated': 
                $args['meta_key']   = '_wc_average_rating';
                $args['orderby']    = 'meta_value_num';
                $args['order']      = 'desc';          
            break;

            case 'mixed_order':
                $args['orderby']    = 'rand';
            break;

            default: /* Recent */
                $args['orderby']    = 'date';
                $args['order']      = 'desc';
            break;
        }

        // Custom Order
        if( $custom_order_ck == 'yes' ){
            $args['orderby'] = $orderby;
            $args['order'] = $order;
        }

        $get_product_categories = $settings['woolentor_product_grid_categories']; // get custom field value
        $product_cats = str_replace(' ', '', $get_product_categories);

        if ( "0" != $get_product_categories) {
            if( is_array($product_cats) && count($product_cats) > 0 ){
                $field_name = is_numeric($product_cats[0])?'term_id':'slug';
                $args['tax_query'] = array(
                    array(
                        'taxonomy' => 'product_cat',
                        'terms' => $product_cats,
                        'field' => $field_name,
                        'include_children' => false
                    )
                );
            }
        }

        $products = new \WP_Query( $args );

        $tabmenu = 'yes';

        if( ($proslider == 'yes') && ( $producttab != 'yes' ) ){
            $collumval = 'slide-item ht-col-xs-12';
        }else{
            $collumval = 'product-list';
            if( $columns !='' ){
                if( $columns == 5){
                    $collumval = 'product-list';
                }else{
                    $colwidth = round(12/$columns);
                    $collumval = 'ht-col-lg-'.$colwidth.'product-list';
                }
            }
        }

        ?>
          
        <div class="product-style htpp ir-owl offer-00-1 slide-new-4-slide">

            <?php if ( $producttab == 'yes' ) { ?>
                <div class="product-tab-list ht-text-center">
  
                    </ul>
                </div>
            <?php }; ?>

            <?php if( is_array( $product_cats ) && (count( $product_cats ) > 0) && ( $producttab == 'yes' ) ): ?>
                
            <?php
                $j=0;
                foreach( $product_cats as $cats ):
                    $j++;
                    $field_name = is_numeric($product_cats[0])?'term_id':'slug';
                    $args['tax_query'] = array(
                        array(
                            'taxonomy' => 'product_cat',
                            'terms' => $cats,
                            'field' => $field_name,
                            'include_children' => false
                        )
                    );
                    $products = new \WP_Query( $args );
                    ?>
                
                <?php endforeach;?>

            <?php else:?>
                <div class="ht-row ertert">
                                  <script>
				 $(document).ready(function() {
  var bigimage = $("#big");
  var thumbs = $("#thumbs");
  //var totalslides = 10;
  var syncedSecondary = true;

  bigimage
    .owlCarousel({
    items: 1,
	  autoplay:true,
    autoplayTimeout:7000,
    autoplayHoverPause:true,
	rtl: true,
    nav: false,
    dots: false,
    loop: true,
    responsiveRefreshRate: 200,
    navText: [
      '<i class="fa fa-arrow-left" aria-hidden="true"></i>',
      '<i class="fa fa-arrow-right" aria-hidden="true"></i>'
    ]
  })
    .on("changed.owl.carousel", syncPosition);

  thumbs
    .on("initialized.owl.carousel", function() {
    thumbs
      .find(".owl-item")
      .eq(0)
      .addClass("current");
  })
    .owlCarousel({
    items: 6,
    dots: true,
    nav: true,
    navText: [
      '<i class="fa fa-arrow-left" aria-hidden="true"></i>',
      '<i class="fa fa-arrow-right" aria-hidden="true"></i>'
    ],
    smartSpeed: 200,
    slideSpeed: 500,
    slideBy: 6,
    responsiveRefreshRate: 100
  })
    .on("changed.owl.carousel", syncPosition2);

  function syncPosition(el) {
    //if loop is set to false, then you have to uncomment the next line
    //var current = el.item.index;

    //to disable loop, comment this block
    var count = el.item.count - 1;
    var current = Math.round(el.item.index - el.item.count / 2 - 0.5);

    if (current < 0) {
      current = count;
    }
    if (current > count) {
      current = 0;
    }
    //to this
    thumbs
      .find(".owl-item")
      .removeClass("current")
      .eq(current)
      .addClass("current");
    var onscreen = thumbs.find(".owl-item.active").length - 1;
    var start = thumbs
    .find(".owl-item.active")
    .first()
    .index();
    var end = thumbs
    .find(".owl-item.active")
    .last()
    .index();

    if (current > end) {
      thumbs.data("owl.carousel").to(current, 100, true);
    }
    if (current < start) {
      thumbs.data("owl.carousel").to(current - onscreen, 100, true);
    }
  }

  function syncPosition2(el) {
    if (syncedSecondary) {
      var number = el.item.index;
      bigimage.data("owl.carousel").to(number, 100, true);
    }
  }

  thumbs.on("click", ".owl-item", function(e) {
    e.preventDefault();
    var number = $(this).index();
    bigimage.data("owl.carousel").to(number, 300, true);
  });
});

</script>
   <div id="big" class="owl-carousel owl-theme owl-100-darsad">

                        <div class="<?php echo esc_attr( $collumval );?>">
                            <?php
                                $k=1;
                                if( $products->have_posts() ):
                                    while( $products->have_posts() ): $products->the_post();
                            ?>
<div class="slide-13-ded slide-offer-3-three">
<div class="sdfds-3w4">
<a href="<?php the_permalink(); ?>">


				 <?php if ( 'yes' === $settings['farnamoneshow3'] ) { ?>

<?php global $product; if( $product->is_on_sale() ) { ?>

<span class="darsad-new-mank">
	<?php echo apply_filters( 'woocommerce_sale_flashtwo' , $product ); ?>


</span>
<?php } ?>
<?php } ?>
<div class="img-iora-1">
  	<?php the_post_thumbnail('woocommerce_thumbnail'); ?>

	</div>
	
	</a>
				 <?php if ( 'yes' === $settings['farnamoneshow6'] ) { ?>


 <?php 
		   
		    global $product;
		   
		   
		   global $post;
								if(  $product->is_on_sale() && $product->is_type('variable')){
					

	

							
		 
    if( $product->is_type('variable') ){
        $default_attributes = $product->get_default_attributes();
        foreach($product->get_available_variations() as $variation_values ){
            foreach($variation_values['attributes'] as $key => $attribute_value ){
                $attribute_name = str_replace( 'attribute_', '', $key );
                $default_value = $product->get_variation_default_attribute($attribute_name);
                if( $default_value == $attribute_value ){
                    $is_default_variation = true;
                } else {
                    $is_default_variation = false;
                    break; // Stop this loop to start next main lopp
                }
            }
            if( $is_default_variation ){
                $variation_id = $variation_values['variation_id'];
                break; // Stop the main loop
		
            }
        }

global $product;

if ($product->is_on_sale() && $product->is_type('variable') ) {
    $default_variation_id = 0;
    $default_variation = $product->get_available_variations()[0];
    if (is_a($default_variation, 'WC_Product_Variation')) {
        $variation_id = $default_variation->get_variation_id_by_sku($default_variation->get_sku());
    }
	
if ($product->is_on_sale() && $product->is_type('variable')) {
    global $product;

    $variation_id = null;

    if ($product->is_type('variable')) {
        $default_attributes = $product->get_default_attributes();
        foreach ($product->get_available_variations() as
 
$variation_values) {
            foreach ($variation_values['attributes'] as
 
$key => $attribute_value) {
                $attribute_name = str_replace('attribute_', '', $key);
                $default_value = $product->get_variation_default_attribute($attribute_name);

                if ($default_value == $attribute_value) {
                    $variation_id = $variation_values['variation_id'];
                    break 2; // Exit both loops
                }
            }
        }
    }

    if ($variation_id) {
        $sale_end_date = get_post_meta($variation_id, '_sale_price_dates_to', true);
    } else {
        // Variation is not selected, so don't display anything
    }
}
    if (empty($sale_end_date) || $sale_end_date < current_time('timestamp')) {
								        // چیزی نمایش داده نمیشود
    } else {
        // The discount is still active
 

        // Now we get the default variation data
        if( $is_default_variation ){
            // Raw output of available "default" variation details data
		 $meta_date = get_post_meta( $variation_id, '_sale_price_dates_to', true );
					if( empty( $meta_date ) ){
																//	echo esc_html_e( 'زمان بندی پیشنهاد ویژه تعیین نشده است!', 'studiare' );
															}
          	else{
					$date  = date( 'm/d/Y 23:59', $meta_date );//echo $date;
			
			
			?>



	<div class="iran-pak in-offer-2 rgggfgff timer-hazfi99">
<div id="fm4<?php echo get_the_ID(); ?>"></div>
<script type="text/javascript">
 $('#fm4<?php echo get_the_ID(); ?>').countdown('<?php echo esc_attr( $date ) ?>', function(event) {
  var $this = $(this).html(event.strftime(''
    + '<div class="timer-wrapper"><div class="time1">%D</div><span class="text32">روز</span></div>'
    + '<div class="timer-wrapper"><div class="time1">%H</div><span class="text32">ساعت</span></div>'
    + '<div class="timer-wrapper"><div class="time1">%M</div><span class="text32">دقیقه</span></div>'
    + '<div class="timer-wrapper"><div class="time1 mini-1-time">%S</div><span class="text32">ثانیه</span></div>'
));
});
</script>

</div>

<?php
          	}		

   


								}
								else {
								        // چیزی نمایش داده نمیشود
	
									
								}
			}
					   }
}			
									}
								
								else {
									
							



  $sales_price_to = get_post_meta($post->ID, '_sale_price_dates_to', true);
															if( empty( $meta_date ) ){
																//	echo esc_html_e( 'زمان بندی پیشنهاد ویژه تعیین نشده است!', '' );
															}
					else{
					// $date  = date_i18n( 'm/d/Y', $meta_date );
					}
					
					
					
 $sale_end_date = get_post_meta($product->get_id(), '_sale_price_dates_to', true);
  if ($sale_end_date < current_time('timestamp')) {
    // تخفیف به پایان رسیده است، بنابراین تایمر را نمایش ندهید
  } else {
	  global $post;


					$date  = date( 'm/d/Y 23:59', $sales_price_to );//echo $date;


?>
	<div class="iran-pak in-offer-2 rgggfgff">
<div id="fm4<?php echo get_the_ID(); ?>"></div>
<script type="text/javascript">
 $('#fm4<?php echo get_the_ID(); ?>').countdown('<?php echo do_shortcode( '[display_end_date]' ); ?> 23:59', function(event) {
  var $this = $(this).html(event.strftime(''
    + '<div class="timer-wrapper"><div class="time1">%D</div><span class="text32">روز</span></div>'
    + '<div class="timer-wrapper"><div class="time1">%H</div><span class="text32">ساعت</span></div>'
    + '<div class="timer-wrapper"><div class="time1">%M</div><span class="text32">دقیقه</span></div>'
    + '<div class="timer-wrapper"><div class="time1 mini-1-time">%S</div><span class="text32">ثانیه</span></div>'
));
});
</script>

</div>
<?php
								}}
								

  
?><?php } ?>

</div>

<div class="nesf-50">
<a href="<?php the_permalink(); ?>">

<h3> <?php the_title(); ?>   

 <?php if ( 'yes' === $settings['farnamoneshow1'] ) { ?>

				<span class="outofstock-new-2"> <?php global $product;
$units_sold = get_post_meta( $product->get_id(), 'total_sales', true );
echo ''. sprintf( __( '%s', 'woocommerce' ), $units_sold ).''; ?>  فروش</span>
				
				<?php } ?>
				</h3>
				
				 <?php if ( 'yes' === $settings['farnamoneshow2'] ) { ?>

  <?php $option_meta = rwmb_meta('title-1'); if (!empty($option_meta)) { ?>
<p><?php echo $option_meta; ?></p>

<?php } ?>
<?php } ?>

</a>

				 <?php if ( 'yes' === $settings['farnamoneshow4'] ) { ?>

<div class="price-iran-offer-3">
<?php global $product; echo $product->get_price_html(); ?>  <?php
				do_action( 'woocommerce_namojood' );
	?>
</div><?php } ?>

				 <?php if ( 'yes' === $settings['farnamoneshow5'] ) { ?>

<?php $option_meta = rwmb_meta('wysiwyg_1'); if (!empty($option_meta)) { ?>


<div class="vijegi fff333ff">
<?php echo $option_meta; ?>

</div>
<?php } ?>
<?php } ?>




</div>


</div>

                           <?php if ($k % $rows == 0 && ($products->post_count != $k)) { ?>
                            </div>
							
                            <div class="<?php echo esc_attr($collumval );?>">
                                <?php } $k++; endwhile; wp_reset_postdata();  endif; ?>
								
                            </div>
							
                    <?php if( $proslider == 'yes' ){ echo '</div>';} ?>
                </div>       </div>
            <?php endif;?>
 <?php if( is_array( $product_cats ) && (count( $product_cats ) > 0) && ( $producttab == 'yes' ) ): ?>
                
            <?php
                $j=0;
                foreach( $product_cats as $cats ):
                    $j++;
                    $field_name = is_numeric($product_cats[0])?'term_id':'slug';
                    $args['tax_query'] = array(
                        array(
                            'taxonomy' => 'product_cat',
                            'terms' => $cats,
                            'field' => $field_name,
                            'include_children' => false
                        )
                    );
                    $products = new \WP_Query( $args );
                    ?>
                
                <?php endforeach;?>

            <?php else:?>


<div id="thumbs" class="owl-carousel owl-theme owl-slide-new-5">

                        <div class="<?php echo esc_attr( $collumval );?>">
                            <?php
                                $k=1;
                                if( $products->have_posts() ):
                                    while( $products->have_posts() ): $products->the_post();
                            ?>
											 <?php if ( 'yes' === $settings['farnamoneshow7'] ) { ?>

  <div class="item-thumbin slide-offer-4-slide-new-s">
  	<?php the_post_thumbnail('thumbnail'); ?>
	
 </div><?php } ?>
</div>


 
                           <?php if ($k % $rows == 0 && ($products->post_count != $k)) { ?>
                         
							
                            <div class="<?php echo esc_attr($collumval );?>">
                                <?php } $k++; endwhile; wp_reset_postdata();  endif; ?>
								
                            </div>
							
                    <?php if( $proslider == 'yes' ){ echo '</div>';} ?>
    <?php endif;?>
        </div>  


        <?php

    }


}



