/
order.twig
executable file
·160 lines (134 loc) · 7.13 KB
/
order.twig
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
{# @var order \workingconcept\snipcart\models\Order #}
{% extends 'snipcart/email/_layout' %}
{% set heroImage = craft.app.assetManager.getPublishedUrl(
'@workingconcept/snipcart/assetbundles/dist/img/order-complete.png',
true
) %}
{% if craft.app.getConfig().general.devMode %}
{% set heroImage = craft.app.assetManager.getPublishedUrl(
'@workingconcept/snipcart/assetbundles/dist/img/order-complete-devmode.png',
true
) %}
{% endif %}
{% set primaryDetails = {
'Order Number': order.invoiceNumber,
'Order Email': order.email
} %}
{% if providerOrders.shipStation is defined %}
{% set primaryDetails = primaryDetails | merge({ 'ShipStation #': providerOrders.shipStation.orderId }) %}
{% endif %}
{% block hero %}
<tr>
<td style="background-color: #F6E767;">
<img src="{{ heroImage }}" width="600" height="" alt="order complete" border="0" style="width: 100%; max-width: 600px; height: auto; background: #F6E767; font-family: sans-serif; font-size: 15px; line-height: 15px; color: #F6E767; margin: auto;" class="g-img">
</td>
</tr>
{% endblock hero %}
{% block content %}
<h1 style="margin: 0 0 25px 0; font-size: 25px; line-height: 30px; color: #333333; font-weight: normal;">
{{- order.billingAddressName }} {{ "just placed an order"|t }}.
</h1>
{% for label, value in primaryDetails %}
{% set pClass = loop.last ? "no-top-margin large-bottom-margin" : "no-margin" %}
<p class="primary-detail {{ pClass }}"><b>{{ label }}:</b> {{ value }}</p>
{% endfor %}
<table class="content-table">
<thead>
<th class="align-left no-left-margin first-cell-padding">{{ "Qty"|t }}</th>
<th class="align-left normal-cell-padding" width="50%">{{ "Item"|t }}</th>
<th class="align-right normal-cell-padding nowrap">{{ "Price"|t }}</th>
<th class="align-right no-right-margin last-cell-padding nowrap">{{ "Subtotal"|t }}</th>
</thead>
<tbody>
{% for item in order.items %}
{# @var item \workingconcept\snipcart\models\Item #}
<tr>
<td class="align-left first-cell-padding">{{ item.quantity }}</td>
<td class="align-left normal-cell-padding" width="50%">
{{ item.name }}
{% if item.customFields | length -%}
({% for field in item.customFields -%}
{{ field.name }}: {{ field.value }}{% if loop.last != true %}, {% endif %}
{%- endfor %})
{%- endif -%}
</td>
<td class="align-right normal-cell-padding nowrap"><nobr>{{ craft.snipcart.formatCurrency(item.price, order.currency) }}</nobr></td>
<td class="align-right last-cell-padding nowrap"><nobr>{{ craft.snipcart.formatCurrency(item.price * item.quantity, order.currency) }}</nobr></td>
</tr>
{% endfor %}
<tr>
<td class="subtotal align-right first-cell-padding" colspan="3">{{ order.shippingMethod }}<br><span class="muted mono">{{ (shipStationOrder.weight.value ?? order.totalWeight) | number_format }} {{ "grams"|t }}</span></td>
<td class="align-right last-cell-padding nowrap"><nobr>{{ craft.snipcart.formatCurrency(order.shippingFees, order.currency) }}</nobr></td>
</tr>
<tr>
<td class="subtotal align-right first-cell-padding" colspan="3">Tax</td>
<td class="align-right last-cell-padding nowrap"><nobr>{{ craft.snipcart.formatCurrency(order.taxesTotal, order.currency) }}</nobr></td>
</tr>
<tr>
<td class="subtotal align-right first-cell-padding" colspan="3">
{{ "Grand Total"|t }}<br>
<span class="muted mono">
{{- order.paymentMethod }}{% if order.paymentMethod == 'CreditCard' %} {{ order.creditCardLast4Digits }}{% endif -%}
</span>
</td>
<td class="align-right last-cell-padding nowrap">
<nobr><b>{{ craft.snipcart.formatCurrency(order.finalGrandTotal, order.currency) }}</b></nobr>
</td>
</tr>
</tbody>
</table>
{% for customField in order.customFields %}
{% if customField.value is not empty %}
<h3>{{ customField.name|t }}</h3>
<p class="no-top-margin">{{ customField.value }}</p>
{% endif %}
{% endfor %}
{% if order.shippingAddressSameAsBilling %}
<h3>{{ "Billing + Shipping Address"|t }}</h3>
<p class="no-top-margin">
{{- order.billingAddressName }}<br>
{{ order.billingAddressAddress1 }}<br>
{% if order.billingAddressAddress2 %}
{{ order.billingAddressAddress2 }}<br>
{% endif %}
{{ order.billingAddressCity }}, {{ order.billingAddressProvince }} {{ order.billingAddressPostalCode }}
{% if order.billingAddressCountry != "US" %}<br>{{ order.billingAddressCountry }}{% endif -%}
</p>
<p class="no-top-margin">{{ order.billingAddress.formattedPhone }}</p>
{% else %}
<h3>{{ "Billing Address"|t }}</h3>
<p class="no-top-margin">
{{- order.billingAddressName }}<br>
{{ order.billingAddressAddress1 }}<br>
{% if order.billingAddressAddress2 %}
{{ order.billingAddressAddress2 }}<br>
{% endif %}
{{ order.billingAddressCity }}, {{ order.billingAddressProvince }} {{ order.billingAddressPostalCode }}
{% if order.billingAddressCountry != "US" %}<br>{{ order.billingAddressCountry }}{% endif -%}
</p>
<p class="no-top-margin">{{ order.billingAddress.formattedPhone }}</p>
<h3>{{ "Shipping Address"|t }}</h3>
<p class="no-top-margin">
{{- order.shippingAddressName }}<br>
{{ order.shippingAddressAddress1 }}<br>
{% if order.shippingAddressAddress2 %}
{{ order.shippingAddressAddress2 }}<br>
{% endif %}
{{ order.shippingAddressCity }}, {{ order.shippingAddressProvince }} {{ order.shippingAddressPostalCode }}
{% if order.shippingAddressCountry != "US" %}<br>{{ order.shippingAddressCountry }}{% endif -%}
</p>
<p class="no-top-margin">{{ order.shippingAddress.formattedPhone }}</p>
{% endif %}
{#
TODO: re-add quantity notes, but access Craft Elements via order.items.getRelatedElement()
{% if settings.reduceQuantitiesOnOrder and settings.productInventoryField %}
<h3>{{ "Remaining Quantities"|t }}</h3>
<ul class="no-top-margin">
{% for element in elements %}
<li><span style="{% if entry.productInventory == 0 %}color: red;{% endif %}">{{ elements.title }}: <b>{{ elements[settings.productInventoryField] }}</b></span></li>
{% endfor %}
</ul>
{% endif %}
#}
<p style="margin-top: 40px;" class="muted mono">{{ order.ipAddress }}<br>{{ order.userAgent }}</p>
{% endblock content %}