Error executing template "Designs/Swift-v2/eCom/Order/EmailOrderlines.cshtml"
System.ArgumentNullException: Value cannot be null. (Parameter 'currency')
at System.ArgumentNullException.Throw(String paramName)
at Dynamicweb.Ecommerce.International.CurrencyService.Format(Currency currency, Double value, Boolean showSymbol)
at CompiledRazorTemplates.Dynamic.RazorEngine_0ec8e888ddc849a58fb7927b92798134.ExecuteAsync()
at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
2 @using Dynamicweb.Frontend
3
4 @functions {
5 private string GetFontStack()
6 {
7 return "font-family:initial,Arial,Helvetica Neue,Helvetica,sans-serif;";
8 }
9
10 private string GetTableReset()
11 {
12 return "border:0;margin:0;outline:0;padding:0;";
13 }
14 }
15
16 @{
17 string textPrice = "font-variant-numeric:tabular-nums;break-inside:avoid;word-break:keep-all;white-space:nowrap;";
18 string showPricesWithVat = Pageview?.Area?.EcomPricesWithVat != null ? Dynamicweb.Ecommerce.Common.Context.DisplayPricesWithVat.ToString() : "false";
19 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat);
20
21 @* Order lines *@
22 <table style="table-layout:fixed;@GetTableReset()" cellpadding="0" cellspacing="0" width="100%" role="presentation">
23 <tbody>
24
25 @foreach (LoopItem orderline in GetLoop("OrderLines"))
26 {
27 string name = orderline.GetString("Ecom:Order:OrderLine.ProductName");
28 string serverPath = $"{Dynamicweb.Context.Current?.Request.Url.Scheme}://{Dynamicweb.Context.Current?.Request.Url.Host}{(Dynamicweb.Context.Current?.Request.Url.Port > 0 ? ":" + Dynamicweb.Context.Current.Request.Url.Port : null)}";
29 string image = $"{serverPath}/Admin/Public/GetImage.ashx?image={orderline.GetString("Ecom:Product.PrimaryImage")}&width=100&height=100&crop=7";
30 var uri = Dynamicweb.Context.Current?.Request?.Url;
31 var hostname = uri?.Scheme + Uri.SchemeDelimiter + uri?.Host;
32 string priceTotalWithDiscounts = !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceFormatted")) ? orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceFormatted") : string.Empty;
33 string unitPrice = !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.UnitPrice.PriceFormatted")) ? orderline.GetString("Ecom:Order:OrderLine.UnitPrice.PriceFormatted") : string.Empty;
34 string discountPrice = !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.UnitPriceWithProductDiscount.PriceFormatted")) ? orderline.GetString("Ecom:Order:OrderLine.UnitPriceWithProductDiscount.PriceFormatted") : string.Empty;
35 string discountTotal = !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.TotalDiscount.PriceFormatted")) ? orderline.GetString("Ecom:Order:OrderLine.TotalDiscount.PriceFormatted") : string.Empty;
36 string variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText");
37 var quantity = orderline.GetDouble("Ecom:Order:OrderLine.Quantity");
38 bool isProduct = orderline.GetBoolean("Ecom:Order:OrderLine.IsProduct");
39
40 bool isGiftCardLine = orderline.GetInteger("Ecom:Order:OrderLine.Type") == (int)Dynamicweb.Ecommerce.Orders.OrderLineType.GiftCard;
41 Dynamicweb.Ecommerce.GiftCards.GiftCard purchasedGiftCard = isGiftCardLine
42 ? Dynamicweb.Ecommerce.Services.GiftCard.GetGiftCardsForOrderLine(orderline.GetString("Ecom:Order:OrderLine.Id"))
43 : null;
44
45 if (isProduct)
46 {
47 <tr style="@GetTableReset()">
48
49 @* Image *@
50 <td valign="top" width="108" style="@GetTableReset()padding-bottom:8px;">
51 <div align="left" style="font-size:2px;">
52 <img src="@image" alt="@name">
53 </div>
54 </td>
55
56 <td valign="top" style="@GetTableReset()padding-bottom:8px;">
57
58 <table style="border-collapse:collapse;table-layout:fixed;@GetTableReset()" cellpadding="0" cellspacing="0" width="100%" role="presentation">
59 <tbody>
60 @* Title *@
61 <tr style="@GetTableReset()">
62 <td style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;font-weight:bold;text-decoration:none;">
63 @name
64 </td>
65 </tr>
66
67 @* Gift card code and expiry *@
68 @if (purchasedGiftCard != null)
69 {
70 <tr style="@GetTableReset()">
71 <td style="@GetTableReset()@GetFontStack()line-height:18px;font-size:13px;text-decoration:none;">
72 @Translate("Gift card code"): <strong>@purchasedGiftCard.Code</strong><br>
73 @Translate("Valid until"): @purchasedGiftCard.ExpiryDate.ToShortDateString()
74 </td>
75 </tr>
76 }
77
78 @* Variants *@
79 <tr style="@GetTableReset()">
80 <td style="@GetTableReset()@GetFontStack()line-height:18px;font-size:13px;text-decoration:none;">
81 @variantText
82 </td>
83 </tr>
84
85 @* Unit price *@
86 <tr style="@GetTableReset()">
87 <td style="@GetTableReset()@GetFontStack()line-height:18px;font-size:13px;text-decoration:none;">
88 @if (discountPrice == unitPrice)
89 {
90 <span style="@(textPrice)">@unitPrice</span>
91 }
92 else
93 {
94 <span style="@(textPrice)">@discountPrice</span>
95 <span style="@(textPrice) text-decoration:line-through;">@unitPrice</span>
96 }
97 </td>
98 </tr>
99
100 @* Quantity *@
101 <tr style="@GetTableReset()">
102 <td style="@GetTableReset()@GetFontStack()line-height:18px;font-size:13px;text-decoration:none;">
103 @Translate("Qty"): @quantity
104 </td>
105 </tr>
106 </tbody>
107 </table>
108 </td>
109
110 @* Orderline total *@
111 <td valign="top" width="108" style="@GetTableReset()padding-bottom:8px;">
112 <table style="border-collapse:collapse;table-layout:fixed;@GetTableReset()text-align:right;" cellpadding="0" cellspacing="0" width="100%" role="presentation">
113 <tbody>
114 <tr style="@GetTableReset()">
115 <td style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;font-weight:bold;text-decoration:none;@(textPrice)">
116 @priceTotalWithDiscounts
117 </td>
118 </tr>
119
120 @if (orderline.GetDouble("Ecom:Order:OrderLine.TotalDiscount.Price.Value") != 0)
121 {
122 <tr style="@GetTableReset()">
123 <td style="@GetTableReset()@GetFontStack()line-height:18px;font-size:13px;text-decoration:none;@(textPrice)">
124 @discountTotal
125 </td>
126 </tr>
127 }
128 </tbody>
129 </table>
130 </td>
131 </tr>
132 }
133 }
134 </tbody>
135 </table>
136
137 @* Summary *@
138 <table style="table-layout:fixed;@GetTableReset()padding-top:16px;border-top:1px solid;" cellpadding="0" cellspacing="0" width="100%" role="presentation">
139 <tbody>
140 <tr style="@GetTableReset()">
141 @{
142 double totalPriceWithoutOrderDiscountsFeesAndTaxesValue = GetDouble("Ecom:Order.TotalPriceWithoutDiscountsFeesAndTaxes.Price.Value") + GetDouble("Ecom:Order.TotalProductDiscount.Price.Value");
143 var orderCurrency = Dynamicweb.Ecommerce.Services.Currencies.GetCurrency(GetString("Ecom:Order.Currency.Code"));
144 string totalPriceWithoutOrderDiscountsFeesAndTaxes = Dynamicweb.Ecommerce.Services.Currencies.Format(orderCurrency, totalPriceWithoutOrderDiscountsFeesAndTaxesValue);
145 }
146
147 @* Subtotal *@
148 <td valign="top" width="35%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:15px;font-weight:bold;text-decoration:none;padding-bottom:8px;">
149 @Translate("Subtotal")
150 </td>
151 <td valign="top" width="65%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;text-decoration:none;text-align:right;padding-bottom:8px;">
152 @if (GetDouble("Ecom:Order.TotalPriceWithoutDiscountsFeesAndTaxes.Price.Value") != totalPriceWithoutOrderDiscountsFeesAndTaxesValue)
153 {
154 <span style="@(textPrice)text-decoration:line-through;">@GetString("Ecom:Order.TotalPriceWithoutDiscountsFeesAndTaxes.PriceFormatted")</span>
155 }
156 <span style="@(textPrice) font-weight:bold;">@totalPriceWithoutOrderDiscountsFeesAndTaxes</span>
157
158 @if (!neverShowVat && showPricesWithVat == "false")
159 {
160 <div>@Translate("Excl. VAT")</div>
161 }
162 @if (!neverShowVat && showPricesWithVat == "true")
163 {
164 <div>@Translate("Incl. VAT")</div>
165 }
166 </td>
167 </tr>
168
169 @* Discounts (only order discounts) *@
170 @foreach (LoopItem orderline in GetLoop("OrderLines"))
171 {
172 bool isDiscount = orderline.GetBoolean("Ecom:Order:OrderLine.IsDiscount");
173 bool isProductIdOrNumber = !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.ProductID")) || !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.ProductNumber")); //Live Cart orderlines may not return ProductId. Manually entered products may not have ProductNumber
174 bool isOrderAmountDiscount = orderline.GetInteger("Ecom:Order:OrderLine.Type") == 1 && !isProductIdOrNumber;
175 if (isDiscount && isOrderAmountDiscount)
176 {
177 <tr style="@GetTableReset()">
178 <td valign="top" width="35%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;text-decoration:none;padding-bottom:8px;">
179 @orderline.GetString("Ecom:Order:OrderLine.ProductName")
180 </td>
181 <td valign="top" width="65%" style="@GetTableReset()@GetFontStack()@(textPrice)line-height:18px;font-size:14px;text-decoration:none;text-align:right;padding-bottom:8px;">
182 @orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceFormatted")
183 </td>
184 </tr>
185 }
186 }
187
188 @* Shipping *@
189 @if (!string.IsNullOrEmpty(GetString("Ecom:Order.ShippingMethodID")) && GetDouble("Ecom:Order.ShippingFee.Price.Value") != 0.0)
190 {
191 <tr style="@GetTableReset()">
192 <td valign="top" width="35%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;text-decoration:none;padding-bottom:8px;">
193 @Translate("Delivery")
194 </td>
195 <td valign="top" width="65%" style="@GetTableReset()@GetFontStack()@(textPrice)line-height:18px;font-size:14px;text-decoration:none;text-align:right;padding-bottom:8px;">
196 @GetString("Ecom:Order.ShippingFee.PriceFormatted")
197 </td>
198 </tr>
199 }
200
201 @* Payment *@
202 @if (!string.IsNullOrEmpty(GetString("Ecom:Order.PaymentMethodID")))
203 {
204 if (GetDouble("Ecom:Order.PaymentFee.Price.Value") != 0)
205 {
206
207 <tr style="@GetTableReset()">
208 <td valign="top" width="35%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;text-decoration:none;padding-bottom:8px;">
209 @Translate("Payment")
210 </td>
211 <td valign="top" width="65%" style="@GetTableReset()@GetFontStack()@(textPrice)line-height:18px;font-size:14px;text-decoration:none;text-align:right;padding-bottom:8px;">
212 @GetString("Ecom:Order.PaymentFee.PriceFormatted")
213 </td>
214 </tr>
215 }
216 }
217
218 @* Taxes *@
219 @if (GetDouble("Ecom:Order.Taxes.Total.Price.Value") != 0)
220 {
221 <tr style="@GetTableReset()">
222 <td valign="top" width="35%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;text-decoration:none;padding-bottom:8px;">
223 @Translate("Sales tax")
224 </td>
225 <td valign="top" width="65%" style="@GetTableReset()@GetFontStack()@(textPrice)line-height:18px;font-size:14px;text-decoration:none;text-align:right;padding-bottom:8px;">
226 @GetString("Ecom:Order.Taxes.Total.PriceFormatted")
227 </td>
228 </tr>
229 }
230
231 @* Total *@
232 <tr style="@GetTableReset()">
233 <td valign="top" width="35%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:18px;font-weight:bold;text-decoration:none;padding-bottom:8px;padding-top:16px;border-top:1px solid;">
234 @Translate("Total")
235 </td>
236 <td valign="top" width="65%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;text-decoration:none;text-align:right;padding-bottom:8px;padding-top:16px;border-top:1px solid;">
237 <div style="@(textPrice)font-size:22px;font-weight:bold;">@GetString("Ecom:Order.Price.PriceFormatted")</div>
238 @if (!neverShowVat && showPricesWithVat == "false")
239 {
240 <div>@Translate("Excl. VAT")</div>
241 }
242 @if (!neverShowVat && showPricesWithVat == "true")
243 {
244 <div>@Translate("Incl. VAT")</div>
245 }
246 </td>
247 </tr>
248
249 @if (!neverShowVat)
250 {
251 <tr style="@GetTableReset()">
252 <td valign="top" width="35%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;text-decoration:none;padding-bottom:8px;">
253 @Translate("VAT")
254 </td>
255 <td valign="top" width="65%" style="@GetTableReset()@GetFontStack()@(textPrice)line-height:18px;font-size:14px;text-decoration:none;text-align:right;padding-bottom:8px;">
256 @GetString("Ecom:Order.Price.VATFormatted")
257 </td>
258 </tr>
259 if (showPricesWithVat == "false")
260 {
261 <tr style="@GetTableReset()">
262 <td valign="top" width="35%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;text-decoration:none;padding-bottom:8px;">
263 @Translate("Total incl. VAT")
264 </td>
265 <td valign="top" width="65%" style="@GetTableReset()@GetFontStack()@(textPrice)line-height:18px;font-size:14px;text-decoration:none;text-align:right;padding-bottom:8px;">
266 @GetString("Ecom:Order.Price.PriceWithVATFormatted")
267 </td>
268 </tr>
269 }
270 }
271
272 @if (GetDouble("Ecom:Order.TotalDiscount.Price.Value") != 0)
273 {
274 <tr style="@GetTableReset()">
275 <td valign="top" width="35%" style="@GetTableReset()@GetFontStack()line-height:18px;font-size:14px;text-decoration:none;padding-bottom:8px;">
276 @Translate("Discount")
277 </td>
278 <td valign="top" width="65%" style="@GetTableReset()@GetFontStack()@(textPrice)line-height:18px;font-size:14px;text-decoration:none;text-align:right;padding-bottom:8px;">
279 @GetString("Ecom:Order.TotalDiscount.PriceFormatted")
280 </td>
281 </tr>
282 }
283 </tbody>
284 </table>
285 }
286
|