<?php $kproduct = get_query_var('kproduct'); ?>
<?php $woo_currency = get_woocommerce_currency_symbol(); ?>

<div class="product-new-one position-relative bg-white d-flex flex-column">
<?php if ( $kproduct['kaveh_custom']['is_on_sale'] === true ): ?>
<div class="offer d-flex flex-column position-absolute align-items-center justify-content-center">
<i class="icon-discount-2 d-flex align-items-center justify-content-center"></i>
<?php if($kproduct['kaveh_custom']['product_type'] === 'variable'): ?>
    <?php echo (int)(( ( (float)$kproduct['kaveh_custom']['min_regular_price'] - (float)$kproduct['kaveh_custom']['min_sale_price'] ) / (float)$kproduct['kaveh_custom']['min_regular_price'] ) * 100); ?><?php echo ' '.'%'; ?>
<?php elseif($kproduct['kaveh_custom']['product_type'] === 'simple'): ?>
    <?php echo (int)(( ( (float)$kproduct['kaveh_custom']['normal_price'] - (float)$kproduct['kaveh_custom']['sale_price'] ) / (float)$kproduct['kaveh_custom']['normal_price'] ) * 100); ?><?php echo ' '.'%'; ?>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="image">
<a href="<?php echo $kproduct['link'] ?>" class="d-block">
<img src="<?php echo $kproduct['kaveh_custom']['thumbnail_url'] ?>" alt="product" width="161" height="161"
class="d-block mx-auto">
</a>
</div>
<h2 class="title overflow-hidden">
<a href="<?php echo $kproduct['link'] ?>">  <?php echo $kproduct['title']['rendered']; ?>  </a>
</h2>
<div class="d-flex align-items-center justify-content-between mt-auto">

<?php if($kproduct['kaveh_custom']['product_type'] === 'variable'): ?>
<div class="offer-price">
<div class="price">
<span> 
<?php if($kproduct['kaveh_custom']['min_regular_price'] !== $kproduct['kaveh_custom']['max_regular_price']): ?>
    <?php if(!empty($kproduct['kaveh_custom']['min_regular_price'])): ?>
    <?php echo number_format($kproduct['kaveh_custom']['min_regular_price'], 0, '.', ',') . ' - ' . number_format($kproduct['kaveh_custom']['max_regular_price'], 0, '.', ',') . ' '; ?>
<?php endif; ?>
<?php else: ?>
    <?php if(!empty($kproduct['kaveh_custom']['min_regular_price'])): ?>
    <?php echo number_format($kproduct['kaveh_custom']['min_regular_price'], 0, '.', ',')  . ' '; ?>
<?php endif; ?>
<?php endif; ?> 
</span>
<?php echo $woo_currency; ?>
</div>
</div>
<?php else: ?>
<?php if ( $kproduct['kaveh_custom']['is_on_sale'] === true ): ?>
<div class="offer-price">
<del> <?php if(!empty($kproduct['kaveh_custom']['normal_price'])): ?>
<?php echo number_format($kproduct['kaveh_custom']['normal_price'], 0, '.', ','); ?>
<?php endif; ?>  </del>
<div class="price">
<span> <?php if(!empty($kproduct['kaveh_custom']['sale_price'])): ?>
    <?php echo number_format($kproduct['kaveh_custom']['sale_price'], 0, '.', ','); ?>
<?php endif; ?> </span>
<?php echo $woo_currency; ?>
</div>
</div>
<?php else: ?>
<div class="offer-price">
<div class="price">
<span> <?php if(!empty($kproduct['kaveh_custom']['normal_price'])): ?>
<?php echo number_format($kproduct['kaveh_custom']['normal_price'], 0, '.', ','); ?>
<?php endif; ?>  </span>
<?php echo $woo_currency; ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if($kproduct['kaveh_custom']['product_type'] === 'variable'): ?>
<a href="<?php echo $kproduct['link'] ?>"  class="add-to-cart d-flex align-items-center justify-content-center">
<i class="icon-shoppin-bag"></i>
</a>
<?php else: ?>
<a href="#" name="add-to-cart" value="<?php echo $kproduct['id']; ?>" class="add-to-cart d-flex align-items-center justify-content-center single_add_to_cart_button">
<i class="icon-shoppin-bag"></i>
</a>
<?php endif; ?>
</div>

</div>