<?php $kproduct = get_query_var('kproduct'); ?>
<?php $woo_currency = get_woocommerce_currency_symbol(); ?>
<div class="product-eight">
<div class="image">
<?php if ( is_plugin_active( 'woo-smart-compare/wpc-smart-compare.php' ) ): ?>
<?php echo do_shortcode( '[woosc id="".<?php echo get_the_ID(); ?>.""]' );  ?>
<?php endif; ?>
<a href="<?php echo $kproduct['link'] ?>">
<img src="<?php echo $kproduct['kaveh_custom']['thumbnail_url'] ?>" alt="<?php echo $kproduct['title']['rendered']; ?>" />
</a>
<?php if ( $kproduct['kaveh_custom']['is_on_sale'] === true ): ?>
<div class="offer">
<?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>
<div class="content">
<h2 class="product-name">
<a href="<?php echo $kproduct['link'] ?>"> <?php echo $kproduct['title']['rendered']; ?></a>
</h2>
<div class="d-flex align-items-center justify-content-start">
<?php if($kproduct['kaveh_custom']['product_stock_status'] !== 'outofstock'): ?>
<?php if($kproduct['kaveh_custom']['product_type'] !== 'variable'): ?>
<?php if ( $kproduct['kaveh_custom']['is_on_sale'] === true ): ?>
<div class="price">
<del>
<?php if(!empty($kproduct['kaveh_custom']['normal_price'])): ?>
<?php echo number_format($kproduct['kaveh_custom']['normal_price'], 0, '.', ','); ?>
<?php endif; ?>
</del>
<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>
<?php else: ?>
<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>
<?php endif ?>
<?php else: ?>
<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>
<?php endif; ?>
<?php endif; ?>
<?php if($kproduct['kaveh_custom']['product_stock_status'] !== 'outofstock'): ?>
<?php if($kproduct['kaveh_custom']['product_type'] !== 'variable'): ?>
  <a type="submit" name="add-to-cart" value="<?php echo $kproduct['id']; ?>" class="btn btn-success-2 shadow-none single_add_to_cart_button"><span> + خرید </span></a>
<?php endif; ?>
<?php else: ?>
<span class="btn btn-notstock rounded-pill"> ناموجود</span>
<?php endif; ?>
</div>
<a href="<?php echo $kproduct['link'] ?>" class="btn btn-secondary rounded-pill"> مشاهده محصول </a>
</div>
</div>
