Error executing template "Designs/Rapido/_parsed/Newsletter.parsed.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_6d1dc7131b1541089561b96fb100a0de.Execute() in E:\Solutions\Korsholm.test002.webtester.dk\Files\Templates\Designs\Rapido\_parsed\Newsletter.parsed.cshtml:line 947
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 2 @using Dynamicweb.Rendering; 3 4 @using Dynamicweb.Security.UserManagement 5 6 @functions { 7 public class Text 8 { 9 public string content { 10 get { 11 return string.Join("<br>", this.Lines.ToArray()); 12 } 13 set {} 14 } 15 public List<string> Lines { get; set; } 16 17 public Text() 18 { 19 Lines = new List<string>(); 20 } 21 22 public void Add(string textString) 23 { 24 Lines.Add(textString); 25 } 26 } 27 28 public class RowSettings 29 { 30 public string backgroundColor { get; set; } 31 public string smallScreenTable { get; set; } 32 public string background { get; set; } 33 public string padding { get; set; } 34 35 //Defaults 36 public RowSettings() 37 { 38 backgroundColor = "#FFFFFF"; 39 background = ""; 40 padding = "25"; 41 } 42 } 43 44 public class Column 45 { 46 public string image { get; set; } 47 public string icon { get; set; } 48 public string imageSize { get; set; } 49 public string preheader { get; set; } 50 public string introheader { get; set; } 51 public string header { get; set; } 52 public string subheader { get; set; } 53 public Text text { get; set; } 54 public string textColor { get; set; } 55 public string introheaderTextColor { get; set; } 56 public string align { get; set; } 57 public string link { get; set; } 58 public string altText { get; set; } 59 public string linkText { get; set; } 60 public string buttonColor { get; set; } 61 public string buttonType { get; set; } 62 public string buttonAlign { get; set; } 63 public string width { get; set; } 64 65 //Defaults 66 public Column() 67 { 68 textColor = "#333"; 69 introheaderTextColor = "#333"; 70 align = "left"; 71 buttonColor = "#EC683B"; 72 buttonType = "Primary"; 73 buttonAlign = "left"; 74 75 //Initialize the text object 76 this.text = new Text(); 77 } 78 79 public bool isEmpty() 80 { 81 return string.IsNullOrEmpty(this.image) && 82 string.IsNullOrEmpty(this.preheader) && 83 string.IsNullOrEmpty(this.introheader) && 84 string.IsNullOrEmpty(this.header) && 85 string.IsNullOrEmpty(this.subheader) && 86 string.IsNullOrEmpty(this.text.content) && 87 string.IsNullOrEmpty(this.link) && 88 string.IsNullOrEmpty(this.linkText); 89 } 90 } 91 92 string emailBgColor = "#d3d3d3"; 93 string emailTextColor = "color:#828282;"; 94 string emailTableBorder = "border-top:1px solid #a8a8a8;"; 95 string emailText = "font-family:Helvetica,Arial,sans-serif;font-size:13px;color:#828282;text-align:center;line-height:120%;"; 96 string emailTextLarge = "font-family:Helvetica,Arial,sans-serif;font-size:15px;margin-bottom:0;line-height:135%;word-break: break-word;"; 97 string emailTextSmall = "line-height:125%;font-family:Helvetica,Arial,sans-serif;font-size:10px;font-weight:normal;margin-top:0;margin-bottom:3px;"; 98 string emailHeaderOneStyle = "text-transform:uppercase;line-height:135%;font-family:Helvetica,Arial,sans-serif;font-size:15px;font-weight:normal;margin-bottom:5px;"; 99 string emailHeaderTwoStyle = "font-weight:normal;font-family:Helvetica,Arial,sans-serif;font-size:23px;margin-bottom:10px;line-height:135%;"; 100 string emailHeaderThreeStyle = "line-height:125%;font-family:Helvetica,Arial,sans-serif;font-size:20px;font-weight:normal;margin-top:0;margin-bottom:3px;"; 101 string emailTableFixedStyle = "table-layout: fixed;max-width:100% !important;width: 100% !important;min-width: 100% !important;"; 102 string emailLinkStyle = "text-decoration:none;color:#828282;"; 103 string emailLinkUnderlineStyle = "text-decoration:underline;color:#828282;"; 104 string emailTableWidth = "500"; 105 string emailTableMaxWidth = "max-width:100%;"; 106 string emailFlexibleImage = "height: auto !important;max-width: 100% !important;display: block;"; 107 string emailHiddenBlock = "display:none !important; mso-hide:all;"; 108 string emailNoTopBottomInnerSpace = "padding-top:0px;padding-bottom:0px;"; 109 string emailContent = "height:100% !important;margin:0;padding:0;width:100% !important;font-family:Helvetica, Arial,'Lucida Grande',sans-serif;"; 110 } 111 112 @helper CreatePreheader(string viewInBrowserLink = "#") 113 { 114 <!-- EMAIL HEADER // --> 115 <!-- 116 The table "emailBody" is the email's container. 117 Its width can be set to 100% for a color band 118 that spans the width of the page. 119 --> 120 <table class="content--bg" bgcolor="@emailBgColor" border="0" cellpadding="0" cellspacing="0" width="@emailTableWidth" id="emailHeader"> 121 122 <!-- HEADER ROW // --> 123 <tr> 124 <td align="center" valign="top"> 125 <!-- CENTERING TABLE // --> 126 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 127 <tr> 128 <td align="center" valign="top"> 129 <!-- FLEXIBLE CONTAINER // --> 130 <table border="0" cellpadding="10" cellspacing="0" width="@emailTableWidth"> 131 <tr> 132 <td valign="top" width="@emailTableWidth"> 133 134 <!-- CONTENT TABLE // --> 135 <table align="left" border="0" cellpadding="0" cellspacing="0" width="100%"> 136 <tr> 137 <!-- 138 The "invisibleIntroduction" is the text used for short preview 139 of the email before the user opens it (50 characters max). Sometimes, 140 you do not want to show this message depending on your design but this 141 text is highly recommended. 142 143 You do not have to worry if it is hidden, the next <td> will automatically 144 center and apply to the width 100% and also shrink to 50% if the first <td> 145 is visible. 146 --> 147 <td class="content--hidden" align="left" valign="middle" id="invisibleIntroduction" style="@emailHiddenBlock"> 148 <table border="0" cellpadding="0" cellspacing="0" width="100%" style="@emailTableMaxWidth"> 149 <tr> 150 <td align="left"> 151 <div class="text" style="@emailText"> 152 153 </div> 154 </td> 155 </tr> 156 </table> 157 </td> 158 <td align="right" valign="middle"> 159 <table border="0" cellpadding="0" cellspacing="0" width="100%" style="@emailTableMaxWidth"> 160 <tr> 161 <td align="left"> 162 <!-- CONTENT // --> 163 <div class="text" style="@emailText"> 164 @Translate("If you can't see this message") 165 @{ 166 string title = Translate("View it in your browser"); 167 } 168 <a href="@viewInBrowserLink" class="link" target="_blank" style="@emailLinkUnderlineStyle;" title="@title"> 169 <span class="label" style="@emailTextColor">@Translate("view it in your browser")</span> 170 </a>. 171 </div> 172 </td> 173 </tr> 174 </table> 175 </td> 176 </tr> 177 </table> 178 </td> 179 </tr> 180 </table> 181 <!-- // FLEXIBLE CONTAINER --> 182 </td> 183 </tr> 184 </table> 185 <!-- // CENTERING TABLE --> 186 </td> 187 </tr> 188 <!-- // END --> 189 190 </table> 191 <!-- // END --> 192 } 193 194 @helper CreateSubscriptionFooter(string subscriptionLink = "#") 195 { 196 <!-- EMAIL FOOTER // --> 197 <!-- 198 The table "emailBody" is the email's container. 199 Its width can be set to 100% for a color band 200 that spans the width of the page. 201 --> 202 <table class="content--bg" bgcolor="@emailBgColor" border="0" cellpadding="0" cellspacing="0" width="@emailTableWidth" id="emailFooter"> 203 204 <!-- FOOTER ROW // --> 205 <!-- 206 To move or duplicate any of the design patterns 207 in this email, simply move or copy the entire 208 MODULE ROW section for each content block. 209 --> 210 <tr> 211 <td align="center" valign="top"> 212 <!-- CENTERING TABLE // --> 213 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 214 <tr> 215 <td align="center" valign="top"> 216 <!-- FLEXIBLE CONTAINER // --> 217 <table border="0" cellpadding="0" cellspacing="0" width="@emailTableWidth"> 218 <tr> 219 <td align="center" valign="top" width="@emailTableWidth"> 220 <table border="0" cellpadding="30" cellspacing="0" width="100%"> 221 <tr> 222 <td class="content--bg" valign="top" bgcolor="@emailBgColor"> 223 224 <div class="text" style="@emailText"> 225 <div>@Translate("Click here if you wish to") <a href="@subscriptionLink" class="link link--no-decoration" target="_blank" style="@emailLinkStyle;" title="@Translate(" unsubscribe")"=""><span class="label" style="@emailTextColor">@Translate("unsubscribe")</span></a>.</div> 226 </div> 227 228 </td> 229 </tr> 230 </table> 231 </td> 232 </tr> 233 </table> 234 <!-- // FLEXIBLE CONTAINER --> 235 </td> 236 </tr> 237 </table> 238 <!-- // CENTERING TABLE --> 239 </td> 240 </tr> 241 </table> 242 <!-- // END --> 243 } 244 245 @helper CreateRow(Column columnObjectOne, RowSettings rowSettings = null) 246 { 247 if (rowSettings == null) 248 { 249 rowSettings = new RowSettings(); 250 } 251 252 if (string.IsNullOrEmpty(columnObjectOne.imageSize)) 253 { 254 columnObjectOne.imageSize = "500"; 255 } 256 257 if (string.IsNullOrEmpty(columnObjectOne.width)) 258 { 259 columnObjectOne.width = "500"; 260 } 261 262 if (string.IsNullOrEmpty(columnObjectOne.align)) 263 { 264 columnObjectOne.align = "center"; 265 } 266 267 @CreateOneColumn(columnObjectOne, rowSettings); 268 } 269 270 @helper CreateRow(Column columnObjectOne, Column columnObjectTwo, RowSettings rowSettings = null) 271 { 272 if (rowSettings == null) 273 { 274 rowSettings = new RowSettings(); 275 } 276 277 if (string.IsNullOrEmpty(columnObjectOne.imageSize)) 278 { 279 columnObjectOne.imageSize = "210"; 280 } 281 282 if (string.IsNullOrEmpty(columnObjectTwo.imageSize)) 283 { 284 columnObjectTwo.imageSize = "210"; 285 } 286 287 if (string.IsNullOrEmpty(columnObjectOne.width)) 288 { 289 columnObjectOne.width = "210"; 290 } 291 292 if (string.IsNullOrEmpty(columnObjectTwo.width)) 293 { 294 columnObjectTwo.width = "210"; 295 } 296 297 @CreateTwoColumns(columnObjectOne, columnObjectTwo, rowSettings); 298 } 299 300 @helper CreateRow(Column columnObjectOne, Column columnObjectTwo, Column columnObjectThree, RowSettings rowSettings = null) 301 { 302 if (rowSettings == null) 303 { 304 rowSettings = new RowSettings(); 305 } 306 307 if (string.IsNullOrEmpty(columnObjectOne.imageSize)) 308 { 309 columnObjectOne.imageSize = "126"; 310 } 311 312 if (string.IsNullOrEmpty(columnObjectTwo.imageSize)) 313 { 314 columnObjectTwo.imageSize = "126"; 315 } 316 317 if (string.IsNullOrEmpty(columnObjectThree.imageSize)) 318 { 319 columnObjectThree.imageSize = "126"; 320 } 321 322 if (string.IsNullOrEmpty(columnObjectOne.width)) 323 { 324 columnObjectOne.width = "126"; 325 } 326 327 if (string.IsNullOrEmpty(columnObjectTwo.width)) 328 { 329 columnObjectTwo.width = "126"; 330 } 331 332 if (string.IsNullOrEmpty(columnObjectThree.width)) 333 { 334 columnObjectThree.width = "126"; 335 } 336 337 @CreateThreeColumns(columnObjectOne, columnObjectTwo, columnObjectThree, rowSettings); 338 } 339 340 @helper CreateRowDivider() 341 { 342 <tr> 343 <td align="center" valign="top"> 344 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 345 <tr> 346 <td align="center" valign="top"> 347 <table border="0" cellpadding="0" cellspacing="0" width="@emailTableWidth"> 348 <tr> 349 <td class="no-top-bottom-inner-space" align="center" valign="top" style="@emailNoTopBottomInnerSpace"> 350 <table border="0" cellpadding="0" cellspacing="0" width="100%"> 351 <tr> 352 <td class="table-content-border--top" align="center" valign="top" style="@emailTableBorder"></td> 353 </tr> 354 </table> 355 </td> 356 </tr> 357 </table> 358 </td> 359 </tr> 360 </table> 361 </td> 362 </tr> 363 } 364 365 @helper CreateOneColumn(Column columnObject, RowSettings rowSettings) 366 { 367 <tr> 368 <td align="center" valign="top"> 369 <table border="0" cellpadding="0" cellspacing="0" width="500" style="color:@columnObject.textColor; background: @rowSettings.background;" bgcolor="@rowSettings.backgroundColor"> 370 <tr> 371 <td align="center" valign="top"> 372 <table border="0" cellpadding="0" cellspacing="0" width="@columnObject.width"> 373 <tr> 374 <td align="@columnObject.align" valign="top" width="@emailTableWidth"> 375 <table border="0" cellpadding="@rowSettings.padding" cellspacing="0" width="100%"> 376 <tr> 377 <td align="@columnObject.align" style="text-align: @columnObject.align" valign="top"> 378 @CreateColumnBlock(columnObject) 379 </td> 380 </tr> 381 </table> 382 </td> 383 </tr> 384 </table> 385 </td> 386 </tr> 387 </table> 388 </td> 389 </tr> 390 } 391 392 @helper CreateTwoColumns(Column columnObjectOne, Column columnObjectTwo, RowSettings rowSettings) 393 { 394 <tr mc:hideable="mc:hideable"> 395 <td align="center" valign="top"> 396 <table border="0" cellpadding="0" cellspacing="0" width="100%" style="color:@columnObjectOne.textColor" bgcolor="@rowSettings.backgroundColor"> 397 <tr> 398 <td align="center" valign="top"> 399 <table border="0" cellpadding="10" cellspacing="0" width="@emailTableWidth"> 400 <tr> 401 <td valign="top" width="@emailTableWidth"> 402 <table align="center" border="0" cellpadding="10" cellspacing="0" width="100%"> 403 <tr> 404 <td align="left" valign="top"> 405 <table border="0" cellpadding="0" cellspacing="0" width="@columnObjectOne.width" style="@emailTableMaxWidth"> 406 <tr> 407 <td align="left"> 408 @CreateColumnBlock(columnObjectOne) 409 </td> 410 </tr> 411 </table> 412 </td> 413 <td align="right" valign="top"> 414 <table border="0" cellpadding="0" cellspacing="0" width="@columnObjectTwo.width" style="@emailTableMaxWidth"> 415 <tr> 416 <td align="left"> 417 @CreateColumnBlock(columnObjectTwo) 418 </td> 419 </tr> 420 </table> 421 </td> 422 </tr> 423 </table> 424 </td> 425 </tr> 426 </table> 427 </td> 428 </tr> 429 </table> 430 </td> 431 </tr> 432 } 433 434 @helper CreateThreeColumns(Column columnObjectOne, Column columnObjectTwo, Column columnObjectThree, RowSettings rowSettings) 435 { 436 <tr mc:hideable="mc:hideable"> 437 <td align="center" valign="top"> 438 <table border="0" cellpadding="0" cellspacing="0" width="100%" style="color:@columnObjectOne.textColor" bgcolor="@rowSettings.backgroundColor"> 439 <tr> 440 <td align="center" valign="top"> 441 <table border="0" cellpadding="10" cellspacing="0" width="@emailTableWidth"> 442 <tr> 443 <td valign="top" width="@emailTableWidth"> 444 <table align="left" border="0" cellpadding="10" cellspacing="0" width="100%"> 445 <tr> 446 <td align="left" valign="top"> 447 <table border="0" cellpadding="0" cellspacing="0" width="@columnObjectOne.width" style="@emailTableMaxWidth"> 448 <tr> 449 <td align="left"> 450 @CreateColumnBlock(columnObjectOne) 451 </td> 452 </tr> 453 </table> 454 </td> 455 <td align="center" valign="top"> 456 <table border="0" cellpadding="0" cellspacing="0" width="@columnObjectTwo.width" style="@emailTableMaxWidth"> 457 <tr> 458 <td align="left"> 459 @CreateColumnBlock(columnObjectTwo) 460 </td> 461 </tr> 462 </table> 463 </td> 464 <td align="right" valign="top"> 465 <table border="0" cellpadding="0" cellspacing="0" width="@columnObjectThree.width" style="@emailTableMaxWidth"> 466 <tr> 467 <td align="left"> 468 @CreateColumnBlock(columnObjectThree) 469 </td> 470 </tr> 471 </table> 472 </td> 473 </tr> 474 </table> 475 </td> 476 </tr> 477 </table> 478 </td> 479 </tr> 480 </table> 481 </td> 482 </tr> 483 } 484 485 @helper CreateColumnBlock(Column columnObject) 486 { 487 @CreateColumnBlockContent(columnObject) 488 } 489 490 @helper CreateColumnBlockContent(Column columnObject) 491 { 492 if (!String.IsNullOrEmpty(columnObject.preheader)) 493 { 494 <small class="text text--small" style="color:@columnObject.textColor;text-align:@columnObject.align;@emailTextSmall;">@columnObject.preheader</small> 495 } 496 497 if (!string.IsNullOrEmpty(columnObject.image)) 498 { 499 string image = Dynamicweb.Context.Current.Request.Url.Scheme + "://" + GetGlobalValue("Global:Request.Host") + "/Admin/Public/GetImage.ashx?width=" + columnObject.imageSize + "&crop=1&image=" + columnObject.image; 500 string altText = !string.IsNullOrEmpty(columnObject.altText) ? columnObject.altText : columnObject.linkText; 501 if (!string.IsNullOrEmpty(columnObject.link) && !string.IsNullOrEmpty(altText)) 502 { 503 <a href="@columnObject.link" style="display: inline-block" title="@altText"> 504 <img src="@image" width="@columnObject.imageSize" class="flexibleImage" style="@emailFlexibleImage" alt="@altText"> 505 </a> 506 } 507 else 508 { 509 <img src="@image" width="@columnObject.imageSize" class="flexibleImage" style="@emailFlexibleImage" alt="@altText"> 510 } 511 } 512 513 if (!String.IsNullOrEmpty(columnObject.image) && (!String.IsNullOrEmpty(columnObject.introheader) || !String.IsNullOrEmpty(columnObject.header) || !String.IsNullOrEmpty(columnObject.text.content))) 514 { 515 <br> 516 } 517 518 if (!String.IsNullOrEmpty(columnObject.introheader)) 519 { 520 <h1 style="color:@columnObject.introheaderTextColor;text-align:@columnObject.align;@emailHeaderOneStyle">@columnObject.introheader</h1> 521 } 522 523 if (!String.IsNullOrEmpty(columnObject.header)) 524 { 525 <h2 style="color:@columnObject.textColor;text-align:@columnObject.align;@emailHeaderTwoStyle"> 526 @if (!String.IsNullOrEmpty(columnObject.icon)) 527 { 528 <img src="@columnObject.icon" class="flexibleImage" style="@emailFlexibleImage" alt="@columnObject.header"> 529 } 530 @columnObject.header 531 </h2> 532 } 533 534 if (!String.IsNullOrEmpty(columnObject.subheader)) 535 { 536 <h3 style="color:@columnObject.textColor;text-align:@columnObject.align;@emailHeaderThreeStyle">@columnObject.subheader</h3> 537 } 538 539 if (!String.IsNullOrEmpty(columnObject.text.content)) 540 { 541 <div class="text text--large text--center" style="color:@columnObject.textColor;text-align:@columnObject.align;@emailTextLarge">@columnObject.text.content</div> 542 } 543 544 if (!String.IsNullOrEmpty(columnObject.link) && !String.IsNullOrEmpty(columnObject.linkText)) 545 { 546 string bgColor = "#EC683B"; 547 string borderColor = "#EC683B"; 548 string fontColor = "#FFFFFF"; 549 string fontSize = "17"; 550 string fontWeight = "normal"; 551 string buttonDesign = ""; 552 string buttonDesignStyles = ""; 553 string borderRadius = ""; 554 string textAlignment = "center"; 555 556 if (!String.IsNullOrEmpty(columnObject.buttonType)) 557 { 558 string btnId; 559 560 switch (columnObject.buttonType) 561 { 562 case "Link": 563 btnId = null; 564 bgColor = ""; 565 borderColor = ""; 566 string linksColor = Dynamicweb.Core.Converter.ToString(Pageview.AreaSettings.GetItem("Layout").GetString("LinksColor")); 567 fontColor = !String.IsNullOrEmpty(linksColor) ? linksColor : "#333"; 568 buttonDesignStyles = "background-color: transparent; text-decoration: underline; padding: 0;"; 569 textAlignment = "left"; 570 break; 571 case "Secondary": 572 btnId = "SecondaryButton"; 573 break; 574 case "Tertiary": 575 btnId = "TertiaryButton"; 576 break; 577 default: 578 btnId = "PrimaryButton"; 579 break; 580 } 581 582 if (!String.IsNullOrEmpty(btnId)) 583 { 584 var item = Pageview.AreaSettings.GetItem("Layout").GetItem(btnId); 585 586 if (item != null) 587 { 588 if (!String.IsNullOrEmpty(item.GetString("BackgroundColor"))) 589 { 590 bgColor = item.GetString("BackgroundColor"); 591 borderColor = item.GetString("BackgroundColor"); 592 } 593 if (!String.IsNullOrEmpty(item.GetString("FontColor"))) 594 { 595 fontColor = item.GetString("FontColor"); 596 } 597 if (!String.IsNullOrEmpty(item.GetString("FontSize"))) 598 { 599 fontSize = item.GetString("FontSize"); 600 } 601 if (!String.IsNullOrEmpty(item.GetString("FontWeight"))) 602 { 603 fontWeight = item.GetString("FontWeight"); 604 } 605 if (!String.IsNullOrEmpty(item.GetString("ButtonDesign"))) 606 { 607 buttonDesign = item.GetString("ButtonDesign"); 608 } 609 } 610 611 switch (buttonDesign) 612 { 613 case "rounded": 614 borderRadius = "0.2rem"; 615 buttonDesignStyles = "border: 1px " + borderColor + " solid; border-radius: " + borderRadius + "; background-color:" + bgColor + ";"; 616 break; 617 case "round": 618 borderRadius = "200px"; 619 buttonDesignStyles = "border: 1px " + borderColor + " solid; border-radius: " + borderRadius + "; background-color:" + bgColor + ";"; 620 break; 621 case "outline-square": 622 borderRadius = "0"; 623 bgColor = "transparent"; 624 buttonDesignStyles = "border: 1px " + borderColor + " solid; border-radius: " + borderRadius + "; background-color:" + bgColor + ";"; 625 break; 626 case "outline-rounded": 627 borderRadius = "0.2rem"; 628 bgColor = "transparent"; 629 buttonDesignStyles = "border: 1px " + borderColor + " solid; border-radius: " + borderRadius + "; background-color:" + bgColor + ";"; 630 break; 631 case "outline-round": 632 borderRadius = "200px"; 633 bgColor = "transparent"; 634 buttonDesignStyles = "border: 1px " + borderColor + " solid; border-radius: " + borderRadius + "; background-color:" + bgColor + ";"; 635 break; 636 default: 637 borderRadius = "0"; 638 buttonDesignStyles = "border: 1px " + borderColor + " solid; border-radius: " + borderRadius + "; background-color:" + bgColor + ";"; 639 break; 640 } 641 } 642 } 643 644 <table width="100%" border="0" cellspacing="0" cellpadding="0"> 645 <tr> 646 <td> 647 <table align="@columnObject.buttonAlign" style="text-align: @columnObject.buttonAlign" border="0" cellspacing="0" cellpadding="0"> 648 <tr> 649 <td align="@columnObject.buttonAlign" style="text-align: @columnObject.buttonAlign; border-radius: @borderRadius;" bgcolor="@bgColor"> 650 <a href="@columnObject.link" style="display: inline-block;padding: 10px;text-align: center; text-decoration:none;font-family:Helvetica,Arial,sans-serif; color: @fontColor; font-size: @(Int32.Parse(fontSize) + 2)px; font-weight: @fontWeight; @buttonDesignStyles; width: inherit" target="_blank" title="@columnObject.linkText"> 651 @columnObject.linkText 652 </a> 653 </td> 654 </tr> 655 </table> 656 </td> 657 </tr> 658 </table> 659 } 660 } 661 662 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 663 <html xmlns="http://www.w3.org/1999/xhtml"> 664 <head> 665 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 666 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 667 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 668 <meta name="format-detection" content="telephone=no"> <!-- disable auto telephone linking in iOS --> 669 <title>@GetValue("Title")</title> 670 @GetValue("MetaTags") 671 @GetValue("CopyRightNotice") 672 673 <style type="text/css"> 674 675 /* RESET STYLES */ 676 html { 677 background-color: #d3d3d3; 678 margin: 0; 679 padding: 0; 680 } 681 682 table { 683 border-collapse: collapse; 684 } 685 686 img, a img { 687 border: 0; 688 outline: none; 689 text-decoration: none; 690 height: auto; 691 line-height: 100%; 692 } 693 694 a { 695 text-decoration: none !important; 696 border-bottom: none; 697 font-weight: normal; 698 } 699 700 /* Force Hotmail/Outlook.com to display line heights normally. */ 701 table, td { 702 mso-table-lspace: 0pt; 703 mso-table-rspace: 0pt; 704 } 705 706 h1, h2, h3, h4, h5, h6 { 707 display: block; 708 margin-top: 0; 709 margin-right: 0; 710 margin-bottom: 5px; 711 margin-left: 0; 712 padding-top: 0; 713 padding-bottom: 0; 714 padding-left: 0; 715 padding-right: 0; 716 color: #5F5F5F; 717 font-weight: normal; 718 font-style: normal; 719 font-family: Helvetica,Arial,sans-serif; 720 line-height: 135%; 721 text-align: Left; 722 letter-spacing: normal; 723 } 724 725 h1 { 726 margin-bottom: 5px; 727 font-size: 15px; 728 text-transform: uppercase; 729 } 730 731 h2 { 732 margin-bottom: 10px; 733 font-size: 23px; 734 } 735 736 h3 { 737 margin-bottom: 3px; 738 font-size: 20px; 739 line-height: 125%; 740 } 741 742 h4 { 743 font-size: 18px; 744 font-style: italic; 745 line-height: 100%; 746 } 747 748 /* STYLES */ 749 750 .table--fixed { 751 table-layout: fixed; 752 max-width: 100% !important; 753 width: 100% !important; 754 min-width: 100% !important; 755 } 756 757 .table-content-border--top { 758 border-top: 1px solid #a8a8a8; 759 } 760 761 .content { 762 height: 100% !important; 763 margin: 0; 764 padding: 0; 765 width: 100% !important; 766 font-family: Helvetica, Arial, "Lucida Grande", sans-serif; 767 } 768 769 .content--bg { 770 background-color: #d3d3d3; 771 } 772 773 .content--hidden { 774 display: none !important; 775 mso-hide: all; 776 } 777 778 .label { 779 color: #828282; 780 } 781 782 .text { 783 font-size: 13px; 784 line-height: 120%; 785 font-weight: normal; 786 color: #828282; 787 } 788 789 .text--small { 790 margin-top: 0; 791 margin-bottom: 3px; 792 font-size: 10px; 793 line-height: 125%; 794 } 795 796 .text--large { 797 margin-bottom: 0; 798 font-size: 15px; 799 line-height: 135%; 800 } 801 802 .text--center { 803 text-align: center; 804 } 805 806 .link { 807 color: #828282; 808 text-decoration: underline; 809 } 810 811 .link--no-decoration { 812 text-decoration: none; 813 } 814 815 .no-top-bottom-inner-space { 816 padding-top: 0px; 817 padding-bottom: 0px; 818 } 819 820 /* MOBILE STYLES */ 821 @@media only screen and (max-width: 480px) { 822 823 .flexibleImage { 824 height: auto !important; 825 width: 100% !important; 826 max-width: 100% !important; 827 } 828 } 829 830 /* CONDITIONS FOR ANDROID DEVICES ONLY 831 * http://developer.android.com/guide/webapps/targeting.html 832 * http://pugetworks.com/2011/04/css-media-queries-for-targeting-different-mobile-devices/ 833 */ 834 835 @@media only screen and (-webkit-device-pixel-ratio:.75) { 836 /* Put CSS for low density (ldpi) Android layouts in here */ 837 } 838 839 @@media only screen and (-webkit-device-pixel-ratio:1) { 840 /* Put CSS for medium density (mdpi) Android layouts in here */ 841 } 842 843 @@media only screen and (-webkit-device-pixel-ratio:1.5) { 844 /* Put CSS for high density (hdpi) Android layouts in here */ 845 } 846 /* end Android targeting */ 847 848 /* CONDITIONS FOR IOS DEVICES ONLY 849 =====================================================*/ 850 @@media only screen and (min-device-width : 320px) and (max-device-width:568px) { 851 } 852 /* end IOS targeting */ 853 </style> 854 855 @GetValue("Stylesheets") 856 @GetValue("Javascripts") 857 </head> 858 859 @{ 860 string emailBgColor = "#d3d3d3"; 861 string emailContent = "height:100% !important;margin:0;padding:0;width:100% !important;font-family:Helvetica, Arial,'Lucida Grande',sans-serif;"; 862 string emailTableFixedStyle = "table-layout: fixed;max-width:100% !important;width: 100% !important;min-width: 100% !important;"; 863 } 864 865 <body class="content content--bg" bgcolor="@emailBgColor" style="@emailContent" marginwidth="0" marginheight="0" offset="0"> 866 <center class="content--bg" bgcolor="@emailBgColor"> 867 <table class="content table--fixed" border="0" cellpadding="0" cellspacing="0" height="100%" width="100%" id="bodyTable" style="@(emailTableFixedStyle + emailContent)"> 868 <tr> 869 <td class="content" align="center" valign="top" id="bodyCell" style="@emailContent"> 870 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 871 @using Dynamicweb.Rendering; 872 @using Dynamicweb.Extensibility 873 @using Dynamicweb.Content 874 @using Dynamicweb.Security; 875 876 877 @inherits RazorTemplateBase<RazorTemplateModel<Template>> 878 @using Dynamicweb.Rendering; 879 @using Dynamicweb.Core; 880 @using System.Linq; 881 @using Dynamicweb.Ecommerce.Orders; 882 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts; 883 @using System.Text.RegularExpressions; 884 @using S_DW_Korsholm.CustomCode.Constants 885 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 886 887 888 @* 889 This is a temporary fallback for the DefaultImage. The image pattern MUST be set up like this: 890 891 ImageSmall = /{ProductNumber}.jpg 892 ImageMedium = /{ProductNumber}{VariantOptionLevel1}.jpg 893 ImageLarge = /{ProductNumber}{VariantComboName}.jpg 894 895 In addition to the ImageDefault setting 896 *@ 897 898 @functions { 899 public string GetProductImage(LoopItem productObject = null) 900 { 901 string theImage = ""; 902 903 if (productObject == null) { 904 theImage = GetString("Ecom:Product.ImageDefault.Default.Clean"); 905 theImage = String.IsNullOrEmpty(theImage) ? GetString("Ecom:Product.ImageLarge.Clean") : theImage; 906 theImage = String.IsNullOrEmpty(theImage) ? GetString("Ecom:Product.ImageMedium.Clean") : theImage; 907 theImage = String.IsNullOrEmpty(theImage) ? GetString("Ecom:Product.ImageSmall.Clean") : theImage; 908 theImage = String.IsNullOrEmpty(theImage) ? GetString("Ecom:Product.ImageLarge.Default.Clean") : theImage; 909 } else { 910 theImage = productObject.GetString("Ecom:Product.ImageDefault.Default.Clean"); 911 theImage = String.IsNullOrEmpty(theImage) ? productObject.GetString("Ecom:Product.ImageLarge.Clean") : theImage; 912 theImage = String.IsNullOrEmpty(theImage) ? productObject.GetString("Ecom:Product.ImageMedium.Clean") : theImage; 913 theImage = String.IsNullOrEmpty(theImage) ? productObject.GetString("Ecom:Product.ImageSmall.Clean") : theImage; 914 theImage = String.IsNullOrEmpty(theImage) ? productObject.GetString("Ecom:Product.ImageLarge.Default.Clean") : theImage; 915 } 916 917 return theImage; 918 } 919 } 920 921 @functions{ 922 string logoimage; 923 string emailFontColor; 924 string emailBackgroundColor; 925 string emailLogoAlignment; 926 string emailFooterAlignment; 927 928 Column GetAddressColumn(string prefix, string type) 929 { 930 Column column = new Column(); 931 column.text.Add(GetString("Ecom:" + prefix + "." + type + ".Company")); 932 column.text.Add(GetString("Ecom:" + prefix + "." + type + ".Name")); 933 column.text.Add(GetString("Ecom:" + prefix + "." + type + ".Address")); 934 column.text.Add(GetString("Ecom:" + prefix + "." + type + ".Zip") + " " + GetString("Ecom:" + prefix + "." + type + ".City")); 935 column.text.Add(GetString("Ecom:" + prefix + "." + type + ".Region")); 936 column.text.Add(GetString("Ecom:" + prefix + "." + type + ".Country")); 937 column.text.Add("<a href='mailto:" + GetString("Ecom:" + prefix + "." + type + ".Email") + "' style='text-decoration: none ;pointer-events: none;' title='" + GetString("Ecom:" + prefix + "." + type + ".Email") + "'>" + GetString("Ecom:" + prefix + "." + type + ".Email") + "</a>"); 938 column.text.Add("<a href='tel:" + GetString("Ecom:" + prefix + "." + type + ".Phone") + "' style='text-decoration: none; ;pointer-events: none;' title='" + GetString("Ecom:" + prefix + "." + type + ".Phone") + "'>" + GetString("Ecom:" + prefix + "." + type + ".Phone") + "</a>"); 939 return column; 940 } 941 } 942 943 @{ 944 945 if (Pageview != null && Pageview.AreaSettings != null) 946 { 947 logoimage = Converter.ToString(Pageview.AreaSettings.GetItem("Layout").GetItem("Emails").GetFile("LogoImage").PathUrlEncoded); 948 emailFontColor = Converter.ToString(Pageview.AreaSettings.GetItem("Layout").GetItem("Emails").GetString("HeaderAndFooterFontColor")); 949 emailFontColor = !string.IsNullOrEmpty(emailFontColor) ? emailFontColor : "#FFFFFF"; 950 emailBackgroundColor = Converter.ToString(Pageview.AreaSettings.GetItem("Layout").GetItem("Emails").GetString("HeaderAndFooterBackgroundColor")); 951 emailBackgroundColor = !string.IsNullOrEmpty(emailBackgroundColor) ? emailBackgroundColor : "#14304A"; 952 emailFooterAlignment = Converter.ToString(Pageview.AreaSettings.GetItem("Layout").GetItem("Emails").GetString("FooterAlignment")); 953 emailFooterAlignment = !string.IsNullOrEmpty(emailFooterAlignment) ? emailFooterAlignment : "right"; 954 emailLogoAlignment = Converter.ToString(Pageview.AreaSettings.GetItem("Layout").GetItem("Emails").GetString("LogoAlignment")); 955 emailLogoAlignment = !string.IsNullOrEmpty(emailLogoAlignment) ? emailLogoAlignment : "center"; 956 } 957 } 958 959 @helper RenderHeaderImage() 960 { 961 Column header = new Column(); 962 header.image = logoimage; 963 header.imageSize = "250"; 964 header.textColor = emailFontColor; 965 header.align = emailLogoAlignment; 966 header.altText = Translate("Go to frontpage"); 967 header.link = "/"; 968 969 @CreateRow(header, new RowSettings { backgroundColor = emailBackgroundColor }); 970 } 971 972 @helper RenderFooterSection() 973 { 974 string footeremail = Converter.ToString(Pageview.AreaSettings.GetItem("Settings").GetString("ContactEmail")); 975 string footerphone = Converter.ToString(Pageview.AreaSettings.GetItem("Settings").GetString("ContactNumber")).Replace(" ", ""); 976 977 Column footerRight = new Column(); 978 footerRight.textColor = emailFontColor; 979 footerRight.image = logoimage; 980 footerRight.imageSize = "200"; 981 footerRight.altText = Translate("Logo"); 982 footerRight.align = emailFooterAlignment; 983 footerRight.altText = Translate("Go to frontpage"); 984 footerRight.link = "/"; 985 986 footerRight.text.Add("<p></p>"); 987 footerRight.text.Add("<a href='tel:" + footerphone + "' style='color: " + emailFontColor + "; text-decoration: none; border-bottom: 0;' title='" + footerphone + "'>" + footerphone + "</a>"); 988 footerRight.text.Add("<a href='mailto:" + footeremail + "' style='color: " + emailFontColor + "; text-decoration: none; border-bottom: 0;' title='" + footeremail + "'>" + footeremail + "</a>"); 989 footerRight.text.Add(""); 990 991 string iconsHTML = ""; 992 var socialLinks = Pageview.AreaSettings.GetItem("Layout").GetItems("FooterSocialLinks"); 993 foreach (var socialitem in socialLinks) 994 { 995 var socialIcon = socialitem.GetValue("Icon") as Dynamicweb.Frontend.ListViewModel; 996 string socialIconClass = socialIcon.SelectedValue; 997 string socialIconTitle = socialIcon.SelectedName; 998 string socialLink = socialitem.GetString("Link"); 999 socialIconClass = Dynamicweb.Context.Current.Request.Url.Scheme + "://" + GetGlobalValue("Global:Request.Host") + "/Admin/Public/GetImage.ashx?width=35&image=" + "/Files/Images/SocialIcons/" + socialIconClass + ".png"; 1000 1001 iconsHTML += " <a href='" + socialLink + "' style='color: white; text-decoration: none; border-bottom: 0; display: inline-block; width: 35px; height: 35px; background-image:url(\"" + socialIconClass + "\")' title='" + socialIconTitle + "'></a>"; 1002 } 1003 footerRight.text.Add(iconsHTML); 1004 1005 @CreateRow(footerRight, new RowSettings { backgroundColor = emailBackgroundColor }); 1006 } 1007 1008 @helper RenderRecurringDetails() 1009 { 1010 if (GetBoolean("Ecom:Order.IsRecurringOrder")) 1011 { 1012 Column recurringInfo = new Column(); 1013 recurringInfo.text.Add(Translate("You have placed a subscription. This is a confirmation of the subscription not the actual order receipt.")); 1014 recurringInfo.align = "center"; 1015 1016 @CreateRow(recurringInfo); 1017 1018 @CreateRowDivider(); 1019 } 1020 1021 if (GetBoolean("Ecom:Order.IsBasedOnRecurringOrder")) 1022 { 1023 Column basedRecurringInfo = new Column(); 1024 basedRecurringInfo.text.Add(Translate("Your subscription order")); 1025 basedRecurringInfo.align = "center"; 1026 1027 @CreateRow(basedRecurringInfo); 1028 1029 @CreateRowDivider(); 1030 } 1031 } 1032 1033 @helper RenderComments() 1034 { 1035 if (!string.IsNullOrWhiteSpace(GetString("Ecom:Order.Customer.Comment"))) 1036 { 1037 Column comment = new Column(); 1038 comment.subheader = Translate("Comment"); 1039 comment.text.Add(GetString("Ecom:Order.Customer.Comment")); 1040 1041 @CreateRow(comment); 1042 1043 @CreateRowDivider(); 1044 } 1045 } 1046 1047 @helper RenderAddresses(string billingTitle, string deliveryTitle, string prefix) 1048 { 1049 Column billingInfo = GetAddressColumn(prefix, "Customer"); 1050 billingInfo.header = billingTitle; 1051 var fix = GetString("Ecom:Order.Delivery.Name"); //without this delivery tags will not be rendered :( 1052 Column shippingInfo = GetAddressColumn(prefix, !string.IsNullOrEmpty(GetString("Ecom:" + prefix + ".Delivery.Address")) ? "Delivery" : "Customer"); 1053 shippingInfo.header = deliveryTitle; 1054 @CreateRow(billingInfo, shippingInfo, new RowSettings { backgroundColor = "#e4e4e4", smallScreenTable = "table-smallScreen" }); 1055 } 1056 1057 @helper RenderPaymentAndShipping() 1058 { 1059 string businessName = Pageview.AreaSettings.GetItem("Settings").GetItem("Address").GetString("Name"); 1060 string businessCountry = Pageview.AreaSettings.GetItem("Settings").GetItem("Address").GetString("Country"); 1061 string businessCity = Pageview.AreaSettings.GetItem("Settings").GetItem("Address").GetString("City"); 1062 string businessRegion = Pageview.AreaSettings.GetItem("Settings").GetItem("Address").GetString("Region"); 1063 string businessZip = Pageview.AreaSettings.GetItem("Settings").GetItem("Address").GetString("PostalCode"); 1064 string businessAddress = Pageview.AreaSettings.GetItem("Settings").GetItem("Address").GetString("StreetAddress"); 1065 string businessCVR = Pageview.AreaSettings.GetItem("Settings").GetItem("Address").GetString("CVRNumber"); 1066 1067 Column leftColumn = new Column(); 1068 Column shopInfo = new Column(); 1069 1070 leftColumn.header = Translate("Payment and shipping"); 1071 1072 if (!string.IsNullOrEmpty(GetString("Ecom:Order.PaymentMethod"))) 1073 { 1074 leftColumn.text.Add(Translate("Payment method") + ": " + Translate(GetString("Ecom:Order.PaymentMethod"))); 1075 } 1076 1077 if (!string.IsNullOrEmpty(GetString("Ecom:Order.ShippingMethod"))) 1078 { 1079 leftColumn.text.Add(Translate("Shipping method") + ": " + Translate(GetString("Ecom:Order.ShippingMethod"))); 1080 } 1081 1082 if (!string.IsNullOrEmpty(GetString("Ecom:Order.TransactionCardNumber"))) 1083 { 1084 leftColumn.text.Add(Translate("Card no") + ": " + GetString("Ecom:Order.TransactionCardNumber")); 1085 } 1086 if (!string.IsNullOrEmpty(GetString("Ecom:Order.TransactionNumber"))) 1087 { 1088 leftColumn.text.Add(Translate("Transaction no") + ": " + GetString("Ecom:Order.TransactionNumber")); 1089 } 1090 if (!string.IsNullOrEmpty(GetString("Ecom:Order.TransactionStatus"))) 1091 { 1092 leftColumn.text.Add(Translate("Transaction status") + ": " + GetString("Ecom:Order.TransactionStatus")); 1093 } 1094 1095 //Shop 1096 if (!string.IsNullOrEmpty(businessAddress)) 1097 { 1098 shopInfo.header = Translate("Shop"); 1099 1100 shopInfo.text.Add(businessName); 1101 shopInfo.text.Add(businessAddress); 1102 1103 if (!string.IsNullOrEmpty(businessRegion)) 1104 { 1105 businessRegion += " "; //add space between region and country 1106 } 1107 shopInfo.text.Add(businessZip + " " + businessCity + ", " + businessRegion + businessCountry); 1108 1109 if (!string.IsNullOrEmpty(businessCVR)) 1110 { 1111 shopInfo.text.Add(Translate("Business number") + ": " + businessCVR); 1112 } 1113 } 1114 1115 @CreateRow(leftColumn, shopInfo, new RowSettings { backgroundColor = "#e4e4e4" }); 1116 } 1117 1118 @helper RenderOrderline(LoopItem orderline, bool showImage = true) 1119 { 1120 Column orderLineLeft = new Column(); 1121 1122 Column orderLineCenter = new Column(); 1123 1124 Column orderLineRight = new Column(); 1125 orderLineRight.align = "right"; 1126 1127 string orderLineType = orderline.GetString("Ecom:Order:OrderLine.Type"); 1128 if (orderLineType == "1" || orderLineType == "3" || orderLineType == "4") 1129 { 1130 string productName = orderline.GetString("Ecom:Order:OrderLine.ProductName"); 1131 1132 productName = Pageview.Area.EcomShopId == Shops.GuntexShopId ? orderline.GetString("Ecom:Order:OrderLine.ProductName").Split(' ')[1] : orderline.GetString("Ecom:Order:OrderLine.ProductName"); 1133 1134 //Discount 1135 orderLineCenter.text.Add(productName); 1136 orderLineRight.text.Add("<strong>" + orderline.GetString("Ecom:Order:OrderLine.TotalPrice") + "</strong>"); 1137 @CreateRow(orderLineCenter, orderLineRight); 1138 } 1139 else 1140 { 1141 if (showImage) 1142 { 1143 orderLineLeft.image = GetProductImage(orderline); 1144 orderLineLeft.altText = orderline.GetString("Ecom:Order:OrderLine.ProductName"); 1145 } 1146 1147 //Product 1148 orderLineCenter.text.Add(orderline.GetString("Ecom:Order:OrderLine.ProductName")); 1149 if (!string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.ProductNumber"))) 1150 { 1151 orderLineCenter.text.Add("# " + orderline.GetString("Ecom:Order:OrderLine.ProductNumber")); 1152 } 1153 if (!string.IsNullOrWhiteSpace(orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"))) 1154 { 1155 orderLineCenter.text.Add(orderline.GetString("Ecom:Order:OrderLine.ProductVariantText")); 1156 } 1157 1158 orderLineCenter.text.Add(Translate("Qty") + ": " + orderline.GetString("Ecom:Order:OrderLine.Quantity")); 1159 orderLineRight.text.Add(orderline.GetString("Ecom:Order:OrderLine.Price.PriceFormatted")); 1160 1161 if (showImage) 1162 { 1163 orderLineLeft.width = "105"; 1164 orderLineLeft.imageSize = "105"; 1165 orderLineCenter.width = "165"; 1166 orderLineRight.width = "110"; 1167 @CreateRow(orderLineLeft, orderLineCenter, orderLineRight); 1168 } 1169 else 1170 { 1171 orderLineCenter.width = "270"; 1172 orderLineRight.width = "110"; 1173 @CreateRow(orderLineCenter, orderLineRight); 1174 } 1175 //BOM Items 1176 foreach (LoopItem bomitem in orderline.GetLoop("BOMItems")) 1177 { 1178 var bomImage = GetProductImage(bomitem); 1179 1180 Column bomLineLeft = new Column(); 1181 if (showImage) 1182 { 1183 bomLineLeft.image = bomImage; 1184 } 1185 Column bomLineCenter = new Column(); 1186 bomLineCenter.text.Add(bomitem.GetString("Ecom:Order:OrderLine.ProductName")); 1187 bomLineCenter.text.Add("# " + bomitem.GetString("Ecom:Order:OrderLine.ProductNumber")); 1188 bomLineCenter.text.Add(Translate("Qty") + ": " + bomitem.GetString("Ecom:Order:OrderLine.Quantity")); 1189 1190 Column bomLineRight = new Column(); 1191 bomLineRight.text.Add(bomitem.GetString("Ecom:Order:OrderLine.TotalPrice")); 1192 bomLineRight.align = "right"; 1193 1194 if (showImage) 1195 { 1196 bomLineLeft.width = "105"; 1197 bomLineLeft.imageSize = "105"; 1198 bomLineCenter.width = "165"; 1199 bomLineRight.width = "110"; 1200 @CreateRow(bomLineLeft, bomLineCenter, bomLineRight, new RowSettings { backgroundColor = "#e4e4e4" }); 1201 } 1202 else 1203 { 1204 bomLineCenter.width = "270"; 1205 bomLineRight.width = "110"; 1206 @CreateRow(bomLineCenter, bomLineRight, new RowSettings { backgroundColor = "#e4e4e4" }); 1207 } 1208 } 1209 } 1210 @CreateRowDivider() 1211 } 1212 1213 @functions { 1214 public class ProductDesign 1215 { 1216 public string imagePosition { get; set; } 1217 public bool separationLines { get; set; } 1218 public string backgroundColor { get; set; } 1219 public string fontColor { get; set; } 1220 public bool showViewButton { get; set; } 1221 public string viewButtonText { get; set; } 1222 1223 //Defaults 1224 public ProductDesign() 1225 { 1226 imagePosition = "left"; 1227 separationLines = true; 1228 backgroundColor = "#FFFFFF"; 1229 fontColor = "#000000"; 1230 showViewButton = true; 1231 viewButtonText = "View"; 1232 } 1233 } 1234 1235 Column getProductColumn(LoopItem product, ProductDesign design) 1236 { 1237 Column productColumn = new Column 1238 { 1239 align = "center", 1240 image = GetProductImage(product), 1241 altText = product.GetString("Ecom:Product.Name"), 1242 textColor = design.fontColor, 1243 buttonAlign = "center" 1244 }; 1245 1246 string variantId = !string.IsNullOrEmpty(product.GetString("Ecom:Product.VariantID")) ? product.GetString("Ecom:Product.VariantID") : product.GetString("Ecom:Product.VariantID.Extented"); 1247 string link = link = Dynamicweb.Context.Current.Request.Url.Scheme + "://" + GetGlobalValue("Global:Request.Host"); 1248 link += "/" + product.GetString("Ecom:Product.LinkGroup.Clean") + (!string.IsNullOrWhiteSpace(variantId) ? "&VariantID=" + variantId : ""); 1249 productColumn.link = link; 1250 1251 productColumn.text.Add(string.Format("<a href='{0}' title='{1}' style='{2}'><strong style='word-break: break-word;'>{1}</strong></a>", link, product.GetString("Ecom:Product.Name"), emailLinkStyle)); 1252 1253 if (!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product.VariantText"))) 1254 { 1255 productColumn.text.Add(product.GetString("Ecom:Product.VariantText")); 1256 } 1257 1258 if (!string.IsNullOrEmpty(product.GetString("Ecom:Product.Number"))) 1259 { 1260 productColumn.text.Add("# " + product.GetString("Ecom:Product.Number")); 1261 } 1262 1263 productColumn.text.Add("<br><strong>" + product.GetString("Ecom:Product.Price") + "</strong>"); 1264 1265 if (design.showViewButton && !string.IsNullOrEmpty(design.viewButtonText)) 1266 { 1267 productColumn.text.Add("<br>"); 1268 productColumn.linkText = Translate(design.viewButtonText); 1269 } 1270 1271 return productColumn; 1272 } 1273 } 1274 1275 @helper RenderProduct(LoopItem product) 1276 { 1277 @RenderProduct(product, new ProductDesign()); 1278 } 1279 1280 @helper RenderProduct(LoopItem product, ProductDesign design) 1281 { 1282 Column productImage = new Column 1283 { 1284 width = "105", 1285 imageSize = "105", 1286 textColor = design.fontColor, 1287 image = GetProductImage(product), 1288 altText = product.GetString("Ecom:Product.Name") 1289 }; 1290 1291 Column productPrice = new Column 1292 { 1293 width = "110", 1294 align = design.imagePosition == "left" ? "right" : "left", 1295 textColor = design.fontColor 1296 }; 1297 productPrice.text.Add("<strong>" + product.GetString("Ecom:Product.Price") + "</strong><br>"); 1298 1299 1300 Column productInfo = new Column 1301 { 1302 width = "165", 1303 textColor = design.fontColor, 1304 buttonAlign = "left" 1305 }; 1306 1307 string variantId = !string.IsNullOrEmpty(product.GetString("Ecom:Product.VariantID")) ? product.GetString("Ecom:Product.VariantID") : product.GetString("Ecom:Product.VariantID.Extented"); 1308 string link = Dynamicweb.Context.Current.Request.Url.Scheme + "://" + GetGlobalValue("Global:Request.Host"); 1309 link += "/" + product.GetString("Ecom:Product.LinkGroup.Clean") + (!string.IsNullOrWhiteSpace(variantId) ? "&VariantID=" + variantId : ""); 1310 productImage.link = link; 1311 1312 productInfo.text.Add(string.Format("<a href='{0}' title='{1}' style='{2}'><strong style='word-break: break-word;'>{1}</strong></a>", link, product.GetString("Ecom:Product.Name"), emailLinkStyle)); 1313 1314 if (!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product.VariantText"))) 1315 { 1316 productInfo.text.Add(product.GetString("Ecom:Product.VariantText")); 1317 } 1318 1319 if (!string.IsNullOrEmpty(product.GetString("Ecom:Product.Number"))) 1320 { 1321 productInfo.text.Add("# " + product.GetString("Ecom:Product.Number")); 1322 } 1323 1324 if (design.showViewButton && !string.IsNullOrEmpty(design.viewButtonText)) 1325 { 1326 productInfo.text.Add("<br>"); 1327 productInfo.link = link; 1328 productInfo.linkText = Translate(design.viewButtonText); 1329 } 1330 1331 if (design.imagePosition == "left") 1332 { 1333 @CreateRow(productImage, productInfo, productPrice, new RowSettings { backgroundColor = design.backgroundColor }); 1334 } 1335 else if (design.imagePosition == "right") 1336 { 1337 @CreateRow(productPrice, productInfo, productImage, new RowSettings { backgroundColor = design.backgroundColor }); 1338 } 1339 if (design.separationLines) 1340 { 1341 @CreateRowDivider() 1342 } 1343 } 1344 1345 1346 @helper RenderGiftcards() 1347 { 1348 if (!string.IsNullOrWhiteSpace(GetString("Ecom:Order.HasGiftCards"))) 1349 { 1350 Column giftcardHeader = new Column(); 1351 giftcardHeader.header = Translate("Giftcards bought on this order"); 1352 giftcardHeader.align = "center"; 1353 1354 @CreateRow(giftcardHeader); 1355 1356 @CreateRowDivider(); 1357 1358 foreach (LoopItem giftcards in GetLoop("GiftCards")) 1359 { 1360 Column giftcardCode = new Column(); 1361 giftcardCode.subheader = Translate("Gift card code") + ": " + giftcards.GetString("Ecom:Order.GiftCard.Code"); 1362 1363 @CreateRow(giftcardCode); 1364 1365 Column giftcardLeft = new Column(); 1366 giftcardLeft.text.Add("<strong>" + giftcards.GetString("Ecom:Order.GiftCard.Name") + "</strong>"); 1367 giftcardLeft.text.Add(Translate("Expiry date") + ": " + giftcards.GetDate("Ecom:Order.GiftCard.ExpiryDate").ToString(Dynamicweb.Core.Helpers.DateHelper.DateFormatStringShort)); 1368 1369 Column giftcardRight = new Column(); 1370 giftcardRight.subheader = giftcards.GetString("Ecom:Order.GiftCard.Amount"); 1371 giftcardRight.align = "right"; 1372 1373 @CreateRow(giftcardLeft, giftcardRight); 1374 1375 @CreateRowDivider(); 1376 } 1377 } 1378 1379 if (!string.IsNullOrWhiteSpace(GetString("Ecom:Order.HasUsedGiftCards"))) 1380 { 1381 Column usedGiftcardHeader = new Column(); 1382 usedGiftcardHeader.subheader = Translate("Order used gift cards"); 1383 usedGiftcardHeader.align = "center"; 1384 1385 @CreateRow(usedGiftcardHeader); 1386 1387 @CreateRowDivider(); 1388 1389 foreach (LoopItem usedgiftcards in GetLoop("UsedGiftCards")) 1390 { 1391 Column giftcardLeft = new Column(); 1392 giftcardLeft.subheader = usedgiftcards.GetString("Ecom:Order.UsedGiftCard.Code"); 1393 giftcardLeft.text.Add(usedgiftcards.GetString("Ecom:Order.UsedGiftCard.Name")); 1394 giftcardLeft.text.Add(Translate("Expiry date") + " " + usedgiftcards.GetDate("Ecom:Order.UsedGiftCard.ExpiryDate").ToString(Dynamicweb.Core.Helpers.DateHelper.DateFormatStringShort)); 1395 1396 Column giftcardRight = new Column(); 1397 giftcardRight.subheader = usedgiftcards.GetString("Ecom:Order.UsedGiftCard.InitialAmount"); 1398 giftcardRight.text.Add(usedgiftcards.GetString("Ecom:Order.UsedGiftCard.UsedAmountForTheOrder")); 1399 giftcardRight.text.Add(usedgiftcards.GetString("Ecom:Order.UsedGiftCard.RemainingBalance")); 1400 giftcardRight.align = "right"; 1401 1402 @CreateRow(giftcardLeft, giftcardRight); 1403 1404 @CreateRowDivider(); 1405 } 1406 } 1407 } 1408 1409 1410 @helper RenderVouchers() 1411 { 1412 string voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); 1413 if (!string.IsNullOrWhiteSpace(voucherCode)) 1414 { 1415 Column vouchers = new Column(); 1416 vouchers.header = Translate("Vouchers"); 1417 vouchers.align = "center"; 1418 1419 string orderId = GetString("Ecom:Order.ID"); 1420 Order order = new OrderService().GetById(orderId); 1421 1422 IEnumerable<string> codes = new List<string>(); 1423 1424 if (order.VoucherUseType.HasFlag(VoucherUseCategoryType.Discount)) 1425 { 1426 codes = voucherCode.Split(new string[] { ",", ";", " " }, StringSplitOptions.RemoveEmptyEntries); 1427 } 1428 else 1429 { 1430 codes = new string[] { voucherCode.Trim() }; 1431 } 1432 1433 bool hasUsedVouchers = false; 1434 foreach (string code in codes) 1435 { 1436 Voucher vouch = Voucher.GetVoucherByCode(code); 1437 if (vouch != null && vouch.DateUsed.HasValue && string.Equals(vouch.UsedOrderId, orderId, StringComparison.OrdinalIgnoreCase)) 1438 { 1439 vouchers.text.Add(Translate("Voucher") + "<span style='font-weight:bold;'>" + code + "</span>" + Translate("has been used")); 1440 hasUsedVouchers = true; 1441 } 1442 } 1443 1444 if (hasUsedVouchers) 1445 { 1446 @CreateRow(vouchers); 1447 } 1448 } 1449 } 1450 1451 @helper RenderButton(string link, string text, string align = "left") 1452 { 1453 Column button = new Column(); 1454 button.link = link; 1455 button.linkText = Translate(text); 1456 button.buttonAlign = align; 1457 @CreateRow(button); 1458 } 1459 1460 @CreatePreheader("/Default.aspx?ID=" + GetString("Global.PageId")) 1461 <table bgcolor="#FFFFFF" border="0" cellpadding="0" cellspacing="0" width="500" id="emailBody"> 1462 @RenderHeaderImage() 1463 <tr><td><div id="mycontainer">@GetValue("DwContent(mycontainer)")</div></td></tr> 1464 @RenderFooterSection() 1465 </table> 1466 1467 @CreateSubscriptionFooter("{{EmailMarketing:Email.UnsubscribeLink.Clean}}") 1468 </td> 1469 </tr> 1470 </table> 1471 </center> 1472 </body> 1473 </html>