<?php
/**
 * The template for displaying product content within loops
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/content-product.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see     https://docs.woocommerce.com/document/template-structure/
 * @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 inraznist">
<div class="product-list-1 ps3 jjj-112 nevis-3-demo-3 inraze">

    <?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
								}}
								

  
?>

<a href="<?php the_permalink(); ?>">
<?php if ( $product->is_on_sale() ) : ?>



  <div class="takhfif-aram">
  <div class="radial-progress"><svg height="45" width="45"> <circle stroke="#FFA000" fill="transparent" r="17" cy="20" stroke-width="2" cx="24"></circle> </svg><span class="span-k-k">	<?php echo apply_filters( 'woocommerce_sale_flashtwo' , $product ); ?>

</span></div>
  
  </div>
	<?php
endif;
?>
	<?php the_post_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="risk-meta hoversho-www1 ffgt544 demo-3-3dd">
<div class="liningk fg455 bazsho1">
<div class="tooltiping">
علاقه مندی به محصول</div>
<?php echo do_shortcode("[yith_wcwl_add_to_wishlist]"); ?>
</div>
<span class="cpmare-wefew fg455 bazsho1">
<div class="tooltiping">
مقایسه این محصول</div>
<?php echo do_shortcode( '[woosc id=' . get_the_ID() . ']' ); ?>
</span>

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

</div>
<div class="list-meta meta-demo-3">
<span >
<?php global $product;
$units_sold = get_post_meta( $product->get_id(), 'total_sales', true ); ?>
</span>
<span class="list-meta-2">





<div class="min-mike"><i class="mdi mdi-credit-card cardine"></i>
<?php echo $product->get_price_html(); ?></div>

</span>
</div>

</div></div>
