{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
{% set variant = product|sylius_resolve_variant %}
{% set channelpricing = null %}
{% if variant is not null %}
{% set channelpricing = variant.getChannelPricingForChannel(sylius.channel) %}
{% set percentage = channelpricing.getDiscountedPercentage %}
{% endif %}
<div class="articleBit h-100" {{ sylius_test_html_attribute('product') }}>
<div class="bg-art-w h-100 d-flex flex-column">
<div class="articleBit-ima flex-grow-1 d-flex align-items-center justify-content-center">
<a href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}">
{% include '@SyliusShop/Product/_mainImage.html.twig' with {'product': product, 'variant': variant, 'class': 'card-img-top_'} %}
</a>
{% if product.callouts is not null %}
{% include "@SetonoSyliusCalloutPlugin/Shop/Product/Callout/_callouts.html.twig" with {'callouts' : product.callouts|setono_callouts} %}
{% endif %}
{% if variant is not null %}
{% if channelpricing.originalPrice > channelpricing.price %}
<div class="picto-promo">
<strong>
<span data-js-product-percentage >
-{{ percentage|round(0) }}%
</span>
</strong>
</div>
{% endif %}
{% endif %}
</div>
<div class="max-art">
<h3 class="articleBit-lib" {{ sylius_test_html_attribute('product-name', product.name) }}><div class="table-lib"><a href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}">{{ product.name }}</a></div></h3>
</div>
<div class="articlebit-detail">
<div class="table-ajout-panier">
<div class="articleBit-prix">
{% if channelpricing and not product.variants.empty() %}
<span class="prix-old" data-js-product-original-price {{ sylius_test_html_attribute('product-price', money.calculatePrice(product|sylius_resolve_variant)) }}>
{% set variant = product|sylius_resolve_variant %}
{% if channelpricing.originalPrice > channelpricing.price %}
{{ money.convertAndFormat(channelpricing.originalPrice)}}
{% endif %}
</span>
{% if channelpricing.price != 0 %}
<strong class="prix-promo" {{ sylius_test_html_attribute('product-price') }}><em class="d-none">{{'app.product.apartirde' |trans}}</em> {{ money.calculatePrice(product|sylius_resolve_variant) }} </strong>
{% endif %}
{% endif %}
</div>
{% if channelpricing and channelpricing.originalPrice > channelpricing.price and channelpricing.discountedPriceEndsAt is not null %}
{% set now = "now"|date("U") %}
{% set endsAt = channelpricing.discountedPriceEndsAt|date("U") %}
{% set diffSeconds = endsAt - now %}
{% set days = (diffSeconds // 86400) %}
{% set hours = ((diffSeconds % 86400) // 3600) %}
{% set minutes = ((diffSeconds % 3600) // 60) %}
{% set seconds = (diffSeconds % 60) %}
{% if diffSeconds > 0 %}
<div class="encart-promo" >
<strong>{{ 'app.product.current_promotion'|trans }} !</strong>
<span>{{ 'app.product.store_at_the_best_price'|trans }}</span>
<div class="timer" data-ends-at="{{ channelpricing.discountedPriceEndsAt|date('c') }}">
<div class="days"><b>{{ days }}</b> {{ 'app.ui.days'|trans }}</div>
<div class="hours"><b>{{ hours }}</b> {{ 'app.ui.hours'|trans }}</div>
<div class="minutes"><b>{{ minutes }}</b> {{ 'app.ui.minutes'|trans }}</div>
<div class="seconds"><b>{{ seconds }}</b> {{ 'app.ui.secondes'|trans }}</div>
</div>
<div class="content-ajout-panier">
<a class="btn-ajout-panier" href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}"> > {{'app.product.detail'|trans}}</a>
</div>
</div>
{% else %}
<div class="content-ajout-panier">
<a class="btn-ajout-panier" href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}"> > {{'app.product.detail'|trans}}</a>
</div>
{% endif %}
{% elseif product.specialOfferEndsAt %}
{% set now = "now"|date("U") %}
{% set endsAt = product.specialOfferEndsAt|date("U") %}
{% set diffSeconds = endsAt - now %}
{% set days = (diffSeconds // 86400) %}
{% set hours = ((diffSeconds % 86400) // 3600) %}
{% set minutes = ((diffSeconds % 3600) // 60) %}
{% set seconds = (diffSeconds % 60) %}
{% if diffSeconds > 0 %}
<div class="special-offer encart-promo" >
<strong>{{ 'app.product.special_offer'|trans }} !</strong>
<div class="timer" data-ends-at="{{ product.specialOfferEndsAt|date('c') }}">
<div class="days"><b>{{ days }}</b> {{ 'app.ui.days'|trans }}</div>
<div class="hours"><b>{{ hours }}</b> {{ 'app.ui.hours'|trans }}</div>
<div class="minutes"><b>{{ minutes }}</b> {{ 'app.ui.minutes'|trans }}</div>
<div class="seconds"><b>{{ seconds }}</b> {{ 'app.ui.secondes'|trans }}</div>
</div>
<div class="content-ajout-panier">
<a class="btn-ajout-panier" href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}"> > {{'app.product.detail'|trans}}</a>
</div>
</div>
{% endif %}
{% else %}
<div class="content-ajout-panier">
<a class="btn-ajout-panier" href="{{ path('sylius_shop_product_show', {'slug': product.slug, '_locale': product.translation.locale}) }}"> > {{'app.product.detail'|trans}}</a>
</div>
{% endif %}
</div>
</div>
</div>
</div>