Browse Source

refactor(email-plugin): Update templates to use new Order props

Michael Bromley 5 years ago
parent
commit
e33b033688

+ 12 - 2
packages/email-plugin/src/mock-events.ts

@@ -1,3 +1,4 @@
+import { AdjustmentType } from '@vendure/common/lib/generated-shop-types';
 import {
     AccountRegistrationEvent,
     Customer,
@@ -18,8 +19,9 @@ export const mockOrderStateTransitionEvent = new OrderStateTransitionEvent(
     {} as any,
     new Order({
         id: '6',
-        createdAt: '2018-10-31T15:18:29.261Z',
+        createdAt: '2018-10-31T11:18:29.261Z',
         updatedAt: '2018-10-31T15:24:17.000Z',
+        orderPlacedAt: '2018-10-31T13:54:17.000Z',
         code: 'T3EPGJKTVZPBD6Z9',
         state: 'ArrangingPayment',
         active: true,
@@ -45,7 +47,14 @@ export const mockOrderStateTransitionEvent = new OrderStateTransitionEvent(
                         id: '6',
                         listPrice: 14374,
                         listPriceIncludesTax: true,
-                        adjustments: [],
+                        adjustments: [
+                            {
+                                adjustmentSource: 'Promotion:1',
+                                type: AdjustmentType.PROMOTION,
+                                amount: -1000,
+                                description: '$10 off computer equipment',
+                            },
+                        ],
                         taxLines: [],
                     }),
                 ],
@@ -76,6 +85,7 @@ export const mockOrderStateTransitionEvent = new OrderStateTransitionEvent(
         shipping: 1000,
         shippingMethod: {
             code: 'express-flat-rate',
+            name: 'Express Shipping',
             description: 'Express Shipping',
             id: '2',
         },

+ 10 - 2
packages/email-plugin/templates/order-confirmation/body.hbs

@@ -101,7 +101,15 @@
                     </td>
                     <td>{{ quantity }} x {{ productVariant.name }}</td>
                     <td>{{ productVariant.quantity }}</td>
-                    <td>${{ formatMoney totalPrice }}</td>
+                    <td>${{ formatMoney discountedLinePriceWithTax }}</td>
+                </tr>
+            {{/each}}
+            {{#each order.discounts }}
+                <tr class="order-row">
+                    <td colspan="3">
+                        {{ description }}
+                    </td>
+                    <td>${{ formatMoney amount }}</td>
                 </tr>
             {{/each}}
             <tr class="order-row">
@@ -109,7 +117,7 @@
                 <td>${{ formatMoney order.subTotal }}</td>
             </tr>
             <tr class="order-row">
-                <td colspan="3">Shipping ({{ shippingMethod.description }}):</td>
+                <td colspan="3">Shipping ({{ shippingMethod.name }}):</td>
                 <td>${{ formatMoney order.shipping }}</td>
             </tr>
             <tr class="order-row total-row">