{% sw_extends '@Storefront/storefront/page/checkout/checkout-item.html.twig' %}
{% block page_checkout_item %}
{% set allDiscounts = [] %}
{% set lineItems = [] %}
{% if page.cart.lineItems is defined %}
{% set lineItems = page.cart.lineItems %}
{% elseif page.order.lineItems is defined %}
{% set lineItems = page.order.lineItems %}
{% endif %}
{% if lineItems %}
{% for item in lineItems %}
{% if item.type is same as ("promotion") and item.payload.discountDisplay is same as ("positionBased") %}
{% if item.payload.composition is defined %}
{% for discount in item.payload.composition %}
{% if (lineItem.identifier and discount.id == lineItem.identifier) or discount.id == lineItem.id %}
{% set allDiscounts = allDiscounts|merge([discount|merge([item])]) %}
{% endif %}
{% endfor %}
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
{{ parent() }}
{% endblock %}
{% block page_checkout_item_container %}
{% if isDiscount is same as (true) and lineItem.payload.discountDisplay is same as ("positionBased") and isAcrisDiscountPositionBased is not defined %}
{# hide general discount #}
{% else %}
{% if allDiscounts %}
<div class="cart-item-has-discount-position-based">
{{ parent() }}
</div>
{% block page_checkout_item_discounts %}
{% for item in allDiscounts %}
{% set lineItem = item[0] %}
{% block page_checkout_item_discount %}
{% if lineItem and lineItem.payload.discountDisplay is same as ("positionBased") %}
{% set discountIncludeFile = '@Storefront/storefront/page/checkout/checkout-item.html.twig' %}
{% block page_checkout_item_discount_include %}
{% sw_include discountIncludeFile with {
'lineItem': lineItem,
'isAcrisDiscountPositionBased': true,
'priceDiscount': item.discount
} %}
{% endblock %}
{% endif %}
{% endblock %}
{% endfor %}
{% endblock %}
{% else %}
{{ parent() }}
{% endif %}
{% endif %}
{% endblock %}
{% block page_checkout_item_quantity_label %}
{% if isAcrisDiscountPositionBased %}{% else %}{{ parent() }}{% endif %}
{% endblock %}
{% block page_checkout_item_total_price_inner %}
{% if isAcrisDiscountPositionBased is same as (true) and priceDiscount %}- {{ priceDiscount|currency }}{% block page_checkout_item_total_price_tax_symbol %}{{ parent() }}{% endblock %}{% else %}{{ parent() }}{% endif %}
{% endblock %}