{% import "@SyliusShop/Common/Macro/money.html.twig" as money %}

{% set orderShippingPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT') %}
{% set shippingAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::SHIPPING_ADJUSTMENT') %}
{% set orderShippingPromotions = sylius_aggregate_adjustments(order.getAdjustmentsRecursively(orderShippingPromotionAdjustment)) %}

{% if not orderShippingPromotions is empty %}
    <td colspan="4" class="text-right" id="promotion-shipping-discounts" {{ sylius_test_html_attribute('promotion-shipping-discounts') }}>
        {{ 'sylius.ui.shipping_total'|trans }}:
        <div class="price-wrapper-vertical down">
            <span>
                <i id="shipping-promotion-details" class="question circle icon"
                   data-toggle="tooltip"
                   title="{% for label, amount in orderShippingPromotions %}<div>{{ label }}: {{ money.convertAndFormat(amount) }}</div>{% endfor %}"
                   {{ sylius_test_html_attribute('shipping-promotion-details') }}
                ></i>
                <span class="price-sm-old price-sm">{{ money.convertAndFormat(order.getAdjustmentsTotal(shippingAdjustment)) }}</span>
            </span>
           <span id="shipping-total" class="price-sm promo" {{ sylius_test_html_attribute('shipping-total') }}>{{ money.convertAndFormat(order.getAdjustmentsTotal(shippingAdjustment) + order.getAdjustmentsTotal(orderShippingPromotionAdjustment)) }}</span>
        </div>
    </td>
{% elseif order.shipments is not empty %}
    <td colspan="4" class="text-right" id="shipping-total">
        {{ 'sylius.ui.shipping_total'|trans }}:
        <span {{ sylius_test_html_attribute('shipping-total') }} class="price-sm">{{ money.convertAndFormat(order.shippingTotal) }}</span>
    </td>
{% endif %}
