From ff4ffe15ec688b16065dfa0afa2da898eccb4547 Mon Sep 17 00:00:00 2001 From: tuka217 Date: Tue, 10 Jan 2017 09:18:45 +0100 Subject: [PATCH] [ShopBundle] Show shipping promotions on checkout summary page [AdminBundle] Show shipping promotions on order show page --- .../Order/Show/Summary/_totals.html.twig | 34 +++++++++++++++---- .../Common/Order/Table/_shipping.html.twig | 25 ++++++++++++++ .../Common/Order/Table/_totals.html.twig | 4 +-- 3 files changed, 53 insertions(+), 10 deletions(-) diff --git a/src/Sylius/Bundle/AdminBundle/Resources/views/Order/Show/Summary/_totals.html.twig b/src/Sylius/Bundle/AdminBundle/Resources/views/Order/Show/Summary/_totals.html.twig index dc0b993c6b2a..ed6354cda93b 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/views/Order/Show/Summary/_totals.html.twig +++ b/src/Sylius/Bundle/AdminBundle/Resources/views/Order/Show/Summary/_totals.html.twig @@ -1,10 +1,14 @@ {% import "@SyliusAdmin/Common/Macro/money.html.twig" as money %} + {% set orderPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_PROMOTION_ADJUSTMENT') %} +{% set orderShippingPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT') %} {% set itemPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_ITEM_PROMOTION_ADJUSTMENT') %} {% set shippingAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::SHIPPING_ADJUSTMENT') %} {% set taxAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::TAX_ADJUSTMENT') %} +{% set orderShippingPromotions = sylius_aggregate_adjustments(order.getAdjustmentsRecursively(orderShippingPromotionAdjustment)) %} + {{ 'sylius.ui.subtotal'|trans }}: @@ -12,7 +16,7 @@ - + {% if not order.adjustments(shippingAdjustment).isEmpty() %}
{% for adjustment in order.adjustments(shippingAdjustment) %} @@ -20,7 +24,7 @@
{{ adjustment.label }}
- {{ money.format(adjustment.amount ,order.currencyCode) }} + {{ money.format(adjustment.amount, order.currencyCode) }}
@@ -30,9 +34,25 @@

{{ 'sylius.ui.no_shipping_charges'|trans }}

{% endif %} + {% if not orderShippingPromotions is empty %} + +
+ {% for label, amount in orderShippingPromotions %} +
+
+
{{ label }}
+
+ {{ money.format(amount, order.currencyCode) }} +
+
+
+ {% endfor %} +
+ + {% endif %} {{ 'sylius.ui.shipping_total'|trans }}: - {{ money.format(order.shippingTotal ,order.currencyCode) }} + {{ money.format(order.shippingTotal, order.currencyCode) }} @@ -45,7 +65,7 @@
{{ taxLabel }}
- {{ money.format(taxAmount ,order.currencyCode) }} + {{ money.format(taxAmount, order.currencyCode) }}
@@ -70,7 +90,7 @@
{{ label }}
- {{ money.format(amount ,order.currencyCode) }} + {{ money.format(amount, order.currencyCode) }}
@@ -82,12 +102,12 @@ {{ 'sylius.ui.promotion_total'|trans }}: - {{ money.format(order.orderPromotionTotal ,order.currencyCode) }} + {{ money.format(order.orderPromotionTotal, order.currencyCode) }} {{ 'sylius.ui.total'|trans }}: - {{ money.format(order.total ,order.currencyCode) }} + {{ money.format(order.total, order.currencyCode) }} diff --git a/src/Sylius/Bundle/ShopBundle/Resources/views/Common/Order/Table/_shipping.html.twig b/src/Sylius/Bundle/ShopBundle/Resources/views/Common/Order/Table/_shipping.html.twig index e69de29bb2d1..15098c5d8495 100644 --- a/src/Sylius/Bundle/ShopBundle/Resources/views/Common/Order/Table/_shipping.html.twig +++ b/src/Sylius/Bundle/ShopBundle/Resources/views/Common/Order/Table/_shipping.html.twig @@ -0,0 +1,25 @@ +{% import "@SyliusShop/Common/Macro/money.html.twig" as money %} + +{% set orderShippingPromotionAdjustment = constant('Sylius\\Component\\Core\\Model\\AdjustmentInterface::ORDER_SHIPPING_PROMOTION_ADJUSTMENT') %} + + + {% set orderShippingPromotions = sylius_aggregate_adjustments(order.getAdjustmentsRecursively(orderShippingPromotionAdjustment)) %} + {% if not orderShippingPromotions is empty %} +
+ {% for label, amount in orderShippingPromotions %} +
+
+
{{ label }}
+
+ {{ money.convertAndFormat(amount) }} +
+
+
+ {% endfor %} +
+ {% endif %} + + + {{ 'sylius.ui.shipping_total'|trans }}: + {{ money.format(order.shippingTotal, order.currencyCode) }} + diff --git a/src/Sylius/Bundle/ShopBundle/Resources/views/Common/Order/Table/_totals.html.twig b/src/Sylius/Bundle/ShopBundle/Resources/views/Common/Order/Table/_totals.html.twig index ec022a474287..7b63439ea3ae 100644 --- a/src/Sylius/Bundle/ShopBundle/Resources/views/Common/Order/Table/_totals.html.twig +++ b/src/Sylius/Bundle/ShopBundle/Resources/views/Common/Order/Table/_totals.html.twig @@ -6,9 +6,7 @@ - - {{ 'sylius.ui.shipping_total'|trans }}: {{ money.format(order.shippingTotal, order.currencyCode) }} - + {% include '@SyliusShop/Common/Order/Table/_shipping.html.twig' with {'order': order} %}