{% sw_extends '@Storefront/storefront/component/product/card/price-unit.html.twig' %}
{% block component_product_box_price_info %}
{# @deprecated tag:v6.5.0 - purchaseUnit will be removed, use product.purchaseUnit if needed #}
{% set purchaseUnit = product.purchaseUnit %}
{# @deprecated tag:v6.5.0 - listingPrice will be removed without replacement, since it was removed from the product struct #}
{% set listingPrice = product.calculatedListingPrice %}
{# @deprecated tag:v6.5.0 - fromPrice will be removed without replacement #}
{% set fromPrice = listingPrice.from %}
{% set cheapest = product.calculatedCheapestPrice %}
{% set real = product.calculatedPrice %}
{% if product.calculatedPrices.count > 0 %}
{% set real = product.calculatedPrices.last %}
{% endif %}
{% set referencePrice = real.referencePrice %}
{% set displayFrom = product.calculatedPrices.count > 1 %}
{% block component_product_box_price_unit %}
<p class="product-price-unit">
{# Price is based on the purchase unit #}
{% block component_product_box_price_purchase_unit %}
{% if referencePrice and referencePrice.unitName %}
<span class="product-unit-label">
{{ "listing.boxUnitLabel"|trans|sw_sanitize }}
</span>
<span class="price-unit-content">
{{ referencePrice.purchaseUnit }} {{ referencePrice.unitName }}
</span>
{% endif %}
{% endblock %}
{# Item price is based on a reference unit #}
{% block component_product_box_price_reference_unit %}
{% if referencePrice is not null %}
<span class="price-unit-reference">
({{ referencePrice.price }} / {{ referencePrice.referenceUnit }} {{ referencePrice.unitName }})
</span>
{% endif %}
{% endblock %}
</p>
{% endblock %}
{% block component_product_box_price %}
<div class="product-price-wrapper">
{# Custom switch, this is made for Shop The Look products. As Shop #}
{% if product.calculatedPrice %}
{# Original prices, default shopware #}
{% set price = real %}
{% set isListPrice = price.listPrice.percentage > 0 %}
{% set unitPrice = price.unitPrice %}
{% set listPrice = price.listPrice.price %}
{% else %}
{# Custom prices, for products that are included by Shop The Look #}
{% set price = product.price.elements|first %}
{% set isListPrice = price.gross < price.listPrice.gross %}
{% set unitPrice = price.gross %}
{% set listPrice = price.listPrice.gross %}
{% endif %}
{% if displayFrom %}
{{ "listing.listingTextFrom"|trans|sw_sanitize }}
{% endif %}
{% if isListPrice and not displayFrom %}
{% set afterListPriceSnippetExists = "listing.afterListPrice"|trans|length > 0 %}
{% set beforeListPriceSnippetExists = "listing.beforeListPrice"|trans|length > 0 %}
{% if beforeListPriceSnippetExists %}{{ "listing.beforeListPrice"|trans|trim|sw_sanitize }}{% endif %}
<span class="list-price original-price text-xs line-through mr-1 md:mr-2">
{{ listPrice|number_format(2) }}
</span>
{% if afterListPriceSnippetExists %}{{ "listing.afterListPrice"|trans|trim|sw_sanitize }}{% endif %}
{% endif %}
<span class="product-price current-price inline-block text-xs{% if isListPrice and not displayFrom %} sale-price text-red-500 font-bold{% endif %}">
{{ unitPrice }}
</span>
</div>
{% endblock %}
{% endblock %}