<?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
 */

defined('ABSPATH') || exit;

global $product;

// Ensure visibility.
if (empty($product) || ! $product->is_visible()) {
    return;
}
?>
<div class="shop-page-list-tab-wrapper">
    <div class="container">
        <div class="row shop-list-viwe-row shop-products-card">
            <div class="col-lg-12 col-xl-4">
                <div class="products-card-img">
                    <a href="<?php the_permalink(); ?>">
                        <?php the_post_thumbnail('full', array('class' => 'img-fluid')); ?>
                    </a>
                    <?php
                    if ($product->is_on_sale()) {
                        $regular_price = $product->get_regular_price();
                        $sale_price = $product->get_sale_price();
                        if (!empty($regular_price) && !empty($sale_price)) {
                            $percentage = round((($regular_price - $sale_price) / $regular_price) * 100);
                            echo '<div class="product-tag">' . '-' . esc_html($percentage) . '% ' . esc_html__('Off', 'glamer') . '</div>';
                        }
                    }
                    ?>
                </div>
            </div>

            <div class="col-lg-12 col-xl-8">
                <div class="products-content-list-wrap">
                    <div class="glamer-product-rating">
                        <?php woocommerce_template_single_rating(); ?>
                    </div>
                    <h4 class="product-title underline-anim-wrap"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                    <div class="product-price"><?php woocommerce_template_loop_price(); ?></div>
                    <div class="glamer-product-description">
                        <?php echo  wp_trim_words($product->get_description(), 30, '...') ?>
                    </div>
                    <div class="glamer-product-cart-and-quantity"><?php woocommerce_template_single_add_to_cart(); ?></div>
                    <?php woocommerce_template_single_meta(); ?>
                </div>
            </div>
        </div>
    </div>
</div>