{#--Onglet Tarif & Promotions--#} {# Contexte promo #} {% set now = date() %} {% set promo = produit.promotion %} {% set promoActive = promo and promo.startAt <= now and promo.endAt >= now %} {% set discount = promoActive ? promo.discountValue : 0 %} {% set discountType = promoActive ? promo.discountType : null %} {# Prix après remise #} {% set ht_remise = promoActive ? (discountType == 'percent' ? (produit.priceHt - (produit.priceHt * discount / 100)) : (produit.priceHt - discount)) : produit.priceHt %} {% set ttc_remise = promoActive ? (discountType == 'percent' ? (produit.priceTtc - (produit.priceTtc * discount / 100)) : (produit.priceTtc - discount)) : produit.priceTtc %} {# % remisé calculé même si remise fixe #} {% set pct_ht = promoActive and produit.priceHt > 0 ? (100 * (produit.priceHt - ht_remise) / produit.priceHt) : 0 %} {% set pct_ttc = promoActive and produit.priceTtc > 0 ? (100 * (produit.priceTtc - ttc_remise) / produit.priceTtc) : 0 %} {#-- Onglet Tarif et Promotion Amélioré --#}