Skip to content

Commit

Permalink
[ShopBundle] Show shipping promotions on checkout summary page
Browse files Browse the repository at this point in the history
[AdminBundle] Show shipping promotions on order show page
  • Loading branch information
tuka217 committed Jan 10, 2017
1 parent 9db055b commit ff4ffe1
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 10 deletions.
@@ -1,26 +1,30 @@
{% 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)) %}

<tr>
<th colspan="8" id="items-total" class="right aligned">
<strong>{{ 'sylius.ui.subtotal'|trans }}</strong>:
{{ money.format(order.itemsTotal ,order.currencyCode) }}
</th>
</tr>
<tr>
<td colspan="4" id="shipping-charges">
<td colspan="{{ orderShippingPromotions ? 2 : 4 }}" id="shipping-charges">
{% if not order.adjustments(shippingAdjustment).isEmpty() %}
<div class="ui relaxed divided list">
{% for adjustment in order.adjustments(shippingAdjustment) %}
<div class="item">
<div class="content">
<span class="header">{{ adjustment.label }}</span>
<div class="description">
{{ money.format(adjustment.amount ,order.currencyCode) }}
{{ money.format(adjustment.amount, order.currencyCode) }}
</div>
</div>
</div>
Expand All @@ -30,9 +34,25 @@
<p><small>{{ 'sylius.ui.no_shipping_charges'|trans }}</small></p>
{% endif %}
</td>
{% if not orderShippingPromotions is empty %}
<td colspan="2" id="promotion-shipping-discounts">
<div class="ui relaxed divided list">
{% for label, amount in orderShippingPromotions %}
<div class="item">
<div class="content">
<div class="header">{{ label }}</div>
<div class="description">
{{ money.format(amount, order.currencyCode) }}
</div>
</div>
</div>
{% endfor %}
</div>
</td>
{% endif %}
<td colspan="4" id="shipping-total" class="right aligned">
<strong>{{ 'sylius.ui.shipping_total'|trans }}</strong>:
{{ money.format(order.shippingTotal ,order.currencyCode) }}
{{ money.format(order.shippingTotal, order.currencyCode) }}
</td>
</tr>
<tr>
Expand All @@ -45,7 +65,7 @@
<div class="content">
<span class="header">{{ taxLabel }}</span>
<div class="description">
{{ money.format(taxAmount ,order.currencyCode) }}
{{ money.format(taxAmount, order.currencyCode) }}
</div>
</div>
</div>
Expand All @@ -70,7 +90,7 @@
<div class="content">
<span class="header">{{ label }}</span>
<div class="description">
{{ money.format(amount ,order.currencyCode) }}
{{ money.format(amount, order.currencyCode) }}
</div>
</div>
</div>
Expand All @@ -82,12 +102,12 @@
</td>
<td colspan="4" id="promotion-total" class="right aligned">
<strong>{{ 'sylius.ui.promotion_total'|trans }}</strong>:
{{ money.format(order.orderPromotionTotal ,order.currencyCode) }}
{{ money.format(order.orderPromotionTotal, order.currencyCode) }}
</td>
</tr>
<tr>
<td colspan="8" id="total" class="ui large header right aligned">
<strong>{{ 'sylius.ui.total'|trans }}</strong>:
{{ money.format(order.total ,order.currencyCode) }}
{{ money.format(order.total, order.currencyCode) }}
</td>
</tr>
@@ -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') %}

<td colspan="2" id="promotion-shipping-discounts">
{% set orderShippingPromotions = sylius_aggregate_adjustments(order.getAdjustmentsRecursively(orderShippingPromotionAdjustment)) %}
{% if not orderShippingPromotions is empty %}
<div class="ui relaxed divided list">
{% for label, amount in orderShippingPromotions %}
<div class="item">
<div class="content">
<div class="header">{{ label }}</div>
<div class="description">
{{ money.convertAndFormat(amount) }}
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
</td>
<td colspan="4" class="right aligned" id="shipping-total">
{{ 'sylius.ui.shipping_total'|trans }}:
{{ money.format(order.shippingTotal, order.currencyCode) }}
</td>
Expand Up @@ -6,9 +6,7 @@
</th>
</tr>
<tr>
<td colspan="4" class="right aligned" id="shipping-total">
{{ 'sylius.ui.shipping_total'|trans }}: {{ money.format(order.shippingTotal, order.currencyCode) }}
</td>
{% include '@SyliusShop/Common/Order/Table/_shipping.html.twig' with {'order': order} %}
</tr>
<tr>
<td colspan="4" class="right aligned" id="tax-total">
Expand Down

0 comments on commit ff4ffe1

Please sign in to comment.