{% sw_extends '@Storefront/storefront/page/checkout/summary.html.twig' %} {% block page_checkout_summary_inner %} {% set loeData = page.extensions.loeEditableProducts ?? null %} {% set allSupplements = loeData ? (loeData.allSupplementOrders ?? []) : [] %} {% set parentOrder = loeData ? (loeData.parentOrder ?? null) : null %} {% set combinedTotal = loeData ? (loeData.combinedAmountTotal ?? null) : null %} {% set parentShipping = loeData ? (loeData.parentShippingTotal ?? 0) : 0 %} {% set allSuppShip = loeData ? (loeData.allSupplementShippingTotals ?? {}) : {} %} {% set loeReplCredit = page.cart.extensions.loeReplacementCredit ?? null %} {% set loeModify = page.extensions.loeModifyOrder ?? null %} {# ── Finish page: detect replacement order from placed order data ─── #} {% set loeFinishOrder = page.order ?? null %} {% set loeFinishIsReplacement = loeFinishOrder and (loeFinishOrder.customFields.sellops_type ?? null) == 'replacement' %} {% set loeFinishCreditItem = null %} {% if loeFinishIsReplacement %} {% for li in (loeFinishOrder.lineItems ?? []) %} {% if li.identifier is defined and li.identifier == 'loe_previous_order_credit' %} {% set loeFinishCreditItem = li %} {% endif %} {% endfor %} {% endif %} {% if loeModify and (loeModify.enabled ?? false) and loeReplCredit and (loeReplCredit.creditApplied ?? false) %} {# ── Replacement order (Case 1): professional payment breakdown ─── #} {% set replCartShipping = 0 %} {% for delivery in page.cart.deliveries %} {% set replCartShipping = replCartShipping + delivery.shippingCosts.totalPrice %} {% endfor %}
{{ 'sellops.loe.modify.summaryProductsSubtotal'|trans|sw_sanitize }}
{{ loeReplCredit.newProductTotal|currency }}
{{ 'sellops.loe.modify.summaryCreditPreviousPayment'|trans|sw_sanitize }}
-{{ loeReplCredit.originalTotal|currency }}
{{ 'checkout.summaryShipping'|trans|sw_sanitize }}
{% if replCartShipping > 0 %}{{ replCartShipping|currency }}{% else %}—{% endif %}
{{ 'checkout.summaryTotalPrice'|trans|sw_sanitize }}
{{ page.cart.price.totalPrice|currency }}
{% elseif loeFinishIsReplacement and loeFinishCreditItem %} {# ── Finish page: Replacement order payment breakdown ─────────────── #} {% set finishProductSubtotal = 0 %} {% for li in (loeFinishOrder.lineItems ?? []) %} {% if li.type is defined and li.type == 'product' %} {% set finishProductSubtotal = finishProductSubtotal + li.totalPrice %} {% endif %} {% endfor %} {% set finishShipping = 0 %} {% for delivery in (loeFinishOrder.deliveries ?? []) %} {% set finishShipping = finishShipping + delivery.shippingCosts.totalPrice %} {% endfor %}
{{ 'sellops.loe.modify.summaryProductsSubtotal'|trans|sw_sanitize }}
{{ finishProductSubtotal|currency }}
{{ 'sellops.loe.modify.summaryCreditPreviousPayment'|trans|sw_sanitize }}
{{ loeFinishCreditItem.totalPrice|currency }}
{{ 'checkout.summaryShipping'|trans|sw_sanitize }}
{% if finishShipping > 0 %}{{ finishShipping|currency }}{% else %}—{% endif %}
{{ 'checkout.summaryTotalPrice'|trans|sw_sanitize }}
{{ loeFinishOrder.amountTotal|currency }}
{% elseif allSupplements|length > 0 and parentOrder and combinedTotal is not null %} {# ── Original order ─────────────────────────────────────────────── #}
#{{ parentOrder.orderNumber }}
{% for li in (parentOrder.lineItems ?? []) %} {% if li.type is not defined or (li.type != 'promotion' and li.label != 'Shipping already paid') %}
{{ li.label }} ×{{ li.quantity }}
{{ li.totalPrice|currency }}
{% endif %} {% endfor %}
{{ 'checkout.summaryShipping'|trans|sw_sanitize }}
{% if parentShipping > 0 %}{{ parentShipping|currency }}{% else %}—{% endif %}
{# ── Each supplement order ───────────────────────────────────────── #} {% for suppOrder in allSupplements %} {% set suppShipping = attribute(allSuppShip, suppOrder.id) ?? 0 %} {# Detect shipping credit line item for this supplement #} {% set suppCreditItem = null %} {% for li in (suppOrder.lineItems ?? []) %} {% if li.identifier is defined and li.identifier == 'loe_shipping_threshold_credit' %} {% set suppCreditItem = li %} {% endif %} {% endfor %}
#{{ suppOrder.orderNumber }}
{% for li in (suppOrder.lineItems ?? []) %} {% if li.label is not defined or (li.label != 'Shipping already paid' and (li.type is not defined or li.type != 'promotion') and (li.identifier is not defined or li.identifier != 'loe_shipping_threshold_credit')) %}
{{ li.label }} ×{{ li.quantity }}
{{ li.totalPrice|currency }}
{% endif %} {% endfor %}
{{ 'checkout.summaryShipping'|trans|sw_sanitize }}
{% if suppShipping > 0 %}{{ suppShipping|currency }}{% else %}—{% endif %}
{# Shipping credit row — only if a credit was applied to this supplement #} {% if suppCreditItem %}
{{ 'sellops.loe.shippingThreshold.summaryLabel'|trans|sw_sanitize }} {{ 'sellops.loe.shippingThreshold.summaryInfoTooltip'|trans|sw_sanitize }}
{{ suppCreditItem.totalPrice|currency }}
{% endif %} {% endfor %} {# ── Combined grand total ────────────────────────────────────────── #}
{{ 'sellops.loe.supplementFinish.grandTotal'|trans|sw_sanitize }}
{{ combinedTotal|currency }}
{% else %} {{ parent() }} {% endif %} {% endblock %}