src/Storefront/Resources/views/storefront/component/product/card/price-unit.html.twig line 1

  1. {% block component_product_box_price_info %}
  2.     {% set cheapest = product.calculatedCheapestPrice %}
  3.     {% set real = product.calculatedPrice %}
  4.     {% if product.calculatedPrices.count > 0 %}
  5.         {% set real = product.calculatedPrices.last %}
  6.     {% endif %}
  7.     {% set referencePrice = real.referencePrice %}
  8.     {% set displayFrom = product.calculatedPrices.count > 1 %}
  9.     {% set displayParent = product.variantListingConfig.displayParent and product.parentId === null %}
  10.     {% if displayParent %}
  11.         {% set displayFromVariants = displayParent and real.unitPrice !== cheapest.unitPrice %}
  12.         {% set real = cheapest %}
  13.     {% endif %}
  14.     <div class="product-price-info">
  15.         {% block component_product_box_price_unit %}
  16.             <p class="product-price-unit">
  17.                 {# Price is based on the purchase unit #}
  18.                 {% block component_product_box_price_purchase_unit %}
  19.                     {% if referencePrice and referencePrice.unitName %}
  20.                         <span class="product-unit-label">
  21.                             {{ "listing.boxUnitLabel"|trans|sw_sanitize }}
  22.                         </span>
  23.                         <span class="price-unit-content">
  24.                             {{ referencePrice.purchaseUnit }} {{ referencePrice.unitName }}
  25.                         </span>
  26.                     {% endif %}
  27.                 {% endblock %}
  28.                 {# Item price is based on a reference unit #}
  29.                 {% block component_product_box_price_reference_unit %}
  30.                     {% if referencePrice is not null %}
  31.                         <span class="price-unit-reference">
  32.                             ({{ referencePrice.price|currency }}{{ "general.star"|trans|sw_sanitize }} / {{ referencePrice.referenceUnit }} {{ referencePrice.unitName }})
  33.                         </span>
  34.                     {% endif %}
  35.                 {% endblock %}
  36.             </p>
  37.         {% endblock %}
  38.         {% block component_product_box_price %}
  39.             <div class="product-price-wrapper">
  40.                 {% set price = real %}
  41.                 {% set isListPrice = price.listPrice.percentage > 0 %}
  42.                 {% set isRegulationPrice = price.regulationPrice != null %}
  43.                 <div class="product-cheapest-price{% if isListPrice and isRegulationPrice and not displayFrom and not displayFromVariants %} with-list-price{% endif %}{% if isRegulationPrice and not displayFrom and displayFromVariants %} with-regulation-price{% endif %}{% if displayFrom and isRegulationPrice %} with-from-price{% endif %}">
  44.                     {% if cheapest.unitPrice != real.unitPrice %}
  45.                         <div>{{ "listing.cheapestPriceLabel"|trans|sw_sanitize }}<span class="product-cheapest-price-price"> {{ cheapest.unitPrice|currency }}{{ "general.star"|trans|sw_sanitize }}</span></div>
  46.                     {% endif %}
  47.                 </div>
  48.                 {% if displayFrom or (displayParent and displayFromVariants) %}
  49.                     {{ "listing.listingTextFrom"|trans|sw_sanitize }}
  50.                 {% endif %}
  51.                 <span class="product-price{% if isListPrice and not displayFrom and not displayFromVariants %} with-list-price{% endif %}">
  52.                     {{ price.unitPrice|currency }}{{ "general.star"|trans|sw_sanitize }}
  53.                     {% if isListPrice and not displayFrom and not displayFromVariants %}
  54.                         {% set afterListPriceSnippetExists = "listing.afterListPrice"|trans|length > 0 %}
  55.                         {% set beforeListPriceSnippetExists = "listing.beforeListPrice"|trans|length > 0 %}
  56.                         {% set hideStrikeTrough = beforeListPriceSnippetExists or afterListPriceSnippetExists %}
  57.                         <span class="list-price{% if hideStrikeTrough %} list-price-no-line-through{% endif %}">
  58.                             {% if beforeListPriceSnippetExists %}{{ "listing.beforeListPrice"|trans|trim|sw_sanitize }}{% endif %}
  59.                             <span class="list-price-price">{{ price.listPrice.price|currency }}{{ "general.star"|trans|sw_sanitize }}</span>
  60.                             {% if afterListPriceSnippetExists %}{{ "listing.afterListPrice"|trans|trim|sw_sanitize }}{% endif %}
  61.                             <span class="list-price-percentage">{{ "detail.listPricePercentage"|trans({'%price%': price.listPrice.percentage })|sw_sanitize }}</span>
  62.                         </span>
  63.                     {% endif %}
  64.                 </span>
  65.                 {% if isRegulationPrice %}
  66.                     <span class="product-price with-regulation-price">
  67.                         {% if isListPrice %}<br/>{% endif %}<span class="regulation-price">{{ "general.listPricePreviously"|trans({'%price%': price.regulationPrice.price|currency }) }}{{ "general.star"|trans|sw_sanitize }}</span>
  68.                     </span>
  69.                 {% endif %}
  70.             </div>
  71.         {% endblock %}
  72.     </div>
  73. {% endblock %}