<?php
/**
 * @see 	    https://docs.woocommerce.com/document/template-structure/
 * @author 		WooThemes
 * @package 	WooCommerce/Templates
 * @version     9.4.0
 */

defined( 'ABSPATH' ) || exit;

global $product;

// Ensure visibility.
if ( empty( $product ) || ! $product->is_visible() ) {
	return;
}
?>

<div class="product-list-45645654 ns-402-1">
 <div class="ps1-1">

 <div class="product-list-1 ps1 product-99-11-00">
 
 
			
			
           <?php 
		   
		   
		   
		   
		   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="sanieaval">
 <div class="iran-pak in-offer-2 seven-ffer-iranin newsanie timer-hazfi9">
 <span class="takhfif-vije-0900"> تخفیف ویژه </span>
<div class="offer-991400-jj-ffds" id="gf<?php echo get_the_ID(); ?>"></div>
<script type="text/javascript">
 $('#gf<?php echo get_the_ID(); ?>').countdown('<?php echo esc_attr( $date ) ?>', function(event) {
  var $this = $(this).html(event.strftime(''
    + '%D :'
    + '%H :'
    + '%M :'
    + '<span class="sanie-54">%S</span>'
));
});
</script>
</div>
</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="sanieaval">
 <div class="iran-pak in-offer-2 seven-ffer-iranin newsanie timer-hazfi9">
 <span class="takhfif-vije-0900"> تخفیف ویژه </span>
<div class="offer-991400-jj-ffds" id="gf<?php echo get_the_ID(); ?>"></div>
<script type="text/javascript">
 $('#gf<?php echo get_the_ID(); ?>').countdown('<?php echo esc_attr( $date ) ?>', function(event) {
  var $this = $(this).html(event.strftime(''
    + '%D :'
    + '%H :'
    + '%M :'
    + '<span class="sanie-54">%S</span>'
));
});
</script>
</div>
</div><?php
								}}
								

  
?>

			
			

	
					
<?php if ( $product->is_on_sale() ) : ?>


<div class="mizan">
	<?php echo apply_filters( 'woocommerce_sale_flashtwo', $post, $product ); ?>


</div>
	<?php
endif;
?>
<a href="<?php the_permalink(); ?>">
	<?php the_post_thumbnail('woocommerce_thumbnail'); ?>
<h3><?php the_title(); ?></h3>
</a>
<div class="rangbandi-style-1400">

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

<?php
    
    
$values = rwmb_meta("colorin1");
//print_r($values);
//if(!empty($values)){
    //print_r($values);
foreach ( $values as $value ) {
                    echo '<div class="rangi-dayere-342" style="background: ';
print_r( $value );	   
	
                    echo ';"></div>';

}
//}
?><?php } ?>
</div>
<div class="list-meta">
<span class="list-meta-1 regtretert">
<div class="box-rating">
 <?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

global $product;

if ( 'no' === get_option( 'woocommerce_enable_review_rating' ) ) {
	return;
}

$rating_count = $product->get_rating_count();
$review_count = $product->get_review_count();
$average      = $product->get_average_rating();

if ( $rating_count > 0 ) : ?>

	<div class="woocommerce-product-rating">
		<?php echo wc_get_rating_html( $average, $rating_count ); ?>
		<?php if ( comments_open() ) : ?><?php endif ?>
	</div>

<?php endif; ?>

</div></span>
<span class="list-meta-2 d5456546f">
<?php echo $product->get_price_html(); ?>
 <?php
				do_action( 'woocommerce_namojood' );
	?>
	
</span>
</div>
<div class="risk-meta rthrth44444">
<div class="liningk bazsho1">
<div class="tooltiping">
علاقه مندی به محصول</div>
<?php echo do_shortcode("[yith_wcwl_add_to_wishlist]"); ?>
</div>
<span class="cpmare-wefew bazsho1">
<div class="tooltiping">
مقایسه این محصول</div>
<?php echo do_shortcode( '[woosc id=' . get_the_ID() . ']' ); ?>
</span>

<span class="cpmare-wefew-1 bazsho1">
<div class="tooltiping">
مشاهده سریع محصول</div>
<?php echo do_shortcode( '[woosq id=' . get_the_ID() . ']' ); ?>
</span>


<div class="gtgeg45yt4yt4">
	
	
	<?php

	do_action( 'woocommerce_after_shop_loop_item' );
	?>

</div>



</div>
</div></div></div>
