<?php $kproduct = get_query_var('kproduct'); ?>
<?php $woo_currency = get_woocommerce_currency_symbol(); ?>
<div class="product-seven">
<h2 class="product-name">
<a href="<?php echo $kproduct['link'] ?>"> <?php echo $kproduct['title']['rendered']; ?></a>
</h2>
<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>
</div>
<?php if($kproduct['kaveh_custom']['product_stock_status'] !== 'outofstock'): ?>
<?php if($kproduct['kaveh_custom']['product_type'] !== 'variable'): ?>
<?php if(!empty($sale_price) ): ?>
<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; ?>
<div class="d-flex align-items-center justify-content-between">
<?php if($kproduct['kaveh_custom']['product_stock_status'] !== 'outofstock'): ?>
<?php if($kproduct['kaveh_custom']['product_type'] !== 'variable'): ?>
<a href="<?php echo $kproduct['link'] ?>" class="position-absolute bottom-0 start-0 ms-3 ms-md-3 ms-lg-3 ms-xl-3 ms-xxl-4 mb-3 btn btn-success-2 shadow-none"> + خرید </a>
<?php else: ?>
<a href="<?php echo $kproduct['link'] ?>" class="position-absolute bottom-0 start-0 ms-3 ms-md-3 ms-lg-3 ms-xl-3 ms-xxl-4 mb-3 btn btn-success-2 shadow-none"> مشاهده گزینه ها </a>
<?php endif; ?>
<?php else: ?>
<div class="price w-100 na6">
<h6 class="mx-auto my-1 nam-6">ناموجود</h6>
</div>
<?php endif; ?>
<?php if ( $kproduct['kaveh_custom']['is_on_sale'] === true ): ?>
<span class="position-absolute bottom-0 end-0 me-3 me-md-3 me-lg-3 me-xl-3 me-xxl-4 mb-3 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; ?>
</span>
<?php endif; ?>
</div>
<a href="<?php echo $kproduct['link'] ?>" class="btn btn-danger-2"> مشاهده و بررسی محصول </a>
</div>
