{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
{% set variant = product|sylius_resolve_variant %}
{% set hasDiscount = variant ? variant|sylius_has_discount({'channel': sylius.channel}) : null %}
{% set tagAttributes = product.attributesByLocale(app.request.locale, app.request.defaultLocale, sylius_base_locale)|filter(attribute => attribute.code == 'tag1' or attribute.code == 'tag2')|sort_by('attribute.position') %}
{% set discount = variant ? money.calculateDiscount(variant, {'channel': sylius.channel, 'zone': sylius.channel.defaultTaxZone}) : null %}
{% set tier_prices = variant ? variant.getTierPricesForChannel(sylius.channel, sylius.customer) : null %}
{% set enabledVariants = product.enabledVariants %}
<div class="product{% if h_100 is defined and h_100 %} h-100{% endif %}" {{ sylius_test_html_attribute('product') }}>
<div class="product-image-wrap">
<a class="product-image-link" href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}">
{% if hasDiscount %}
<span class="labels-wrap">
<span class="discount-content">
<span class="label">-{{ discount }}%</span>
</span>
</span>
{% endif %}
{% include '@SyliusShop/Product/_mainImage.html.twig' with {'product': product, 'class': 'card-img-top'} %}
{% if product.labels %}
<span class="labels-bottom-wrap">
<span class="labels-content">
{% for label in product.labels %}
{% if label.code != 'top_all_categories' %}
<span class="label {{ label.code -}}">{{- label.name -}}</span>
{% endif %}
{% endfor %}
</span>
</span>
{% endif %}
</a>
</div>
<div class="product-content">
<h6 class="product-name fw-medium" {{ sylius_test_html_attribute('product-name', product.name) }}>
<a class="link-heading stretched-link" href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}">{{ product.name }}</a>
</h6>
<div class="product-description">
{% if product.shortDescription %}
{{ product.shortDescription|striptags|unescape|u.truncate(100, '...', false) }}
{% else %}
{{ product.description|striptags|unescape|u.truncate(100, '...', false) }}
{% endif %}
</div>
</div>
<div class="product-bottom">
{% if not product.enabledVariants.empty() %}
<div class="product-price-wrap">
{% if product.minPrice %}
<span class="text-nowrap">
<span class="product-price-from cfs-8">{{ 'app.ui.price_from'|trans }}</span>
<span class="product-price min-price cfs-5" {{ sylius_test_html_attribute('product-price') }}>{{ money.convertAndFormatSpecial(product.minPrice, {'divisor': 100000, 'scale': 3 }) }}</span>
</span>
{% if product.maxPrice %}
<span class="text-nowrap">
<span class="product-price-from cfs-8">{{ 'app.ui.price_to'|trans }}</span>
<span class="product-price min-price cfs-5" {{ sylius_test_html_attribute('product-price') }}>{{ money.convertAndFormatSpecial(product.maxPrice, {'divisor': 100000, 'scale': 3 }) }}</span>
</span>
{% endif %}
{% elseif enabledVariants|length == 1 %}
{% if hasDiscount %}<span class="product-original-price cfs-8">{{ money.calculateOriginalPriceWithoutTax(variant, {'divisor': 100000, 'scale': 3, 'channel': sylius.channel, 'zone': sylius.channel.defaultTaxZone}) }}</span>{% endif %}
<span class="product-price cfs-5" {{ sylius_test_html_attribute('product-price') }}>{{ money.calculatePrice(product|sylius_resolve_variant) }}</span>
{% endif %}
</div>
{% endif %}
{% if product.minQuantity %}
<div class="product-min-quantity cfs-9">{{ 'app.product_box.min_qty'|trans({ '%qty%': product.minQuantity }) }}</div>
{% endif %}
</div>
</div>