{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}
{% if product.imagesByType('image_product_main') is not empty %}
{% set source_path = product.imagesByType('image_product_main').first.path %}
{% set path = source_path|imagine_filter('app_product_small_thumbnail_listing') %}
{% elseif product.images.first %}
{% set source_path = product.images.first.path %}
{% set path = source_path|imagine_filter('app_product_small_thumbnail_listing') %}
{% else %}
{% set path = asset('webapic-theme/images/icon-gmap.png') %}
{% endif %}
{% set price = money.calculatePrice(product) %}
{% set originalPrice = money.calculateOriginalPrice(product) %}
<div class="listing1-product-ctn card">
{% include 'partials/block-add-to-wishlist.html.twig' with {'product': product, 'price': price} %}
<a href="{{ path('app_product_variant_show', {'slug': product.slug, 'id': product.id}) }}" class="{% if is_mobile() %}mobile {% else %}desktop{% endif %}">
<div class="img-ctn">
<div class="flag">
{% include 'partials/block-callout.html.twig' with {'callout': product.badge} only %}
{# Octobre Rose #}
{# {{dump(product)}} #}
{# {% if product.optionValues|length > 0 and product.optionValues[0].code == "PL.RO.FU" %}
<img class="lazy oct-rose" src="{{ asset('webapic-theme/images/2024_oct-rose_ruban-listing.svg') }}" alt="Octobre Rose" />
{% else %}
{% include 'partials/block-callout.html.twig' with {'callout': product.badge} only %}
{% endif %} #}
</div>
<div class="img-ctn-content">
<img class="lazyload" data-src="{{ path }}" id="main-image" alt="{{ product.name }}" {{ sylius_test_html_attribute('main-image') }} />
{% set path = '' %}
{% if product.imagesByType('image_product_secondary') is not empty %}
{% set source_path = product.imagesByType('image_product_secondary').first.path %}
{% set path = source_path|imagine_filter('app_product_small_thumbnail_listing_cropped') %}
{% elseif product.imagesByType('image_product_main') is not empty %}
{% set source_path = product.imagesByType('image_product_main').first.path %}
{% set path = source_path|imagine_filter('app_product_small_thumbnail_listing_cropped') %}
{% endif %}
{% if path is not empty %}
<img class="hover lazyload" data-src="{{ path }}" id="main-image" alt="{{ product.name }}" {{ sylius_test_html_attribute('main-image') }} />
{% endif %}
{% if is_mobile() and not is_device('iPad') %}
<button class="mobile"><i class="chevron left icon"></i></button>
<button class="mobile right"><i class="chevron right icon"></i></button>
{% endif %}
{% if not is_device('iPad') %}
{% set cat = '' %}
{% set cat2 = '' %}
{% if product.product.mainTaxon is not null and product.product.mainTaxon.parent is not null %}
{% set cat = product.product.mainTaxon.name %}
{% if product.product.mainTaxon.parent is not null %}
{% set cat2 = product.product.mainTaxon.parent.name %}
{% endif %}
{% endif %}
<div class="add">
<button class="js-add-to-cart" data-url="{{ path('app_cart_add_to_cart_ajax') }}" data-postdata="{{ '{"' ~ product.id ~ '":1}' }}"
data-id="{{ product.id }}" data-name="{{ product.name }}" data-price="{{ price|replace({'€': '',',': '.'}) }}" data-cat="{{ cat }}" data-catdeux="{{ cat2 }}">
<img src="{{ asset('webapic-theme/images/icon-panier.svg') }}" class="ui image addcart" />
{# <img src="{{ asset('webapic-theme/images/loader-spinner.gif') }}" class="ui image loader" /> #}
<div class="loader lds-roller-ctn">
<div class="lds-roller"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
</div>
</button>
</div>
{% endif %}
</div>
</div>
<div class="name">{{ product.name }}</div>
{# {% if price != originalPrice %}
<div class="sylius-product-original-price price" {{ sylius_test_html_attribute('product-original-price') }}><del>{{ originalPrice }}</del></div>
{% endif %} #}
<div class="sylius-product-price price {% if price != originalPrice %}bloc-price-promo{% endif %}" {{ sylius_test_html_attribute('product-price') }}>
{# aa{{ price }}bb{{ originalPrice }} #}
{% if price != originalPrice %}
<div class="ligne-promo">
<span class="original-price">{{ originalPrice }}</span>
{# {% if product.badge is not defined or product.badge != "low_price" %} #}
<span class="percentage">
{{ app_percentage_promo(product|sylius_calculate_original_price({'channel': sylius.channel}), product|sylius_calculate_price({'channel': sylius.channel})) }}
</span>
{# {% endif %} #}
</div>
{% endif %}
{% if product.badge is defined and product.badge is not empty and product.badge == "low_price" %}
{% set pricebarre = money.convertAndFormat(product|sylius_calculate_original_price({'channel': sylius.channel}) * 2) %}
<span class="original-price">{{ pricebarre }}</span>
{% endif %}
{% if product.product.conditioning == 'per_meter_each_0_5_meter' %}
{{ price }}/m
{% elseif product.product.conditioning == 'card_kdo_per_euros_each_10_euros' %}
{{ 'app.front.listing.product.from'|trans }} 10€
{% else %}
{{ price }}
{% endif %}
</div>
</a>
</div>