{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} {# --------------------------------------------------------------------- #} {# Template : Cart > _itemRow.html.twig #} {# Objectif  : une seule instance du champ quantité (pas de doublon d'id) #} {# --------------------------------------------------------------------- #} {% set variant = item.variant %} {% set product = variant.product %} {% set originalPrice = sylius_order_item_original_price_to_display(item) %} {% set image = product.imagesByType('main').first ?? null %} {% set variantImagePath = null %} {% if variant.images|length > 0 %} {% for variantImage in variant.images %} {% if variantImagePath is null and variantImage.path is not empty %} {% set variantImagePath = variantImage.path %} {% endif %} {% endfor %} {% endif %} {% if variantImagePath is null %} {% for productImage in product.images %} {% if variantImagePath is null and productImage.productVariants is defined and productImage.path is not empty %} {% for linkedVariant in productImage.productVariants %} {% if variantImagePath is null and linkedVariant.id is defined and linkedVariant.id == variant.id %} {% set variantImagePath = productImage.path %} {% endif %} {% endfor %} {% endif %} {% endfor %} {% endif %} {# On rend le champ une seule fois pour éviter les IDs dupliqués #} {% set quantityField = form_widget(form.quantity, { attr: { class: 'form-control text-center', min: 1 } }) %} {# -------------------------------------------------- #} {# 1. Cellule : Image + Infos produit #} {# -------------------------------------------------- #}
{% if variantImagePath %}
{{ variant.name|default(product.name) }}
{% else %} {% include '@SyliusShop/Product/_mainImage.html.twig' with { product: product, filter: 'sylius_shop_product_tiny_thumbnail' } %} {% endif %}
{{ product.name }}
{# Infos prix & total supplémentaires pour mobile (< md) #}
{{ 'sylius.ui.price'|trans }}: {{ money.convertAndFormat(item.unitPrice) }}
{{ 'sylius.ui.total'|trans }}: {{ money.convertAndFormat(item.subtotal) }}
{# -------------------------------------------------- #} {# 2. Cellule : Prix unitaire (desktop ≥ md) #} {# -------------------------------------------------- #} {{ money.convertAndFormat(item.unitPrice) }} {% if originalPrice is not null %} {{ money.convertAndFormat(originalPrice) }} {% endif %} {# -------------------------------------------------- #} {# 3. Cellule : Quantité – source unique #} {# -------------------------------------------------- #}
{{ quantityField|raw }}
{# -------------------------------------------------- #} {# 4. Cellule : Sous‑total (desktop ≥ md) #} {# -------------------------------------------------- #} {{ money.convertAndFormat(item.subtotal) }} {# -------------------------------------------------- #} {# 5. Cellule : Bouton supprimer #} {# -------------------------------------------------- #}