{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} {% set tax_included = sylius_order_tax_included(order) %} {% set tax_excluded = sylius_order_tax_excluded(order) %} {% set current_route = app.request is defined and app.request ? app.request.attributes.get('_route') : null %} {% set hide_shipping_on_route = current_route in ['sylius_shop_checkout_address'] %} {% set has_selected_shipping = false %} {% for shipment in order.shipments %} {% if shipment.method is not null %} {% set has_selected_shipping = true %} {% endif %} {% endfor %} {% set display_shipping = has_selected_shipping and not hide_shipping_on_route %} {% set exclude_shipping_from_total = current_route in ['sylius_shop_checkout_address', 'sylius_shop_checkout_select_shipping'] %} {% set display_total = (not display_shipping or exclude_shipping_from_total) ? order.total - order.shippingTotal : order.total %} {% set hide_items_total = current_route in ['sylius_shop_checkout_select_payment'] %} {% set order_promotion_adjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT') %} {% set order_item_promotion_adjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT') %} {% set order_unit_promotion_adjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_UNIT_PROMOTION_ADJUSTMENT') %} {% set promotion_coupon = order.promotionCoupon %} {% set promotion_coupon_code = promotion_coupon and promotion_coupon.promotion ? promotion_coupon.promotion.code : null %} {% set volume_discount_total = 0 %} {% set coupon_discount_total = 0 %} {% for adjustment_type in [order_promotion_adjustment, order_item_promotion_adjustment, order_unit_promotion_adjustment] %} {% for adjustment in order.getAdjustmentsRecursively(adjustment_type) %} {% set amount = adjustment.amount %} {% if promotion_coupon_code and adjustment.originCode == promotion_coupon_code %} {% set coupon_discount_total = coupon_discount_total + amount %} {% else %} {% set volume_discount_total = volume_discount_total + amount %} {% endif %} {% endfor %} {% endfor %} {% set original_items_total = 0 %} {% for item in order.items %} {% set original_items_total = original_items_total + (item.quantity * item.unitPrice) %} {% endfor %} {% set items_total = original_items_total ?: (display_total - volume_discount_total - coupon_discount_total) %} {% set order_promotion_percentage = null %} {% if volume_discount_total and original_items_total %} {% set order_promotion_percentage = ((volume_discount_total / original_items_total) * 100)|abs %} {% endif %}