Error executing template "Designs/Rapido/eCom7/CartV2/Step/Cart.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_e74a4589664e4477bbde0c406fd03118.<RenderCartOrderlineTemplateCustom>b__82_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Cart.cshtml:line 4516
   at RazorEngine.Templating.TemplateWriter.ToString()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_e74a4589664e4477bbde0c406fd03118.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Cart.cshtml:line 207
   at CompiledRazorTemplates.Dynamic.RazorEngine_e74a4589664e4477bbde0c406fd03118.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Cart.cshtml:line 117
   at CompiledRazorTemplates.Dynamic.RazorEngine_e74a4589664e4477bbde0c406fd03118.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Cart.cshtml:line 240
   at CompiledRazorTemplates.Dynamic.RazorEngine_e74a4589664e4477bbde0c406fd03118.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Cart.cshtml:line 117
   at CompiledRazorTemplates.Dynamic.RazorEngine_e74a4589664e4477bbde0c406fd03118.<>c__DisplayClass3_0.<RenderBlock>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Cart.cshtml:line 240
   at CompiledRazorTemplates.Dynamic.RazorEngine_e74a4589664e4477bbde0c406fd03118.<>c__DisplayClass2_0.<RenderBlockList>b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Cart.cshtml:line 117
   at CompiledRazorTemplates.Dynamic.RazorEngine_e74a4589664e4477bbde0c406fd03118.Execute() in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Cart.cshtml:line 5534
   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 Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Content 5 @using Dynamicweb.Core 6 @using Dynamicweb.Ecommerce.Orders 7 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 8 @using System 9 @using System.IO 10 @using Dynamicweb.Rapido.Blocks 11 12 13 @functions{ 14 BlocksPage checkoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 15 string checkoutPageType = "onestep"; 16 } 17 18 @{ 19 Block checkoutTopSnippets = new Block() 20 { 21 Id = "CheckoutTopSnippets", 22 SortId = 10 23 }; 24 checkoutPage.Add(checkoutTopSnippets); 25 26 Block checkoutForm = new Block 27 { 28 Id = "CheckoutForm", 29 SortId = 20, 30 Template = RenderCheckoutForm(), 31 SkipRenderBlocksList = true, 32 BlocksList = new List<Block> 33 { 34 new Block() 35 { 36 Id = "AddressContainer", 37 SortId = 10, 38 Design = new Design 39 { 40 RenderType = RenderType.Column, 41 Size = "4", 42 HidePadding = true 43 }, 44 BlocksList = new List<Block> { 45 new Block() 46 { 47 Id = "AddressContainerRow", 48 SortId = 10, 49 Design = new Design 50 { 51 RenderType = RenderType.Row 52 } 53 } 54 } 55 }, 56 new Block() 57 { 58 Id = "OrderContainer", 59 SortId = 20, 60 Design = new Design 61 { 62 RenderType = RenderType.Column, 63 Size = "auto", 64 HidePadding = true 65 }, 66 BlocksList = new List<Block> { 67 new Block() 68 { 69 Id = "OrderContainerRow", 70 SortId = 10, 71 Design = new Design 72 { 73 RenderType = RenderType.Row 74 } 75 } 76 } 77 } 78 } 79 }; 80 checkoutPage.Add(checkoutForm); 81 82 Block checkoutBottomSnippets = new Block() 83 { 84 Id = "CheckoutBottomSnippets", 85 SortId = 30 86 }; 87 checkoutPage.Add(checkoutBottomSnippets); 88 } 89 90 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 91 @using System.Text.RegularExpressions 92 @using System.Collections.Generic 93 @using System.Reflection 94 @using System.Web 95 @using System.Web.UI.HtmlControls 96 @using Dynamicweb.Rapido.Blocks.Components 97 @using Dynamicweb.Rapido.Blocks.Components.Articles 98 @using Dynamicweb.Rapido.Blocks.Components.Documentation 99 @using Dynamicweb.Rapido.Blocks 100 101 102 @*--- START: Base block renderers ---*@ 103 104 @helper RenderBlockList(List<Block> blocks) 105 { 106 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 107 blocks = blocks.OrderBy(item => item.SortId).ToList(); 108 109 foreach (Block item in blocks) 110 { 111 if (debug) { 112 <!-- Block START: @item.Id --> 113 } 114 115 if (item.Design == null) 116 { 117 @RenderBlock(item) 118 } 119 else if (item.Design.RenderType == RenderType.None) { 120 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 121 122 <div class="@cssClass dw-mod"> 123 @RenderBlock(item) 124 </div> 125 } 126 else if (item.Design.RenderType != RenderType.Hide) 127 { 128 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 129 130 if (!item.SkipRenderBlocksList) { 131 if (item.Design.RenderType == RenderType.Row) 132 { 133 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 134 @RenderBlock(item) 135 </div> 136 } 137 138 if (item.Design.RenderType == RenderType.Column) 139 { 140 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 141 string size = item.Design.Size ?? "12"; 142 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 143 144 <div class="grid__col-lg-@item.Design.Size grid__col-md-@item.Design.Size grid__col-sm-12 grid__col-xs-12 @hidePadding @cssClass dw-mod" id="Block__@item.Id"> 145 @RenderBlock(item) 146 </div> 147 } 148 149 if (item.Design.RenderType == RenderType.Table) 150 { 151 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 152 @RenderBlock(item) 153 </table> 154 } 155 156 if (item.Design.RenderType == RenderType.TableRow) 157 { 158 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 159 @RenderBlock(item) 160 </tr> 161 } 162 163 if (item.Design.RenderType == RenderType.TableColumn) 164 { 165 <td class="@cssClass dw-mod" id="Block__@item.Id"> 166 @RenderBlock(item) 167 </td> 168 } 169 170 if (item.Design.RenderType == RenderType.CardHeader) 171 { 172 <div class="card-header @cssClass dw-mod"> 173 @RenderBlock(item) 174 </div> 175 } 176 177 if (item.Design.RenderType == RenderType.CardBody) 178 { 179 <div class="card @cssClass dw-mod"> 180 @RenderBlock(item) 181 </div> 182 } 183 184 if (item.Design.RenderType == RenderType.CardFooter) 185 { 186 <div class="card-footer @cssClass dw-mod"> 187 @RenderBlock(item) 188 </div> 189 } 190 } 191 else 192 { 193 @RenderBlock(item) 194 } 195 } 196 197 if (debug) { 198 <!-- Block END: @item.Id --> 199 } 200 } 201 } 202 203 @helper RenderBlock(Block item) 204 { 205 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 206 207 if (item.Template != null) 208 { 209 @BlocksPage.RenderTemplate(item.Template) 210 } 211 212 if (item.Component != null) 213 { 214 string customSufix = "Custom"; 215 string methodName = item.Component.HelperName; 216 217 ComponentBase[] methodParameters = new ComponentBase[1]; 218 methodParameters[0] = item.Component; 219 Type methodType = this.GetType(); 220 221 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 222 MethodInfo generalMethod = methodType.GetMethod(methodName); 223 224 try { 225 if (debug) { 226 <!-- Component: @methodName.Replace("Render", "") --> 227 } 228 @customMethod.Invoke(this, methodParameters).ToString(); 229 } catch { 230 try { 231 @generalMethod.Invoke(this, methodParameters).ToString(); 232 } catch(Exception ex) { 233 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 234 } 235 } 236 } 237 238 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 239 { 240 @RenderBlockList(item.BlocksList) 241 } 242 } 243 244 @*--- END: Base block renderers ---*@ 245 246 @using Dynamicweb.Rapido.Blocks.Components 247 @using Dynamicweb.Rapido.Blocks.Components.General 248 @using Dynamicweb.Rapido.Blocks 249 @using System.IO 250 251 @* Required *@ 252 @using Dynamicweb.Rapido.Blocks.Components 253 @using Dynamicweb.Rapido.Blocks.Components.General 254 @using Dynamicweb.Rapido.Blocks 255 256 257 @helper Render(ComponentBase component) 258 { 259 if (component != null) 260 { 261 @component.Render(this) 262 } 263 } 264 265 266 @* Components *@ 267 @using System.Reflection 268 @using Dynamicweb.Rapido.Blocks.Components.General 269 270 271 @* Component *@ 272 273 @helper RenderIcon(Icon settings) 274 { 275 if (settings != null) 276 { 277 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 278 279 if (settings.Name != null) 280 { 281 if (string.IsNullOrEmpty(settings.Label)) 282 { 283 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 284 } 285 else 286 { 287 if (settings.LabelPosition == IconLabelPosition.Before) 288 { 289 <span>@settings.Label <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i></span> 290 } 291 else 292 { 293 <span><i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> @settings.Label</span> 294 } 295 } 296 } 297 else if (!string.IsNullOrEmpty(settings.Label)) 298 { 299 @settings.Label 300 } 301 } 302 } 303 @using System.Reflection 304 @using Dynamicweb.Rapido.Blocks.Components.General 305 @using Dynamicweb.Rapido.Blocks.Components 306 @using Dynamicweb.Core 307 308 @* Component *@ 309 310 @helper RenderButton(Button settings) 311 { 312 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 313 { 314 Dictionary<string, string> attributes = new Dictionary<string, string>(); 315 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 316 if (settings.Disabled) { 317 attributes.Add("disabled", "true"); 318 classList.Add("disabled"); 319 } 320 321 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 322 { 323 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 324 @RenderConfirmDialog(settings); 325 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 326 } 327 328 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 329 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 330 if (!string.IsNullOrEmpty(settings.AltText)) 331 { 332 attributes.Add("title", settings.AltText); 333 } 334 else if (!string.IsNullOrEmpty(settings.Title)) 335 { 336 attributes.Add("title", settings.Title); 337 } 338 339 var onClickEvents = new List<string>(); 340 if (!string.IsNullOrEmpty(settings.OnClick)) 341 { 342 onClickEvents.Add(settings.OnClick); 343 } 344 if (!string.IsNullOrEmpty(settings.Href)) 345 { 346 onClickEvents.Add("location.href='" + settings.Href + "'"); 347 } 348 if (onClickEvents.Count > 0) 349 { 350 attributes.Add("onClick", string.Join(";", onClickEvents)); 351 } 352 353 if (settings.ButtonLayout != ButtonLayout.None) 354 { 355 classList.Add("btn"); 356 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 357 if (btnLayout == "linkclean") 358 { 359 btnLayout = "link-clean"; //fix 360 } 361 classList.Add("btn--" + btnLayout); 362 } 363 364 if (settings.Icon == null) 365 { 366 settings.Icon = new Icon(); 367 } 368 settings.Icon.Label = settings.Title; 369 370 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 371 372 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 373 } 374 } 375 376 @helper RenderConfirmDialog(Button settings) 377 { 378 Modal confirmDialog = new Modal { 379 Id = settings.Id, 380 Width = ModalWidth.Sm, 381 Heading = new Heading 382 { 383 Level = 2, 384 Title = settings.ConfirmTitle 385 }, 386 BodyText = settings.ConfirmText 387 }; 388 389 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 390 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 391 392 @Render(confirmDialog) 393 } 394 @using Dynamicweb.Rapido.Blocks.Components.General 395 @using Dynamicweb.Rapido.Blocks.Components 396 @using Dynamicweb.Core 397 398 @helper RenderDashboard(Dashboard settings) 399 { 400 var widgets = settings.GetWidgets(); 401 402 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 403 { 404 //set bg color for them 405 406 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 407 int r = Convert.ToInt16(color.R); 408 int g = Convert.ToInt16(color.G); 409 int b = Convert.ToInt16(color.B); 410 411 var count = widgets.Length; 412 var max = Math.Max(r, Math.Max(g, b)); 413 double step = 255.0 / (max * count); 414 var i = 0; 415 foreach (var widget in widgets) 416 { 417 i++; 418 419 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 420 widget.BackgroundColor = shade; 421 } 422 } 423 424 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 425 @foreach (var widget in widgets) 426 { 427 <div class="dashboard__widget"> 428 @Render(widget) 429 </div> 430 } 431 </div> 432 } 433 @using Dynamicweb.Rapido.Blocks.Components.General 434 @using Dynamicweb.Rapido.Blocks.Components 435 436 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 437 { 438 if (!string.IsNullOrEmpty(settings.Link)) 439 { 440 var backgroundStyles = ""; 441 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 442 { 443 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 444 } 445 446 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 447 <div class="u-center-middle u-color-light"> 448 @if (settings.Icon != null) 449 { 450 settings.Icon.CssClass += "widget__icon"; 451 @Render(settings.Icon) 452 } 453 <div class="widget__title">@settings.Title</div> 454 </div> 455 </a> 456 } 457 } 458 @using Dynamicweb.Rapido.Blocks.Components.General 459 @using Dynamicweb.Rapido.Blocks.Components 460 461 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 462 { 463 var backgroundStyles = ""; 464 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 465 { 466 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 467 } 468 469 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 470 <div class="u-center-middle u-color-light"> 471 @if (settings.Icon != null) 472 { 473 settings.Icon.CssClass += "widget__icon"; 474 @Render(settings.Icon) 475 } 476 <div class="widget__counter">@settings.Count</div> 477 <div class="widget__title">@settings.Title</div> 478 </div> 479 </div> 480 } 481 @using System.Reflection 482 @using Dynamicweb.Rapido.Blocks.Components.General 483 @using Dynamicweb.Rapido.Blocks.Components 484 @using Dynamicweb.Core 485 486 @* Component *@ 487 488 @helper RenderLink(Link settings) 489 { 490 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 491 { 492 Dictionary<string, string> attributes = new Dictionary<string, string>(); 493 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 494 if (settings.Disabled) 495 { 496 attributes.Add("disabled", "true"); 497 classList.Add("disabled"); 498 } 499 500 if (!string.IsNullOrEmpty(settings.AltText)) 501 { 502 attributes.Add("title", settings.AltText); 503 } 504 else if (!string.IsNullOrEmpty(settings.Title)) 505 { 506 attributes.Add("title", settings.Title); 507 } 508 509 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 510 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 511 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 512 attributes.Add("href", settings.Href); 513 514 if (settings.ButtonLayout != ButtonLayout.None) 515 { 516 classList.Add("btn"); 517 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 518 if (btnLayout == "linkclean") 519 { 520 btnLayout = "link-clean"; //fix 521 } 522 classList.Add("btn--" + btnLayout); 523 } 524 525 if (settings.Icon == null) 526 { 527 settings.Icon = new Icon(); 528 } 529 settings.Icon.Label = settings.Title; 530 531 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 532 { 533 settings.Rel = LinkRelType.Noopener; 534 } 535 if (settings.Target != LinkTargetType.None) 536 { 537 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 538 } 539 if (settings.Download) 540 { 541 attributes.Add("download", "true"); 542 } 543 if (settings.Rel != LinkRelType.None) 544 { 545 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 546 } 547 548 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 549 } 550 } 551 @using System.Reflection 552 @using Dynamicweb.Rapido.Blocks.Components 553 @using Dynamicweb.Rapido.Blocks.Components.General 554 @using Dynamicweb.Rapido.Blocks 555 556 557 @* Component *@ 558 559 @helper RenderRating(Rating settings) 560 { 561 if (settings.Score > 0) 562 { 563 int rating = settings.Score; 564 string iconType = "fa-star"; 565 566 switch (settings.Type.ToString()) { 567 case "Stars": 568 iconType = "fa-star"; 569 break; 570 case "Hearts": 571 iconType = "fa-heart"; 572 break; 573 case "Lemons": 574 iconType = "fa-lemon"; 575 break; 576 case "Bombs": 577 iconType = "fa-bomb"; 578 break; 579 } 580 581 <div class="u-ta-right"> 582 @for (int i = 0; i < settings.OutOf; i++) 583 { 584 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 585 } 586 </div> 587 } 588 } 589 @using System.Reflection 590 @using Dynamicweb.Rapido.Blocks.Components.General 591 @using Dynamicweb.Rapido.Blocks.Components 592 593 594 @* Component *@ 595 596 @helper RenderSelectFieldOption(SelectFieldOption settings) 597 { 598 Dictionary<string, string> attributes = new Dictionary<string, string>(); 599 if (settings.Checked) { attributes.Add("selected", "true"); } 600 if (settings.Disabled) { attributes.Add("disabled", "true"); } 601 if (settings.Value != null) { attributes.Add("value", settings.Value); } 602 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 603 604 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 605 } 606 @using System.Reflection 607 @using Dynamicweb.Rapido.Blocks.Components.General 608 @using Dynamicweb.Rapido.Blocks.Components 609 610 611 @* Component *@ 612 613 @helper RenderNavigation(Navigation settings) { 614 @RenderNavigation(new 615 { 616 id = settings.Id, 617 cssclass = settings.CssClass, 618 startLevel = settings.StartLevel, 619 endlevel = settings.EndLevel, 620 expandmode = settings.Expandmode, 621 sitemapmode = settings.SitemapMode, 622 template = settings.Template 623 }) 624 } 625 @using Dynamicweb.Rapido.Blocks.Components.General 626 @using Dynamicweb.Rapido.Blocks.Components 627 628 629 @* Component *@ 630 631 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 632 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 633 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 634 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 635 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 636 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 637 settings.SitemapMode = false; 638 639 @RenderNavigation(settings) 640 } 641 @using Dynamicweb.Rapido.Blocks.Components.General 642 @using Dynamicweb.Rapido.Blocks.Components 643 644 645 @* Component *@ 646 647 @helper RenderLeftNavigation(LeftNavigation settings) { 648 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 649 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 650 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 651 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 652 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 653 654 <div class="grid__cell"> 655 @RenderNavigation(settings) 656 </div> 657 } 658 @using System.Reflection 659 @using Dynamicweb.Rapido.Blocks.Components.General 660 @using Dynamicweb.Core 661 662 @* Component *@ 663 664 @helper RenderHeading(Heading settings) 665 { 666 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 667 { 668 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 669 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 670 671 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 672 if (!string.IsNullOrEmpty(settings.Link)) 673 { 674 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 675 } 676 else 677 { 678 if (settings.Icon == null) 679 { 680 settings.Icon = new Icon(); 681 } 682 settings.Icon.Label = settings.Title; 683 @Render(settings.Icon) 684 } 685 @("</" + tagName + ">"); 686 } 687 } 688 @using Dynamicweb.Rapido.Blocks.Components 689 @using Dynamicweb.Rapido.Blocks.Components.General 690 @using Dynamicweb.Rapido.Blocks 691 692 693 @* Component *@ 694 695 @helper RenderImage(Image settings) 696 { 697 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 698 { 699 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 700 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 701 702 if (settings.Caption != null) 703 { 704 @:<div> 705 } 706 707 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 708 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 709 710 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 711 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 712 @if (settings.Link != null) 713 { 714 <a href="@settings.Link"> 715 @RenderTheImage(settings) 716 </a> 717 } 718 else 719 { 720 @RenderTheImage(settings) 721 } 722 </div> 723 </div> 724 725 if (settings.Caption != null) 726 { 727 <span class="image-caption dw-mod">@settings.Caption</span> 728 @:</div> 729 } 730 } 731 else 732 { 733 if (settings.Caption != null) 734 { 735 @:<div> 736 } 737 if (!string.IsNullOrEmpty(settings.Link)) 738 { 739 <a href="@settings.Link"> 740 @RenderTheImage(settings) 741 </a> 742 } 743 else 744 { 745 @RenderTheImage(settings) 746 } 747 748 if (settings.Caption != null) 749 { 750 <span class="image-caption dw-mod">@settings.Caption</span> 751 @:</div> 752 } 753 } 754 } 755 756 @helper RenderTheImage(Image settings) 757 { 758 if (settings != null) 759 { 760 string placeholderImage = "/Files/Images/placeholder.gif"; 761 string imageEngine = "/Admin/Public/GetImage.ashx?"; 762 763 string imageStyle = ""; 764 765 switch (settings.Style) 766 { 767 case ImageStyle.Ball: 768 imageStyle = "grid__cell-img--ball"; 769 break; 770 } 771 772 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle) 773 { 774 if (settings.ImageDefault != null) 775 { 776 settings.ImageDefault.Height = settings.ImageDefault.Width; 777 } 778 if (settings.ImageMedium != null) 779 { 780 settings.ImageMedium.Height = settings.ImageMedium.Width; 781 } 782 if (settings.ImageSmall != null) 783 { 784 settings.ImageSmall.Height = settings.ImageSmall.Width; 785 } 786 } 787 788 string defaultImage = imageEngine; 789 string imageSmall = ""; 790 string imageMedium = ""; 791 792 if (settings.DisableImageEngine) 793 { 794 defaultImage = settings.Path; 795 } 796 else 797 { 798 if (settings.ImageDefault != null) 799 { 800 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 801 802 if (settings.Path.GetType() != typeof(string)) 803 { 804 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 805 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 806 } 807 else 808 { 809 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 810 } 811 } 812 813 if (settings.ImageSmall != null) 814 { 815 imageSmall = "data-src-small=\"" + imageEngine; 816 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 817 818 if (settings.Path.GetType() != typeof(string)) 819 { 820 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 821 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 822 } 823 else 824 { 825 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 826 } 827 828 imageSmall += "\""; 829 } 830 831 if (settings.ImageMedium != null) 832 { 833 imageMedium = "data-src-medium=\"" + imageEngine; 834 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 835 836 if (settings.Path.GetType() != typeof(string)) 837 { 838 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 839 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 840 } 841 else 842 { 843 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 844 } 845 846 imageMedium += "\""; 847 } 848 } 849 850 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 851 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 852 if (!string.IsNullOrEmpty(settings.Title)) 853 { 854 optionalAttributes.Add("alt", settings.Title); 855 optionalAttributes.Add("title", settings.Title); 856 } 857 858 if (settings.DisableLazyLoad) 859 { 860 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 861 } 862 else 863 { 864 <img id="@settings.Id" class="b-lazy @imageStyle @settings.CssClass dw-mod" src="@placeholderImage" data-src="@defaultImage" @imageSmall @imageMedium @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 865 } 866 } 867 } 868 @using System.Reflection 869 @using Dynamicweb.Rapido.Blocks.Components.General 870 @using Dynamicweb.Rapido.Blocks.Components 871 872 @* Component *@ 873 874 @helper RenderFileField(FileField settings) 875 { 876 var attributes = new Dictionary<string, string>(); 877 if (string.IsNullOrEmpty(settings.Id)) 878 { 879 settings.Id = Guid.NewGuid().ToString("N"); 880 } 881 882 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 883 if (settings.Disabled) { attributes.Add("disabled", "true"); } 884 if (settings.Required) { attributes.Add("required", "true"); } 885 if (settings.Multiple) { attributes.Add("multiple", "true"); } 886 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 887 if (string.IsNullOrEmpty(settings.ChooseFileText)) 888 { 889 settings.ChooseFileText = Translate("Choose file"); 890 } 891 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 892 { 893 settings.NoFilesChosenText = Translate("No files chosen..."); 894 } 895 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 896 897 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 898 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 899 900 attributes.Add("type", "file"); 901 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 902 settings.CssClass = "u-full-width " + settings.CssClass; 903 904 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 905 906 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 907 @if (!string.IsNullOrEmpty(settings.Label)) 908 { 909 <label for="@settings.Id">@settings.Label</label> 910 } 911 @if (!string.IsNullOrEmpty(settings.HelpText)) 912 { 913 <small class="form__help-text">@settings.HelpText</small> 914 } 915 916 <div class="form__field-combi file-input u-no-margin dw-mod"> 917 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 918 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 919 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 920 @if (settings.UploadButton != null) 921 { 922 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 923 @Render(settings.UploadButton) 924 } 925 </div> 926 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 927 </div> 928 } 929 @using System.Reflection 930 @using Dynamicweb.Rapido.Blocks.Components.General 931 @using Dynamicweb.Rapido.Blocks.Components 932 @using Dynamicweb.Core 933 @using System.Linq 934 935 @* Component *@ 936 937 @helper RenderDateTimeField(DateTimeField settings) 938 { 939 if (string.IsNullOrEmpty(settings.Id)) 940 { 941 settings.Id = Guid.NewGuid().ToString("N"); 942 } 943 944 var textField = new TextField { 945 Name = settings.Name, 946 Id = settings.Id, 947 Label = settings.Label, 948 HelpText = settings.HelpText, 949 Value = settings.Value, 950 Disabled = settings.Disabled, 951 Required = settings.Required, 952 ErrorMessage = settings.ErrorMessage, 953 CssClass = settings.CssClass, 954 WrapperCssClass = settings.WrapperCssClass, 955 OnChange = settings.OnChange, 956 OnClick = settings.OnClick, 957 ExtraAttributes = settings.ExtraAttributes, 958 // 959 Placeholder = settings.Placeholder 960 }; 961 962 @Render(textField) 963 964 List<string> jsAttributes = new List<string>(); 965 966 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 967 968 if (!string.IsNullOrEmpty(settings.DateFormat)) 969 { 970 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 971 } 972 if (!string.IsNullOrEmpty(settings.MinDate)) 973 { 974 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 975 } 976 if (!string.IsNullOrEmpty(settings.MaxDate)) 977 { 978 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 979 } 980 if (settings.IsInline) 981 { 982 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 983 } 984 if (settings.EnableTime) 985 { 986 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 987 } 988 if (settings.EnableWeekNumbers) 989 { 990 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 991 } 992 993 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 994 995 <script> 996 document.addEventListener("DOMContentLoaded", function () { 997 flatpickr("#@textField.Id", { 998 @string.Join(",", jsAttributes) 999 }); 1000 }); 1001 </script> 1002 } 1003 @using System.Reflection 1004 @using Dynamicweb.Rapido.Blocks.Components.General 1005 @using Dynamicweb.Rapido.Blocks.Components 1006 1007 @* Component *@ 1008 1009 @helper RenderTextField(TextField settings) 1010 { 1011 var attributes = new Dictionary<string, string>(); 1012 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1013 { 1014 settings.Id = Guid.NewGuid().ToString("N"); 1015 } 1016 1017 /*base settings*/ 1018 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1019 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1020 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1021 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1022 if (settings.Required) { attributes.Add("required", "true"); } 1023 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1024 /*end*/ 1025 1026 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1027 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1028 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1029 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1030 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1031 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1032 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1033 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1034 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1035 settings.CssClass = "u-full-width " + settings.CssClass; 1036 1037 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1038 1039 string noMargin = "u-no-margin"; 1040 if (!settings.ReadOnly) { 1041 noMargin = ""; 1042 } 1043 1044 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1045 @if (!string.IsNullOrEmpty(settings.Label)) 1046 { 1047 <label for="@settings.Id" id="label_@settings.Id">@settings.Label</label> 1048 } 1049 @if (!string.IsNullOrEmpty(settings.HelpText)) 1050 { 1051 <small class="form__help-text">@settings.HelpText</small> 1052 } 1053 1054 @if (settings.ActionButton != null) 1055 { 1056 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1057 <div class="form__field-combi u-no-margin dw-mod"> 1058 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1059 @Render(settings.ActionButton) 1060 </div> 1061 } 1062 else 1063 { 1064 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1065 } 1066 1067 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1068 </div> 1069 } 1070 @using System.Reflection 1071 @using Dynamicweb.Rapido.Blocks.Components.General 1072 @using Dynamicweb.Rapido.Blocks.Components 1073 1074 @* Component *@ 1075 1076 @helper RenderNumberField(NumberField settings) 1077 { 1078 var attributes = new Dictionary<string, string>(); 1079 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1080 { 1081 settings.Id = Guid.NewGuid().ToString("N"); 1082 } 1083 1084 /*base settings*/ 1085 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1086 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1087 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1088 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1089 if (settings.Required) { attributes.Add("required", "true"); } 1090 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1091 /*end*/ 1092 1093 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1094 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1095 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1096 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1097 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1098 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1099 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1100 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1101 attributes.Add("type", "number"); 1102 1103 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1104 1105 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1106 @if (!string.IsNullOrEmpty(settings.Label)) 1107 { 1108 <label for="@settings.Id">@settings.Label</label> 1109 } 1110 @if (!string.IsNullOrEmpty(settings.HelpText)) 1111 { 1112 <small class="form__help-text">@settings.HelpText</small> 1113 } 1114 1115 @if (settings.ActionButton != null) 1116 { 1117 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1118 <div class="form__field-combi u-no-margin dw-mod"> 1119 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1120 @Render(settings.ActionButton) 1121 </div> 1122 } 1123 else 1124 { 1125 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1126 } 1127 1128 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1129 </div> 1130 } 1131 @using System.Reflection 1132 @using Dynamicweb.Rapido.Blocks.Components.General 1133 @using Dynamicweb.Rapido.Blocks.Components 1134 1135 1136 @* Component *@ 1137 1138 @helper RenderTextareaField(TextareaField settings) 1139 { 1140 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1141 string id = settings.Id; 1142 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1143 { 1144 id = Guid.NewGuid().ToString("N"); 1145 } 1146 1147 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1148 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1149 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1150 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1151 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1152 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1153 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1154 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1155 if (settings.Required) { attributes.Add("required", "true"); } 1156 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1157 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1158 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1159 attributes.Add("name", settings.Name); 1160 1161 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1162 @if (!string.IsNullOrEmpty(settings.Label)) 1163 { 1164 <label for="@id">@settings.Label</label> 1165 } 1166 @if (!string.IsNullOrEmpty(settings.HelpText)) 1167 { 1168 <small class="form__help-text">@settings.HelpText</small> 1169 } 1170 1171 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1172 1173 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1174 </div> 1175 } 1176 @using System.Reflection 1177 @using Dynamicweb.Rapido.Blocks.Components.General 1178 @using Dynamicweb.Rapido.Blocks.Components 1179 1180 1181 @* Component *@ 1182 1183 @helper RenderHiddenField(HiddenField settings) { 1184 var attributes = new Dictionary<string, string>(); 1185 attributes.Add("type", "hidden"); 1186 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1187 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1188 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1189 1190 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1191 } 1192 @using System.Reflection 1193 @using Dynamicweb.Rapido.Blocks.Components.General 1194 @using Dynamicweb.Rapido.Blocks.Components 1195 1196 @* Component *@ 1197 1198 @helper RenderCheckboxField(CheckboxField settings) 1199 { 1200 var attributes = new Dictionary<string, string>(); 1201 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1202 { 1203 settings.Id = Guid.NewGuid().ToString("N"); 1204 } 1205 1206 /*base settings*/ 1207 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1208 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1209 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1210 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1211 if (settings.Required) { attributes.Add("required", "true"); } 1212 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1213 /*end*/ 1214 1215 attributes.Add("type", "checkbox"); 1216 if (settings.Checked) { attributes.Add("checked", "true"); } 1217 settings.CssClass = "form__control " + settings.CssClass; 1218 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1219 1220 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1221 1222 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1223 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1224 @if (!string.IsNullOrEmpty(settings.Label)) 1225 { 1226 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1227 } 1228 @if (!string.IsNullOrEmpty(settings.HelpText)) 1229 { 1230 <small class="form__help-text">@settings.HelpText</small> 1231 } 1232 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1233 </div> 1234 } 1235 @using System.Reflection 1236 @using Dynamicweb.Rapido.Blocks.Components.General 1237 @using Dynamicweb.Rapido.Blocks.Components 1238 1239 1240 @* Component *@ 1241 1242 @helper RenderCheckboxListField(CheckboxListField settings) 1243 { 1244 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1245 @if (!string.IsNullOrEmpty(settings.Label)) 1246 { 1247 <label>@settings.Label</label> 1248 } 1249 @if (!string.IsNullOrEmpty(settings.HelpText)) 1250 { 1251 <small class="form__help-text">@settings.HelpText</small> 1252 } 1253 1254 @foreach (var item in settings.Options) 1255 { 1256 if (settings.Required) 1257 { 1258 item.Required = true; 1259 } 1260 if (settings.Disabled) 1261 { 1262 item.Disabled = true; 1263 } 1264 if (!string.IsNullOrEmpty(settings.Name)) 1265 { 1266 item.Name = settings.Name; 1267 } 1268 if (!string.IsNullOrEmpty(settings.CssClass)) 1269 { 1270 item.CssClass += settings.CssClass; 1271 } 1272 1273 /* value is not supported */ 1274 1275 if (!string.IsNullOrEmpty(settings.OnClick)) 1276 { 1277 item.OnClick += settings.OnClick; 1278 } 1279 if (!string.IsNullOrEmpty(settings.OnChange)) 1280 { 1281 item.OnChange += settings.OnChange; 1282 } 1283 @Render(item) 1284 } 1285 1286 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1287 </div> 1288 } 1289 @using System.Reflection 1290 @using Dynamicweb.Rapido.Blocks.Components.General 1291 @using Dynamicweb.Rapido.Blocks.Components 1292 1293 1294 @* Component *@ 1295 1296 @helper RenderSelectField(SelectField settings) 1297 { 1298 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1299 { 1300 settings.Id = Guid.NewGuid().ToString("N"); 1301 } 1302 1303 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1304 @if (!string.IsNullOrEmpty(settings.Label)) 1305 { 1306 <label for="@settings.Id">@settings.Label</label> 1307 } 1308 @if (!string.IsNullOrEmpty(settings.HelpText)) 1309 { 1310 <small class="form__help-text">@settings.HelpText</small> 1311 } 1312 1313 @if (settings.ActionButton != null) 1314 { 1315 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1316 <div class="form__field-combi u-no-margin dw-mod"> 1317 @RenderSelectBase(settings) 1318 @Render(settings.ActionButton) 1319 </div> 1320 } 1321 else 1322 { 1323 @RenderSelectBase(settings) 1324 } 1325 1326 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1327 </div> 1328 } 1329 1330 @helper RenderSelectBase(SelectField settings) 1331 { 1332 var attributes = new Dictionary<string, string>(); 1333 1334 /*base settings*/ 1335 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1336 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1337 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1338 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1339 if (settings.Required) { attributes.Add("required", "true"); } 1340 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1341 /*end*/ 1342 1343 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1344 1345 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1346 @if (settings.Default != null) 1347 { 1348 @Render(settings.Default) 1349 } 1350 1351 @foreach (var item in settings.Options) 1352 { 1353 if (!string.IsNullOrEmpty(settings.Value)) { 1354 item.Checked = item.Value == settings.Value; 1355 } 1356 @Render(item) 1357 } 1358 </select> 1359 } 1360 @using System.Reflection 1361 @using Dynamicweb.Rapido.Blocks.Components.General 1362 @using Dynamicweb.Rapido.Blocks.Components 1363 1364 @* Component *@ 1365 1366 @helper RenderRadioButtonField(RadioButtonField settings) 1367 { 1368 var attributes = new Dictionary<string, string>(); 1369 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1370 { 1371 settings.Id = Guid.NewGuid().ToString("N"); 1372 } 1373 1374 /*base settings*/ 1375 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1376 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1377 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1378 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1379 if (settings.Required) { attributes.Add("required", "true"); } 1380 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1381 /*end*/ 1382 1383 attributes.Add("type", "radio"); 1384 if (settings.Checked) { attributes.Add("checked", "true"); } 1385 settings.CssClass = "form__control " + settings.CssClass; 1386 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1387 1388 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1389 1390 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1391 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1392 @if (!string.IsNullOrEmpty(settings.Label)) 1393 { 1394 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1395 } 1396 @if (!string.IsNullOrEmpty(settings.HelpText)) 1397 { 1398 <small class="form__help-text">@settings.HelpText</small> 1399 } 1400 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1401 </div> 1402 } 1403 @using System.Reflection 1404 @using Dynamicweb.Rapido.Blocks.Components.General 1405 @using Dynamicweb.Rapido.Blocks.Components 1406 1407 1408 @* Component *@ 1409 1410 @helper RenderRadioButtonListField(RadioButtonListField settings) 1411 { 1412 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1413 @if (!string.IsNullOrEmpty(settings.Label)) 1414 { 1415 <label>@settings.Label</label> 1416 } 1417 @if (!string.IsNullOrEmpty(settings.HelpText)) 1418 { 1419 <small class="form__help-text">@settings.HelpText</small> 1420 } 1421 1422 @foreach (var item in settings.Options) 1423 { 1424 if (settings.Required) 1425 { 1426 item.Required = true; 1427 } 1428 if (settings.Disabled) 1429 { 1430 item.Disabled = true; 1431 } 1432 if (!string.IsNullOrEmpty(settings.Name)) 1433 { 1434 item.Name = settings.Name; 1435 } 1436 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 1437 { 1438 item.Checked = true; 1439 } 1440 if (!string.IsNullOrEmpty(settings.OnClick)) 1441 { 1442 item.OnClick += settings.OnClick; 1443 } 1444 if (!string.IsNullOrEmpty(settings.OnChange)) 1445 { 1446 item.OnChange += settings.OnChange; 1447 } 1448 if (!string.IsNullOrEmpty(settings.CssClass)) 1449 { 1450 item.CssClass += settings.CssClass; 1451 } 1452 @Render(item) 1453 } 1454 1455 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1456 </div> 1457 } 1458 @using System.Reflection 1459 @using Dynamicweb.Rapido.Blocks.Components.General 1460 @using Dynamicweb.Rapido.Blocks.Components 1461 1462 1463 @* Component *@ 1464 1465 @helper RenderNotificationMessage(NotificationMessage settings) 1466 { 1467 if (!string.IsNullOrEmpty(settings.Message)) 1468 { 1469 var attributes = new Dictionary<string, string>(); 1470 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1471 1472 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1473 <div class="field-@messageTypeClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 1474 } 1475 } 1476 @using Dynamicweb.Rapido.Blocks.Components.General 1477 1478 1479 @* Component *@ 1480 1481 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1482 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1483 1484 <div class="@settings.CssClass dw-mod js-handlebars-root" id="@settings.Id" data-template="@settings.ScriptTemplate" data-json-feed="@settings.FeedUrl" data-init-onload="@settings.InitOnLoad.ToString()" data-preloader="@settings.Preloader" @preRender> 1485 @if (settings.SubBlocks != null) { 1486 @RenderBlockList(settings.SubBlocks) 1487 } 1488 </div> 1489 } 1490 @using System.Reflection 1491 @using Dynamicweb.Rapido.Blocks.Components.General 1492 @using Dynamicweb.Rapido.Blocks.Components 1493 @using System.Text.RegularExpressions 1494 1495 1496 @* Component *@ 1497 1498 @helper RenderSticker(Sticker settings) { 1499 if (!String.IsNullOrEmpty(settings.Title)) { 1500 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1501 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1502 1503 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1504 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1505 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1506 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1507 optionalAttributes.Add("style", styleTag); 1508 } 1509 1510 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1511 } 1512 } 1513 1514 @using System.Reflection 1515 @using Dynamicweb.Rapido.Blocks.Components.General 1516 @using Dynamicweb.Rapido.Blocks.Components 1517 1518 1519 @* Component *@ 1520 1521 @helper RenderStickersCollection(StickersCollection settings) 1522 { 1523 if (settings.Stickers.Count > 0) 1524 { 1525 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1526 1527 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1528 @foreach (Sticker sticker in settings.Stickers) 1529 { 1530 @Render(sticker) 1531 } 1532 </div> 1533 } 1534 } 1535 1536 @using Dynamicweb.Rapido.Blocks.Components.General 1537 1538 1539 @* Component *@ 1540 1541 @helper RenderForm(Form settings) { 1542 if (settings != null) 1543 { 1544 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1545 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1546 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1547 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1548 var enctypes = new Dictionary<string, string> 1549 { 1550 { "multipart", "multipart/form-data" }, 1551 { "text", "text/plain" }, 1552 { "application", "application/x-www-form-urlencoded" } 1553 }; 1554 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1555 optionalAttributes.Add("method", settings.Method.ToString()); 1556 1557 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1558 { 1559 @settings.FormStartMarkup 1560 } 1561 else 1562 { 1563 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1564 } 1565 1566 foreach (var field in settings.GetFields()) 1567 { 1568 @Render(field) 1569 } 1570 1571 @:</form> 1572 } 1573 } 1574 @using System.Reflection 1575 @using Dynamicweb.Rapido.Blocks.Components.General 1576 @using Dynamicweb.Rapido.Blocks.Components 1577 1578 1579 @* Component *@ 1580 1581 @helper RenderText(Text settings) 1582 { 1583 @settings.Content 1584 } 1585 @using System.Reflection 1586 @using Dynamicweb.Rapido.Blocks.Components.General 1587 @using Dynamicweb.Rapido.Blocks.Components 1588 1589 1590 @* Component *@ 1591 1592 @helper RenderContentModule(ContentModule settings) { 1593 if (!string.IsNullOrEmpty(settings.Content)) 1594 { 1595 @settings.Content 1596 } 1597 } 1598 @using System.Reflection 1599 @using Dynamicweb.Rapido.Blocks.Components.General 1600 @using Dynamicweb.Rapido.Blocks.Components 1601 1602 1603 @* Component *@ 1604 1605 @helper RenderModal(Modal settings) { 1606 if (settings != null) 1607 { 1608 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1609 1610 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1611 1612 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1613 1614 <div class="modal-container"> 1615 @if (!settings.DisableDarkOverlay) 1616 { 1617 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1618 } 1619 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1620 @if (settings.Heading != null) 1621 { 1622 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1623 { 1624 <div class="modal__header"> 1625 @Render(settings.Heading) 1626 </div> 1627 } 1628 } 1629 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1630 @if (!string.IsNullOrEmpty(settings.BodyText)) 1631 { 1632 @settings.BodyText 1633 } 1634 @if (settings.BodyTemplate != null) 1635 { 1636 @settings.BodyTemplate 1637 } 1638 @{ 1639 var actions = settings.GetActions(); 1640 } 1641 </div> 1642 @if (actions.Length > 0) 1643 { 1644 <div class="modal__footer"> 1645 @foreach (var action in actions) 1646 { 1647 action.CssClass += " u-no-margin"; 1648 @Render(action) 1649 } 1650 </div> 1651 } 1652 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1653 </div> 1654 </div> 1655 } 1656 } 1657 @using Dynamicweb.Rapido.Blocks.Components.General 1658 1659 @* Component *@ 1660 1661 @helper RenderMediaListItem(MediaListItem settings) 1662 { 1663 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1664 @if (!string.IsNullOrEmpty(settings.Label)) 1665 { 1666 if (!string.IsNullOrEmpty(settings.Link)) 1667 { 1668 @Render(new Link 1669 { 1670 Href = settings.Link, 1671 CssClass = "media-list-item__sticker dw-mod", 1672 ButtonLayout = ButtonLayout.None, 1673 Title = settings.Label, 1674 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1675 }) 1676 } 1677 else if (!string.IsNullOrEmpty(settings.OnClick)) 1678 { 1679 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1680 <span class="u-uppercase">@settings.Label</span> 1681 </span> 1682 } 1683 else 1684 { 1685 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1686 <span class="u-uppercase">@settings.Label</span> 1687 </span> 1688 } 1689 } 1690 <div class="media-list-item__wrap"> 1691 <div class="media-list-item__info dw-mod"> 1692 <div class="media-list-item__header dw-mod"> 1693 @if (!string.IsNullOrEmpty(settings.Title)) 1694 { 1695 if (!string.IsNullOrEmpty(settings.Link)) 1696 { 1697 @Render(new Link 1698 { 1699 Href = settings.Link, 1700 CssClass = "media-list-item__name dw-mod", 1701 ButtonLayout = ButtonLayout.None, 1702 Title = settings.Title, 1703 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1704 }) 1705 } 1706 else if (!string.IsNullOrEmpty(settings.OnClick)) 1707 { 1708 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1709 } 1710 else 1711 { 1712 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1713 } 1714 } 1715 1716 @if (!string.IsNullOrEmpty(settings.Status)) 1717 { 1718 <div class="media-list-item__state dw-mod">@settings.Status</div> 1719 } 1720 </div> 1721 @{ 1722 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1723 } 1724 1725 @Render(settings.InfoTable) 1726 </div> 1727 <div class="media-list-item__actions dw-mod"> 1728 <div class="media-list-item__actions-list dw-mod"> 1729 @{ 1730 var actions = settings.GetActions(); 1731 1732 foreach (ButtonBase action in actions) 1733 { 1734 action.ButtonLayout = ButtonLayout.None; 1735 action.CssClass += " media-list-item__action link"; 1736 1737 @Render(action) 1738 } 1739 } 1740 </div> 1741 1742 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1743 { 1744 settings.SelectButton.CssClass += " u-no-margin"; 1745 1746 <div class="media-list-item__action-button"> 1747 @Render(settings.SelectButton) 1748 </div> 1749 } 1750 </div> 1751 </div> 1752 </div> 1753 } 1754 @using Dynamicweb.Rapido.Blocks.Components.General 1755 @using Dynamicweb.Rapido.Blocks.Components 1756 1757 @helper RenderTable(Table settings) 1758 { 1759 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1760 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1761 1762 var enumToClasses = new Dictionary<TableDesign, string> 1763 { 1764 { TableDesign.Clean, "table--clean" }, 1765 { TableDesign.Bordered, "table--bordered" }, 1766 { TableDesign.Striped, "table--striped" }, 1767 { TableDesign.Hover, "table--hover" }, 1768 { TableDesign.Compact, "table--compact" }, 1769 { TableDesign.Condensed, "table--condensed" }, 1770 { TableDesign.NoTopBorder, "table--no-top-border" } 1771 }; 1772 string tableDesignClass = ""; 1773 if (settings.Design != TableDesign.None) 1774 { 1775 tableDesignClass = enumToClasses[settings.Design]; 1776 } 1777 1778 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1779 1780 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1781 1782 <table @ComponentMethods.AddAttributes(resultAttributes)> 1783 @if (settings.Header != null) 1784 { 1785 <thead> 1786 @Render(settings.Header) 1787 </thead> 1788 } 1789 <tbody> 1790 @foreach (var row in settings.Rows) 1791 { 1792 @Render(row) 1793 } 1794 </tbody> 1795 @if (settings.Footer != null) 1796 { 1797 <tfoot> 1798 @Render(settings.Footer) 1799 </tfoot> 1800 } 1801 </table> 1802 } 1803 @using Dynamicweb.Rapido.Blocks.Components.General 1804 @using Dynamicweb.Rapido.Blocks.Components 1805 1806 @helper RenderTableRow(TableRow settings) 1807 { 1808 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1809 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1810 1811 var enumToClasses = new Dictionary<TableRowDesign, string> 1812 { 1813 { TableRowDesign.NoBorder, "table__row--no-border" }, 1814 { TableRowDesign.Border, "table__row--border" }, 1815 { TableRowDesign.TopBorder, "table__row--top-line" }, 1816 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1817 { TableRowDesign.Solid, "table__row--solid" } 1818 }; 1819 1820 string tableRowDesignClass = ""; 1821 if (settings.Design != TableRowDesign.None) 1822 { 1823 tableRowDesignClass = enumToClasses[settings.Design]; 1824 } 1825 1826 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 1827 1828 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1829 1830 <tr @ComponentMethods.AddAttributes(resultAttributes)> 1831 @foreach (var cell in settings.Cells) 1832 { 1833 if (settings.IsHeaderRow) 1834 { 1835 cell.IsHeader = true; 1836 } 1837 @Render(cell) 1838 } 1839 </tr> 1840 } 1841 @using Dynamicweb.Rapido.Blocks.Components.General 1842 @using Dynamicweb.Rapido.Blocks.Components 1843 @using Dynamicweb.Core 1844 1845 @helper RenderTableCell(TableCell settings) 1846 { 1847 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1848 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1849 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 1850 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 1851 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 1852 1853 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1854 1855 string tagName = settings.IsHeader ? "th" : "td"; 1856 1857 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + " title="+ settings.Content.Replace(" ", "&nbsp;") + ">") 1858 1859 @settings.Content 1860 @("</" + tagName + ">"); 1861 } 1862 @using System.Linq 1863 @using Dynamicweb.Rapido.Blocks.Components.General 1864 1865 @* Component *@ 1866 1867 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 1868 { 1869 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 1870 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 1871 1872 if (settings.NumberOfPages > 1) 1873 { 1874 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 1875 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 1876 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 1877 1878 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 1879 @if (settings.ShowPagingInfo) 1880 { 1881 <div class="pager__info dw-mod"> 1882 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 1883 </div> 1884 } 1885 <ul class="pager__list dw-mod"> 1886 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 1887 { 1888 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 1889 } 1890 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 1891 { 1892 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 1893 } 1894 @if (settings.GetPages().Any()) 1895 { 1896 foreach (var page in settings.GetPages()) 1897 { 1898 @Render(page) 1899 } 1900 } 1901 else 1902 { 1903 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 1904 { 1905 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 1906 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 1907 } 1908 } 1909 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 1910 { 1911 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 1912 } 1913 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 1914 { 1915 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 1916 } 1917 </ul> 1918 </div> 1919 } 1920 } 1921 1922 @helper RenderPaginationItem(PaginationItem settings) 1923 { 1924 if (settings.Icon == null) 1925 { 1926 settings.Icon = new Icon(); 1927 } 1928 1929 settings.Icon.Label = settings.Label; 1930 <li class="pager__btn dw-mod"> 1931 @if (settings.IsActive) 1932 { 1933 <span class="pager__num pager__num--current dw-mod"> 1934 @Render(settings.Icon) 1935 </span> 1936 } 1937 else 1938 { 1939 <a href="@settings.Link" class="pager__num dw-mod"> 1940 @Render(settings.Icon) 1941 </a> 1942 } 1943 </li> 1944 } 1945 1946 1947 @using Dynamicweb.Rapido.Blocks.Components.General 1948 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 1949 1950 1951 1952 @* Include the Blocks for the page *@ 1953 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 1954 @using Dynamicweb.Core 1955 @using Dynamicweb.Ecommerce.International 1956 @using System 1957 @using System.Web 1958 @using System.Linq 1959 @using System.Collections.Generic 1960 @using Dynamicweb.Rapido.Blocks 1961 @using Dynamicweb.Rapido.Blocks.Components 1962 @using Dynamicweb.Rapido.Blocks.Components.General 1963 1964 @{ 1965 BlocksPage billingAddressCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 1966 var billingAddressesEditingSetting = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetList("AddressesEditing"); 1967 bool isBillingAddressEditable = billingAddressesEditingSetting != null && billingAddressesEditingSetting.SelectedValue == "editable"; 1968 bool isBillingUserAnonymous = string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName")); 1969 1970 Block billingAddressBlock = new Block() 1971 { 1972 Id = "BillingAddress", 1973 SortId = 10, 1974 Design = new Design 1975 { 1976 RenderType = RenderType.Column, 1977 Size = "12" 1978 }, 1979 BlocksList = new List<Block> { 1980 new Block { 1981 Id = "BillingAddressHeader", 1982 SortId = 10, 1983 Component = new Heading { Level = 3, Title = Translate("Billing address"), Icon = new Icon { Prefix = "fas", Name = "fa-home", LabelPosition = IconLabelPosition.After } }, 1984 Design = new Design { 1985 RenderType = RenderType.CardHeader, 1986 CssClass = "u-color-light--bg" 1987 } 1988 }, 1989 new Block { 1990 Id = "BillingAddressBody", 1991 SortId = 20, 1992 Design = new Design { 1993 RenderType = RenderType.CardBody, 1994 CssClass = "u-color-light--bg" 1995 } 1996 } 1997 } 1998 }; 1999 2000 billingAddressCheckoutPage.Add("AddressContainerRow", billingAddressBlock); 2001 2002 if (isBillingUserAnonymous) 2003 { 2004 billingAddressCheckoutPage.Add("BillingAddressBody", new Block 2005 { 2006 Id = "AlreadyACustomerButton", 2007 SortId = 10, 2008 Template = RenderAlreadyACustomerButton() 2009 }); 2010 2011 if (GetBoolean("Ecom:Cart.CreateUserInCheckout")) 2012 { 2013 billingAddressCheckoutPage.Add("BillingAddressBody", new Block 2014 { 2015 Id = "CreateUserInCheckoutHiddens", 2016 SortId = 20, 2017 Component = new HiddenField { Name = "EcomUserCreateNew", Value = "True" } 2018 }); 2019 } 2020 } 2021 2022 if (isBillingAddressEditable || isBillingUserAnonymous) 2023 { 2024 billingAddressCheckoutPage.Add("BillingAddressBody", new Block 2025 { 2026 Id = "EditableBillingAddress", 2027 SortId = 30, 2028 Template = RenderEditableBillingAddress() 2029 }); 2030 } 2031 else 2032 { 2033 billingAddressCheckoutPage.Add("BillingAddressBody", new Block 2034 { 2035 Id = "StaticBillingAddress", 2036 SortId = 30, 2037 Template = RenderStaticBillingAddress() 2038 }); 2039 } 2040 } 2041 2042 @helper RenderEditableBillingAddress() 2043 { 2044 @Render(new TextField { Label = Translate("Company"), Name = "EcomOrderCustomerCompany", Id = "EcomOrderCustomerCompany", Value = GetString("Ecom:Order.Customer.Company"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerCompany.ErrorMessage") }) 2045 @Render(new TextField { Label = Translate("Name"), Name = "EcomOrderCustomerName", Id = "EcomOrderCustomerName", Value = GetString("Ecom:Order.Customer.Name"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerName.ErrorMessage") }) 2046 2047 <div class="form__fields-collection form__fields-collection--2-3"> 2048 @Render(new TextField { Label = Translate("Phone"), Name = "EcomOrderCustomerPhone", Id = "EcomOrderCustomerPhone", Value = GetString("Ecom:Order.Customer.Phone"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerPhone.ErrorMessage") }) 2049 @Render(new TextField { Label = Translate("Email"), Name = "EcomOrderCustomerEmail", Id = "EcomOrderCustomerEmail", Value = GetString("Ecom:Order.Customer.Email"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerEmail.ErrorMessage") }) 2050 </div> 2051 2052 @Render(new TextField { Label = Translate("Address"), Name = "EcomOrderCustomerAddress", Id = "EcomOrderCustomerAddress", Value = GetString("Ecom:Order.Customer.Address"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerAddress.ErrorMessage") }) 2053 2054 <div class="form__fields-collection form__fields-collection--2-3"> 2055 @Render(new TextField { Label = Translate("Zip"), Name = "EcomOrderCustomerZip", Id = "EcomOrderCustomerZip", Value = GetString("Ecom:Order.Customer.Zip"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerZip.ErrorMessage") }) 2056 @Render(new TextField { Label = Translate("City"), Name = "EcomOrderCustomerCity", Id = "EcomOrderCustomerCity", Value = GetString("Ecom:Order.Customer.City"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerCity.ErrorMessage") }) 2057 </div> 2058 2059 if (GetLoop("CustomerRegions").Count > 0) 2060 { 2061 SelectField selectState = new SelectField 2062 { 2063 Id = "EcomOrderCustomerRegion", 2064 Name = "EcomOrderCustomerRegion", 2065 Label = Translate("State/Region"), 2066 OnChange = "Cart.SubmitCart()", 2067 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerRegion.ErrorMessage"), 2068 Value = GetString("Ecom:Order.Customer.Region") 2069 }; 2070 selectState.Options.Add(new SelectFieldOption 2071 { 2072 Label = Translate("Nothing selected"), 2073 Value = "", 2074 Disabled = true, 2075 Checked = true 2076 }); 2077 foreach (LoopItem state in GetLoop("CustomerRegions")) 2078 { 2079 selectState.Options.Add(new SelectFieldOption { Label = state.GetString("Ecom:CustomerRegion.Name"), Value = state.GetString("Ecom:CustomerRegion.RegionCode") }); 2080 } 2081 @Render(selectState) 2082 } 2083 else 2084 { 2085 @Render(new HiddenField { Id = "EcomOrderCustomerRegion", Name = "EcomOrderCustomerRegion" }) 2086 } 2087 2088 SelectField selectCountry = new SelectField 2089 { 2090 Id = "EcomOrderCustomerCountry", 2091 Name = "EcomOrderCustomerCountry", 2092 Label = Translate("Country"), 2093 OnChange = "resetStateField('EcomOrderCustomerRegion');Cart.SubmitCart()", 2094 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerCountry.ErrorMessage") 2095 }; 2096 foreach (LoopItem country in GetLoop("Countries")) 2097 { 2098 selectCountry.Options.Add(new SelectFieldOption { Label = country.GetString("Ecom:Country.Name"), Value = country.GetString("Ecom:Country.Code2"), Checked = country.GetBoolean("Ecom:Country.IsCustomerCountryOrDefault") }); 2099 } 2100 2101 @Render(selectCountry) 2102 } 2103 2104 @helper RenderStaticBillingField(string name, string value, string cssClass = "", string displayedValue = "") 2105 { 2106 if (string.IsNullOrEmpty(displayedValue)) 2107 { 2108 displayedValue = value; 2109 } 2110 2111 if (!string.IsNullOrEmpty(value)) 2112 { 2113 @Render(new HiddenField { Name = name, Id = name, Value = value }) 2114 <div class="@cssClass">@displayedValue</div> 2115 } 2116 } 2117 2118 @helper RenderStaticBillingAddress() 2119 { 2120 @RenderStaticBillingField("EcomOrderCustomerName", GetString("Ecom:Order.Customer.Name"), "u-bold") 2121 @RenderStaticBillingField("EcomOrderCustomerCompany", GetString("Ecom:Order.Customer.Company")) 2122 @RenderStaticBillingField("EcomOrderCustomerAddress", GetString("Ecom:Order.Customer.Address")) 2123 @RenderStaticBillingField("EcomOrderCustomerZip", GetString("Ecom:Order.Customer.Zip"), "u-inline") 2124 @RenderStaticBillingField("EcomOrderCustomerCity", GetString("Ecom:Order.Customer.City"), "u-inline") 2125 2126 if (!string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Region"))) 2127 { 2128 var stateName = ""; 2129 foreach (var state in GetLoop("CustomerRegions")) 2130 { 2131 if (state.GetString("Ecom:CustomerRegion.RegionCode") == GetString("Ecom:Order.Customer.Region")) 2132 { 2133 stateName = state.GetString("Ecom:CustomerRegion.Name"); 2134 } 2135 } 2136 2137 @RenderStaticBillingField("EcomOrderCustomerRegion", GetString("Ecom:Order.Customer.Region"), "", stateName) 2138 } 2139 2140 var countryList = GlobalISO.GetGlobalISOs().Cast<GlobalISO>().GroupBy(x => x.Code2).Select(x => x.FirstOrDefault()).ToDictionary(x => x.Code2, y => y.CountryUK); 2141 var countryCode = GetString("Ecom:Order.Customer.Country.Code"); 2142 var countryName = GetString("Ecom:Order.Customer.Country.Code"); 2143 if (countryList.ContainsKey(countryCode)) 2144 { 2145 countryName = countryList[countryCode]; 2146 } 2147 2148 @RenderStaticBillingField("EcomOrderCustomerCountry", countryCode, "", countryName); 2149 2150 if (!string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Email")) && !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Phone"))) 2151 { 2152 <div class="u-margin-bottom"></div> 2153 } 2154 2155 @RenderStaticBillingField("EcomOrderCustomerEmail", GetString("Ecom:Order.Customer.Email")) 2156 @RenderStaticBillingField("EcomOrderCustomerPhone", GetString("Ecom:Order.Customer.Phone")) 2157 2158 if (!GetLoop("Countries").Any(country => country.GetString("Ecom:Country.Code2") == GetString("Ecom:Order.Customer.Country.Code"))) 2159 { 2160 @Render(new NotificationMessage { MessageType = NotificationMessageType.Error, Message = Translate("Your selected billing country is not supported") }) 2161 } 2162 } 2163 2164 @helper RenderAlreadyACustomerButton() 2165 { 2166 @Render(new Button { Title = Translate("Already a customer?"), ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--full more", OnClick = "document.getElementById('SignInModalTrigger').checked = !document.getElementById('SignInModalTrigger').checked" }) 2167 } 2168 2169 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2170 @using Dynamicweb.Core 2171 @using System 2172 @using System.Linq 2173 @using System.Web 2174 @using System.Collections.Generic 2175 @using Dynamicweb.Rapido.Blocks 2176 @using Dynamicweb.Rapido.Blocks.Components 2177 @using Dynamicweb.Rapido.Blocks.Components.General 2178 @using Dynamicweb.Ecommerce.International; 2179 2180 @functions { 2181 string addressesViewMode; 2182 bool useBillingAddress = true; 2183 } 2184 2185 @{ 2186 BlocksPage shippingAddressCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 2187 useBillingAddress = HttpContext.Current.Request.Cookies["UseAnotherAddress"] == null || !Converter.ToBoolean(HttpContext.Current.Request.Cookies["UseAnotherAddress"].Value); 2188 bool isShippingUserAnonymous = string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName")); 2189 var shippingAddressesEditingSetting = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetList("AddressesEditing"); 2190 addressesViewMode = shippingAddressesEditingSetting != null && !isShippingUserAnonymous ? shippingAddressesEditingSetting.SelectedValue : "editable"; 2191 2192 //dont render shipping address if shipping provider has content 2193 bool shippingProviderHasContent = false; 2194 foreach (LoopItem shipping in GetLoop("Shippingmethods")) 2195 { 2196 if (Converter.ToBoolean(shipping.GetString("Ecom:Cart.Shippingmethod.IsSelected")) && !string.IsNullOrEmpty(shipping.GetString("Ecom:ShippingProvider.Content"))) 2197 { 2198 shippingProviderHasContent = true; 2199 } 2200 } 2201 2202 if (!shippingProviderHasContent) 2203 { 2204 Block shippingAddressBlock = new Block() 2205 { 2206 Id = "ShippingAddress", 2207 SortId = 20, 2208 Design = new Design 2209 { 2210 RenderType = RenderType.Column, 2211 Size = "12" 2212 }, 2213 BlocksList = new List<Block> { 2214 new Block { 2215 Id = "ShippingAddressHeader", 2216 SortId = 10, 2217 Component = new Heading { Level = 3, Title = Translate("Shipping address"), Icon = new Icon { Prefix = "fas", Name = "fa-map-marker", LabelPosition = IconLabelPosition.After } }, 2218 Design = new Design { 2219 RenderType = RenderType.CardHeader, 2220 CssClass = "u-color-light--bg" 2221 } 2222 }, 2223 new Block 2224 { 2225 Id = "ShippingAddressJavascript", 2226 SortId = 20, 2227 Template = RenderAddressesJavascript() 2228 }, 2229 new Block { 2230 Id = "ShippingAddressBody", 2231 SortId = 30, 2232 Design = new Design { 2233 RenderType = RenderType.CardBody, 2234 CssClass = "u-color-light--bg" 2235 }, 2236 BlocksList = new List<Block> 2237 { 2238 new Block 2239 { 2240 Id = "ShippingAddressSelector", 2241 SortId = 10, 2242 Template = RenderShippingAddressSelector() 2243 } 2244 } 2245 } 2246 } 2247 }; 2248 shippingAddressCheckoutPage.Add("AddressContainerRow", shippingAddressBlock); 2249 2250 if (addressesViewMode != "editable") 2251 { 2252 shippingAddressCheckoutPage.Add("CheckoutBottomSnippets", new Block 2253 { 2254 Id = "SelectAnotherAddressModal", 2255 SortId = 40, 2256 Component = new Modal 2257 { 2258 Id = "MyAddressesSelector", 2259 Heading = new Heading 2260 { 2261 Icon = new Icon { Prefix = "far", Name = "fa-address-card", LabelPosition = IconLabelPosition.After }, 2262 Title = Translate("My addresses") 2263 }, 2264 Width = ModalWidth.Lg, 2265 OnClose = useBillingAddress ? "setUseBillingAddress(true)" : "" 2266 } 2267 }); 2268 2269 if (addressesViewMode != "readonly") 2270 { 2271 shippingAddressCheckoutPage.Add("CheckoutBottomSnippets", new Block 2272 { 2273 //common modal for edit and add 2274 Id = "ManageAddressModal", 2275 SortId = 100, 2276 Component = new Modal 2277 { 2278 Id = "ManageAddress", 2279 Heading = new Heading 2280 { 2281 Icon = new Icon { Prefix = "far", Name = "fa-plus", LabelPosition = IconLabelPosition.After }, 2282 Title = Translate("Add address") 2283 }, 2284 Width = ModalWidth.Md, 2285 OnClose = "document.querySelector('#MyAddressesSelectorModalTrigger').checked = true;" 2286 } 2287 }); 2288 } 2289 } 2290 2291 if (addressesViewMode != "editable") 2292 { 2293 var modal = new Modal 2294 { 2295 Id = "CountryIsNotAvailable", 2296 Heading = new Heading 2297 { 2298 Title = Translate("Sorry") 2299 }, 2300 Width = ModalWidth.Sm, 2301 BodyText = Translate("We cannot ship to this country.") 2302 }; 2303 modal.AddActions(new Button 2304 { 2305 Title = Translate("Choose another address"), 2306 OnClick = "document.getElementById('CountryIsNotAvailableModalTrigger').checked = false;" 2307 }); 2308 2309 shippingAddressCheckoutPage.Add("CheckoutBottomSnippets", new Block 2310 { 2311 //common modal for edit and add 2312 Id = "CountryIsNotAvailableModal", 2313 SortId = 110, 2314 Component = modal 2315 }); 2316 } 2317 2318 if (useBillingAddress) 2319 { 2320 shippingAddressCheckoutPage.Add("ShippingAddressBody", new Block 2321 { 2322 Id = "ShippingAddressFromBillingAddress", 2323 SortId = 20, 2324 Template = RenderShippingAddressFromBillingAddress() 2325 }); 2326 } 2327 else 2328 { 2329 shippingAddressCheckoutPage.Add("ShippingAddressBody", new Block 2330 { 2331 Id = "ShippingAddressContainer", 2332 SortId = 20, 2333 Design = new Design 2334 { 2335 CssClass = "js-shipping-address-container" 2336 } 2337 }); 2338 2339 if (addressesViewMode == "editable") 2340 { 2341 shippingAddressCheckoutPage.Add("ShippingAddressContainer", new Block 2342 { 2343 Id = "EditableShippingAddress", 2344 SortId = 10, 2345 Template = RenderEditableShippingAddress() 2346 }); 2347 } 2348 else 2349 { 2350 shippingAddressCheckoutPage.Add("ShippingAddressContainer", new Block 2351 { 2352 Id = "StaticShippingAddress", 2353 SortId = 10, 2354 Template = RenderStaticShippingAddress() 2355 }); 2356 shippingAddressCheckoutPage.Add("ShippingAddressContainer", new Block 2357 { 2358 Id = "SelectAnotherAddressButton", 2359 SortId = 20, 2360 Component = new Button 2361 { 2362 Title = Translate("Select shipping address"), 2363 ButtonLayout = ButtonLayout.Secondary, 2364 CssClass = "u-no-margin u-full-width", 2365 OnClick = "showAddressesListModal()" 2366 } 2367 }); 2368 } 2369 } 2370 } 2371 } 2372 2373 @helper RenderShippingAddressSelector() 2374 { 2375 @Render(new RadioButtonListField 2376 { 2377 Name = "ShippingAddressSelector", 2378 Options = new List<RadioButtonField> 2379 { 2380 new RadioButtonField 2381 { 2382 Label = Translate("Ship to the billing address"), 2383 Value = "useBillingAddress", 2384 Id = "useBillingAddress", 2385 Checked = useBillingAddress, 2386 OnChange = "changeShippingAddressToBilling()" 2387 }, 2388 new RadioButtonField 2389 { 2390 Label = Translate("Ship to another address"), 2391 Value = "useAnotherAddress", 2392 Id = "useAnotherAddress", 2393 Checked = !useBillingAddress, 2394 OnChange = "setUseBillingAddress(false);" + (addressesViewMode != "editable" ? "showAddressesListModal()" : "Cart.SubmitCart()") 2395 } 2396 } 2397 }); 2398 } 2399 2400 @helper RenderShippingAddressFromBillingAddress() 2401 { 2402 2403 @Render(new HiddenField { Name = "EcomOrderDeliveryCompany", Id = "EcomOrderDeliveryCompany", Value = GetString("Ecom:Order.Customer.Company")}) 2404 @Render(new HiddenField { Name = "EcomOrderDeliveryName", Id = "EcomOrderDeliveryName", Value = GetString("Ecom:Order.Customer.Name") }) 2405 @Render(new HiddenField { Name = "EcomOrderDeliveryPhone", Id = "EcomOrderDeliveryPhone", Value = GetString("Ecom:Order.Customer.Phone") }) 2406 @Render(new HiddenField { Name = "EcomOrderDeliveryEmail", Id = "EcomOrderDeliveryEmail", Value = GetString("Ecom:Order.Customer.Email") }) 2407 @Render(new HiddenField { Name = "EcomOrderDeliveryAddress", Id = "EcomOrderDeliveryAddress", Value = GetString("Ecom:Order.Customer.Address") }) 2408 @Render(new HiddenField { Name = "EcomOrderDeliveryZip", Id = "EcomOrderDeliveryZip", Value = GetString("Ecom:Order.Customer.Zip") }) 2409 @Render(new HiddenField { Name = "EcomOrderDeliveryCity", Id = "EcomOrderDeliveryCity", Value = GetString("Ecom:Order.Customer.City") }) 2410 @Render(new HiddenField { Name = "EcomOrderDeliveryRegion", Id = "EcomOrderDeliveryRegion", Value = GetString("Ecom:Order.Customer.Region") }) 2411 @Render(new HiddenField { Name = "EcomOrderDeliveryCountry", Id = "EcomOrderDeliveryCountry", Value = GetString("Ecom:Order.Customer.Country") }) 2412 } 2413 2414 @helper RenderStaticShippingField(string name, string value, string cssClass = "", string displayedValue = "") 2415 { 2416 if (string.IsNullOrEmpty(displayedValue)) 2417 { 2418 displayedValue = value; 2419 } 2420 2421 @Render(new HiddenField { Name = name, Id = name, Value = value }) 2422 2423 if (!string.IsNullOrEmpty(displayedValue)) 2424 { 2425 <div class="@cssClass">@displayedValue</div> 2426 } 2427 } 2428 2429 @helper RenderStaticShippingAddress() 2430 { 2431 @RenderStaticShippingField("EcomOrderDeliveryName", GetString("Ecom:Order.Delivery.Name"), "u-bold") 2432 @RenderStaticShippingField("EcomOrderDeliveryCompany", GetString("Ecom:Order.Delivery.Company")) 2433 @RenderStaticShippingField("EcomOrderDeliveryAddress", GetString("Ecom:Order.Delivery.Address")) 2434 @RenderStaticShippingField("EcomOrderDeliveryZip", GetString("Ecom:Order.Delivery.Zip"), "u-inline") 2435 @RenderStaticShippingField("EcomOrderDeliveryCity", GetString("Ecom:Order.Delivery.City"), "u-inline") 2436 2437 if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Region"))) 2438 { 2439 var stateName = ""; 2440 foreach (var state in GetLoop("DeliveryRegions")) 2441 { 2442 if (state.GetString("Ecom:DeliveryRegion.RegionCode") == GetString("Ecom:Order.Delivery.Region")) 2443 { 2444 stateName = state.GetString("Ecom:DeliveryRegion.Name"); 2445 } 2446 } 2447 2448 @RenderStaticShippingField("EcomOrderDeliveryRegion", GetString("Ecom:Order.Delivery.Region"), "", stateName) 2449 } 2450 else 2451 { 2452 @RenderStaticShippingField("EcomOrderDeliveryRegion", "") 2453 } 2454 2455 foreach (LoopItem country in GetLoop("Countries")) 2456 { 2457 if (country.GetBoolean("Ecom:Country.IsDeliveryCountryOrDefault")) 2458 { 2459 @RenderStaticShippingField("EcomOrderDeliveryCountry", country.GetString("Ecom:Country.Code2"), "", country.GetString("Ecom:Country.Name")) 2460 break; 2461 } 2462 } 2463 2464 if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Email")) && !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Phone"))) 2465 { 2466 <div class="u-margin-bottom"></div> 2467 } 2468 2469 @RenderStaticShippingField("EcomOrderDeliveryEmail", GetString("Ecom:Order.Delivery.Email")) 2470 @RenderStaticShippingField("EcomOrderDeliveryPhone", GetString("Ecom:Order.Delivery.Phone")) 2471 2472 <div class="u-margin-bottom"></div> 2473 } 2474 2475 @helper RenderAddressesJavascript() 2476 { 2477 string cartFeedPageIdAd = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 2478 <script> 2479 function setUseBillingAddress(useBillingAddress) { 2480 RememberState.SetCookie("useAnotherAddress", !useBillingAddress) 2481 document.getElementById("useBillingAddress").checked = useBillingAddress; 2482 document.getElementById("useBillingAddress").setAttribute("checked", useBillingAddress); 2483 } 2484 2485 function changeShippingAddressToBilling() { 2486 setUseBillingAddress(true); 2487 2488 address = {Company:'@GetString("Ecom:Order.Customer.Company")',Name:'@GetString("Ecom:Order.Customer.Name")', Phone: '@GetString("Ecom:Order.Customer.Phone")',Email: '@GetString("Ecom:Order.Customer.Email")',Address: '@GetString("Ecom:Order.Customer.Address")', Zip: '@GetString("Ecom:Order.Customer.Zip")',City: '@GetString("Ecom:Order.Customer.Cist")',Region: '@GetString("Ecom:Order.Customer.Region")',Country: '@GetString("Ecom:Order.Customer.Counry")' }; 2489 2490 for (key in address) { 2491 let value = address[key]; 2492 let field = document.getElementById("EcomOrderDelivery" + key); 2493 let nextfield = field.nextElementSibling ; 2494 if (field) { 2495 field.value = value; 2496 nextfield.innerHTML = value; 2497 } 2498 } 2499 var selectForm = document.getElementById("OrderSubmit"); // Select the form by ID. 2500 var formAction = document.getElementById("OrderSubmit").getAttribute('action'); // Get the form action. 2501 var formInputs = document.getElementById("OrderSubmit").querySelectorAll("input"); // Get the form inputs. 2502 clearTimeout(updateDelay); 2503 2504 updateDelay = setTimeout(function () { 2505 var httpRequest = new XMLHttpRequest(); 2506 var formData = new FormData(); 2507 2508 for (var i = 0; i < formInputs.length; i++) { 2509 formData.append(formInputs[i].name, formInputs[i].value); // Add all inputs inside formData(). 2510 } 2511 2512 httpRequest.onreadystatechange = function () { 2513 if (this.readyState == 4 && this.status == 200) { 2514 } 2515 }; 2516 2517 httpRequest.open("POST", formAction); 2518 httpRequest.send(formData); 2519 2520 HandlebarsBolt.UpdateContent('SummaryCart', 2521 '/Default.aspx?ID=@cartFeedPageIdAd' + '&redirect=false', 2522 '/Default.aspx?ID=@cartFeedPageIdAd' + '&redirect=false', 2523 'CartOrderlineSummary', 'minimal'); 2524 }, 100); 2525 } 2526 </script> 2527 2528 if (addressesViewMode != "editable") 2529 { 2530 string cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 2531 <script> 2532 let manageAddressPageId = "@GetPageIdByNavigationTag("AddressesForCheckout")"; 2533 2534 function showLoader(bodyElement) { 2535 let minHeightContainer = document.createElement("div"); 2536 minHeightContainer.className = "u-min-h180px"; 2537 let loader = document.createElement("div"); 2538 loader.className = "modal__loader"; 2539 let spinner = document.createElement("i"); 2540 spinner.className = "fa-4x fa-circle-notch fa-spin fas u-color-light"; 2541 loader.appendChild(spinner); 2542 minHeightContainer.appendChild(loader); 2543 bodyElement.innerHTML = ""; 2544 bodyElement.appendChild(minHeightContainer); 2545 } 2546 2547 //refresh addresses list 2548 function showAddressesListModal() { 2549 showLoader(document.querySelector("#MyAddressesSelectorModal .modal__body")); 2550 document.querySelector("#MyAddressesSelectorModalTrigger").checked = true; 2551 Request.Fetch().get( 2552 "Default.aspx?ID=" + manageAddressPageId, 2553 function (result) { 2554 document.querySelector("#MyAddressesSelectorModal .modal__body").innerHTML = result; 2555 }, 2556 function () { }, 2557 false 2558 ); 2559 } 2560 2561 var countries = []; 2562 2563 @foreach (var country in GetLoop("Countries")) 2564 { 2565 <text>countries.push("@country.GetString("Ecom:Country.Code2")");</text> 2566 } 2567 2568 function countryIsAvailable(countryCode) 2569 { 2570 return countries.indexOf(countryCode) != -1; 2571 } 2572 2573 function selectAddress(address) { 2574 document.getElementById("MyAddressesSelectorModalTrigger").checked = false; 2575 if (countryIsAvailable(address.Country)) { 2576 for (key in address) { 2577 let value = address[key]; 2578 let field = document.getElementById("EcomOrderDelivery" + key); 2579 let nextfield = field.nextElementSibling ; 2580 if (field) { 2581 field.value = value; 2582 nextfield.innerHTML = value; 2583 } 2584 } 2585 var selectForm = document.getElementById("OrderSubmit"); // Select the form by ID. 2586 var formAction = document.getElementById("OrderSubmit").getAttribute('action'); // Get the form action. 2587 var formInputs = document.getElementById("OrderSubmit").querySelectorAll("input"); // Get the form inputs. 2588 clearTimeout(updateDelay); 2589 2590 updateDelay = setTimeout(function () { 2591 var httpRequest = new XMLHttpRequest(); 2592 var formData = new FormData(); 2593 2594 for (var i = 0; i < formInputs.length; i++) { 2595 formData.append(formInputs[i].name, formInputs[i].value); // Add all inputs inside formData(). 2596 } 2597 2598 httpRequest.onreadystatechange = function () { 2599 if (this.readyState == 4 && this.status == 200) { 2600 } 2601 }; 2602 2603 httpRequest.open("POST", formAction); 2604 httpRequest.send(formData); 2605 2606 HandlebarsBolt.UpdateContent('SummaryCart', 2607 '/Default.aspx?ID=@cartFeedPageId' + '&redirect=false', 2608 '/Default.aspx?ID=@cartFeedPageId' + '&redirect=false', 2609 'CartOrderlineSummary', 'minimal'); 2610 }, 100); 2611 2612 } else { 2613 document.getElementById("CountryIsNotAvailableModalTrigger").checked = true; 2614 document.getElementById("MyAddressesSelectorModalTrigger").checked = true; 2615 } 2616 } 2617 </script> 2618 } 2619 2620 if (addressesViewMode == "static") 2621 { 2622 <script> 2623 let countryRegions = { 2624 2625 @foreach (var country in GetLoop("Countries")) 2626 { 2627 var regions = Dynamicweb.Ecommerce.Services.Countries.GetRegions(country.GetString("Ecom:Country.Code2")); 2628 2629 if (regions.Count > 0) 2630 { 2631 <text>"@country.GetString("Ecom:Country.Code2")": {</text> 2632 } 2633 2634 <text>@string.Join(",", regions.Select(region => "\"" + region.RegionCode + "\": \"" + region.Name + "\""))</text> 2635 2636 if (regions.Count > 0) 2637 { 2638 <text>},</text> 2639 } 2640 } 2641 2642 } 2643 2644 function changeCountry(countryCode) { 2645 document.getElementById("countryHidden").value = countryCode; 2646 let stateField = document.getElementById("UserManagement_Form_State"); 2647 stateField.innerHTML = ""; 2648 let currentRegions = countryRegions[countryCode] 2649 2650 if (currentRegions != null) { 2651 for (let regionCode in currentRegions) { 2652 let option = document.createElement("option"); 2653 option.text = currentRegions[regionCode]; 2654 option.value = regionCode; 2655 stateField.add(option); 2656 } 2657 stateField.closest(".js-state-field").classList.remove("u-hidden"); 2658 } else { 2659 let option = document.createElement("option"); 2660 option.value = ""; 2661 stateField.add(option); 2662 stateField.closest(".js-state-field").classList.add("u-hidden"); 2663 } 2664 } 2665 </script> 2666 <script id="AddAddressFormTemplate" type="text/html"> 2667 </script> 2668 <script id="AddAddressHeadingTemplate" type="text/html"> 2669 @Render(new Heading { Title = Translate("Add address"), Icon = new Icon { Prefix = "far", Name = "fa-plus", LabelPosition = IconLabelPosition.After } }) 2670 </script> 2671 <script id="EditAddressHeadingTemplate" type="text/html"> 2672 @Render(new Heading { Title = Translate("Edit address"), Icon = new Icon { Prefix = "fas", Name = "fa-pencil", LabelPosition = IconLabelPosition.After } }) 2673 </script> 2674 <script> 2675 //get add address form 2676 document.addEventListener("DOMContentLoaded", function () { 2677 Request.Fetch().get( 2678 "Default.aspx?ID=" + manageAddressPageId + "&ManageAddressesFormAction=Add", 2679 function (result) { 2680 document.querySelector("#AddAddressFormTemplate").innerHTML = result; 2681 document.querySelector("#ManageAddressModal .modal__body").innerHTML = document.getElementById("AddAddressFormTemplate").innerHTML; 2682 }, 2683 function () { }, 2684 false 2685 ); 2686 }); 2687 2688 function openAddAddressModal() { 2689 //get already saved template to prevent additional loading 2690 document.getElementById("MyAddressesSelectorModalTrigger").checked = false; 2691 document.querySelector("#ManageAddressModal .modal__header").innerHTML = document.getElementById("AddAddressHeadingTemplate").innerHTML; 2692 document.querySelector("#ManageAddressModal .modal__body").innerHTML = document.getElementById("AddAddressFormTemplate").innerHTML; 2693 regionLabels.LocalizeRegionLabels("UserManagement_Form_State", "UserManagement_Form_Country", true); 2694 document.getElementById("ManageAddressModalTrigger").checked = true; 2695 } 2696 2697 //open edit modal 2698 function openEditAddressModal(addressId) { 2699 document.getElementById("MyAddressesSelectorModalTrigger").checked = false; 2700 showLoader(document.querySelector("#ManageAddressModal .modal__body")); 2701 document.querySelector("#ManageAddressModal .modal__header").innerHTML = document.getElementById("EditAddressHeadingTemplate").innerHTML; 2702 document.getElementById("ManageAddressModalTrigger").checked = true; 2703 Request.Fetch().post( 2704 "Default.aspx?ID=" + manageAddressPageId, 2705 { 2706 "ManageAddressesFormAction": "Update", 2707 "SelectedAddressId": addressId 2708 }, 2709 function (result) { 2710 document.querySelector("#ManageAddressModal .modal__body").innerHTML = result; 2711 regionLabels.LocalizeRegionLabels("UserManagement_Form_State", "UserManagement_Form_Country", true); 2712 }, 2713 function () { }, 2714 false 2715 ); 2716 } 2717 2718 //save address (add / edit) 2719 function saveAddress(mode) { 2720 let form = document.getElementById("AddressForm"); 2721 let formData = new FormData(form); 2722 if (!form.checkValidity()) { 2723 // Create the temporary button, click and remove it 2724 var tmpSubmit = document.createElement("button"); 2725 form.appendChild(tmpSubmit); 2726 tmpSubmit.click(); 2727 form.removeChild(tmpSubmit); 2728 } else { 2729 Request.Fetch().post( 2730 "Default.aspx?ID=" + manageAddressPageId + "&ManageAddressesFormAction=Add", 2731 formData, 2732 function (result) { 2733 document.getElementById("ManageAddressModalTrigger").checked = false; 2734 showAddressesListModal(); 2735 }, 2736 function () { }, 2737 false 2738 ); 2739 } 2740 } 2741 2742 //delete 2743 function deleteAddress(addressId, button) { 2744 Request.Fetch().post( 2745 "Default.aspx?ID=" + manageAddressPageId, 2746 { 2747 SelectedAddressId: addressId, 2748 ManageAddressesFormAction: "Delete" 2749 }, 2750 function (result) { 2751 button.closest(".media-list-item").remove(); 2752 }, 2753 function () { }, 2754 false 2755 ); 2756 } 2757 </script> 2758 } 2759 } 2760 2761 @helper RenderEditableShippingAddress() 2762 { 2763 @Render(new TextField { Label = Translate("Company"), Name = "EcomOrderDeliveryCompany", Id = "EcomOrderDeliveryCompany", Value = GetString("Ecom:Order.Delivery.Company"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCompany.ErrorMessage") }) 2764 @Render(new TextField { Label = Translate("Name"), Name = "EcomOrderDeliveryName", Id = "EcomOrderDeliveryName", Value = GetString("Ecom:Order.Delivery.Name"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryName.ErrorMessage") }) 2765 2766 <div class="form__fields-collection form__fields-collection--2-3"> 2767 @Render(new TextField { Label = Translate("Phone"), Name = "EcomOrderDeliveryPhone", Id = "EcomOrderDeliveryPhone", Value = GetString("Ecom:Order.Delivery.Phone"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryPhone.ErrorMessage") }) 2768 @Render(new TextField { Label = Translate("Email"), Name = "EcomOrderDeliveryEmail", Id = "EcomOrderDeliveryEmail", Value = GetString("Ecom:Order.Delivery.Email"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryEmail.ErrorMessage") }) 2769 </div> 2770 2771 @Render(new TextField { Label = Translate("Address"), Name = "EcomOrderDeliveryAddress", Id = "EcomOrderDeliveryAddress", Value = GetString("Ecom:Order.Delivery.Address"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryAddress.ErrorMessage") }) 2772 2773 <div class="form__fields-collection form__fields-collection--2-3"> 2774 @Render(new TextField { Label = Translate("Zip"), Name = "EcomOrderDeliveryZip", Id = "EcomOrderDeliveryZip", Value = GetString("Ecom:Order.Delivery.Zip"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryZip.ErrorMessage") }) 2775 @Render(new TextField { Label = Translate("City"), Name = "EcomOrderDeliveryCity", Id = "EcomOrderDeliveryCity", Value = GetString("Ecom:Order.Delivery.City"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCity.ErrorMessage") }) 2776 </div> 2777 2778 if (GetLoop("DeliveryRegions").Count > 0) 2779 { 2780 SelectField selectState = new SelectField 2781 { 2782 Id = "EcomOrderDeliveryRegion", 2783 Name = "EcomOrderDeliveryRegion", 2784 Label = Translate("State/Region"), 2785 OnChange = "Cart.SubmitCart()", 2786 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryRegion.ErrorMessage"), 2787 Value = GetString("Ecom:Order.Delivery.Region") 2788 }; 2789 selectState.Options.Add(new SelectFieldOption 2790 { 2791 Label = Translate("Nothing selected"), 2792 Value = "", 2793 Disabled = true, 2794 Checked = true 2795 }); 2796 foreach (LoopItem state in GetLoop("DeliveryRegions")) 2797 { 2798 selectState.Options.Add(new SelectFieldOption { Label = state.GetString("Ecom:DeliveryRegion.Name"), Value = state.GetString("Ecom:DeliveryRegion.RegionCode") }); 2799 } 2800 @Render(selectState) 2801 } 2802 else 2803 { 2804 @Render(new HiddenField { Id = "EcomOrderDeliveryRegion", Name = "EcomOrderDeliveryRegion" }) 2805 } 2806 2807 SelectField selectCountry = new SelectField 2808 { 2809 Id = "EcomOrderDeliveryCountry", 2810 Name = "EcomOrderDeliveryCountry", 2811 Label = Translate("Country"), 2812 OnChange = "resetStateField('EcomOrderDeliveryRegion');Cart.SubmitCart()", 2813 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCountry.ErrorMessage") 2814 }; 2815 2816 foreach (LoopItem country in GetLoop("Countries")) 2817 { 2818 selectCountry.Options.Add(new SelectFieldOption { Label = country.GetString("Ecom:Country.Name"), Value = country.GetString("Ecom:Country.Code2"), Checked = country.GetBoolean("Ecom:Country.IsDeliveryCountryOrDefault") }); 2819 } 2820 2821 @Render(selectCountry) 2822 } 2823 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2824 @using Dynamicweb.Core 2825 @using System 2826 @using System.Web 2827 @using System.Linq 2828 @using System.Collections.Generic 2829 @using Dynamicweb.Rapido.Blocks 2830 @using Dynamicweb.Rapido.Blocks.Components 2831 @using Dynamicweb.Rapido.Blocks.Components.General 2832 2833 @{ 2834 BlocksPage paymentCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 2835 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 2836 string paymentCardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 2837 bool paymentCountryIsNotSupported = !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Country.Code")) && !GetLoop("Countries").Any(country => country.GetString("Ecom:Country.Code2") == GetString("Ecom:Order.Customer.Country.Code")); 2838 2839 var paymentBlock = new Block() 2840 { 2841 Id = "Payment", 2842 SortId = 10, 2843 Design = new Design 2844 { 2845 RenderType = RenderType.Column, 2846 Size = "6-auto" 2847 } 2848 }; 2849 2850 var paymentHeader = new Block 2851 { 2852 Id = "PaymentHeader", 2853 SortId = 10, 2854 Component = new Heading { Level = 3, Title = Translate("Payment"), Icon = new Icon { Prefix = "fas", Name = "fa-credit-card", LabelPosition = IconLabelPosition.After } }, 2855 Design = new Design 2856 { 2857 RenderType = RenderType.CardHeader, 2858 CssClass = "u-color-light--bg" 2859 } 2860 }; 2861 2862 var paymentBody = new Block 2863 { 2864 Id = "PaymentBody", 2865 SortId = 20, 2866 Design = new Design 2867 { 2868 RenderType = RenderType.CardBody, 2869 CssClass = "u-color-light--bg " + paymentCardHeightClass 2870 } 2871 }; 2872 2873 if (paymentCountryIsNotSupported) 2874 { 2875 paymentBlock.Add(paymentHeader); 2876 paymentBody.Component = new NotificationMessage { MessageType = NotificationMessageType.Error, Message = Translate("There is no available payment options") }; 2877 paymentBlock.Add(paymentBody); 2878 } 2879 else if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HidePayment") && GetLoop("Paymethods").Count != 0 && !pointShop) 2880 { 2881 paymentBlock.Add(paymentHeader); 2882 paymentBody.Template = RenderPayment(); 2883 paymentBlock.Add(paymentBody); 2884 } 2885 else 2886 { 2887 paymentBlock.Template = RenderHiddenPayment(); 2888 paymentBlock.Design.CssClass = "u-hidden"; 2889 } 2890 2891 paymentCheckoutPage.Add("OrderContainerRow", paymentBlock); 2892 } 2893 2894 @helper RenderPayment() 2895 { 2896 string errorMessage = GetString("Ecom:Cart.ValidationError.EcomCartPaymethodId.ErrorMessage"); 2897 string savedCardName = ""; 2898 foreach (LoopItem payment in GetLoop("Paymethods")) 2899 { 2900 bool isExist = false; 2901 bool supportSavedCards = payment.GetBoolean("Ecom:Cart.Paymethod.SupportSavedCard") && Dynamicweb.Core.Converter.ToBoolean(GetGlobalValue("Global:Extranet.UserName")); 2902 bool cardIsSaved = !String.IsNullOrEmpty(payment.GetString("Ecom:Order.SavedCardName")) ? true : false; 2903 if (Pageview.AreaSettings.GetItem("Custom") != null) 2904 { 2905 if (Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings") != null) 2906 { 2907 2908 if (Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetItems("Distributor_Payments") != null) 2909 { 2910 2911 foreach (var lang in Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetItems("Distributor_Payments")) 2912 { 2913 2914 if (lang.GetString("Payment") == payment.GetString("Ecom:Cart.Paymethod.Name")) 2915 { 2916 isExist = true; 2917 if (Dynamicweb.Frontend.PageView.Current()?.User?.CurrentSecondaryUser != null) 2918 { 2919 <div> 2920 <div class="u-margin-bottom"> 2921 @Render(new RadioButtonField 2922 { 2923 Name = "EcomCartPaymethodId", 2924 Label = payment.GetString("Ecom:Cart.Paymethod.Name"), 2925 Id = "EcomCartPaymethodId_" + payment.GetString("Ecom:Cart.Paymethod.ID"), 2926 Value = payment.GetString("Ecom:Cart.Paymethod.ID"), 2927 OnChange = "Cart.DeselectRadioGroup('EcomCartSavedCardID'); PaymentSubmit('EcomCartPaymethodId_" + payment.GetString("Ecom:Cart.Paymethod.ID") + "','" + payment.GetString("Ecom:Cart.Paymethod.ID") + "')", 2928 Checked = payment.GetBoolean("Ecom:Cart.Paymethod.IsSelected"), 2929 ExtraAttributes = new Dictionary<string, string> 2930 () { 2931 { "data-expand", "savedCards_" + payment.GetString("Ecom:Cart.Paymethod.Name").Replace(" ", "_") } 2932 } 2933 }) 2934 </div> 2935 </div> 2936 } 2937 2938 } 2939 2940 2941 } 2942 } 2943 } 2944 } 2945 if (!isExist) 2946 { 2947 <div> 2948 <div class="u-margin-bottom"> 2949 @Render(new RadioButtonField 2950 { 2951 Name = "EcomCartPaymethodId", 2952 Label = payment.GetString("Ecom:Cart.Paymethod.Name"), 2953 Id = "EcomCartPaymethodId_" + payment.GetString("Ecom:Cart.Paymethod.ID"), 2954 Value = payment.GetString("Ecom:Cart.Paymethod.ID"), 2955 OnChange = "Cart.DeselectRadioGroup('EcomCartSavedCardID'); PaymentSubmit('EcomCartPaymethodId_" + payment.GetString("Ecom:Cart.Paymethod.ID") + "','" + payment.GetString("Ecom:Cart.Paymethod.ID") + "')", 2956 Checked = payment.GetBoolean("Ecom:Cart.Paymethod.IsSelected"), 2957 ExtraAttributes = new Dictionary<string, string> 2958 () { 2959 { "data-expand", "savedCards_" + payment.GetString("Ecom:Cart.Paymethod.Name").Replace(" ", "_") } 2960 } 2961 }) 2962 </div> 2963 2964 @if (supportSavedCards) 2965 { 2966 <div class="expandable--collapsed dw-mod" data-trigger="savedCards_@payment.GetString("Ecom:Cart.Paymethod.Name").Replace(" ", "_")"> 2967 <div class="u-border-top u-border-bottom u-padding u-margin-bottom show"> 2968 @Render(new CheckboxField { Label = Translate("Save used card"), Name = "EcomOrderSavedCardCreate", Id = "EcomOrderSavedCardCreate_" + payment.GetString("Ecom:Cart.Paymethod.ID"), Value = "true", Checked = cardIsSaved }) 2969 2970 @Render(new TextField 2971 { 2972 Placeholder = Translate("Saved card name"), 2973 Value = payment.GetString("Ecom:Order.SavedCardName"), 2974 OnChange = "document.getElementById('MySavedCardName').value=this.value" 2975 }) 2976 </div> 2977 </div> 2978 } 2979 </div> 2980 } 2981 } 2982 2983 if (!string.IsNullOrEmpty(errorMessage)) 2984 { 2985 @Render(new NotificationMessage { Message = errorMessage, MessageType = NotificationMessageType.Error }) 2986 } 2987 2988 if (GetLoop("SavedCards").Count > 0) 2989 { 2990 <div class="u-bold u-margin-top u-margin-bottom">@Translate("Pay with a saved card")</div> 2991 2992 foreach (LoopItem card in GetLoop("SavedCards")) 2993 { 2994 @Render(new RadioButtonField 2995 { 2996 Name = "EcomCartSavedCardID", 2997 Label = card.GetString("Ecom:SavedCard.Name"), 2998 Value = card.GetString("Ecom:SavedCard.ID"), 2999 OnChange = "Cart.DeselectRadioGroup('EcomCartPaymethodID');PaymentSubmit()", 3000 Checked = card.GetBoolean("Ecom:SavedCard.IsSelected") 3001 }) 3002 3003 if (!card.GetBoolean("Ecom:SavedCard.IsSelected")) 3004 { 3005 savedCardName = card.GetString("Ecom:SavedCard.Name"); 3006 } 3007 } 3008 } 3009 3010 @Render(new HiddenField { Name = "EcomOrderSavedCardName", Id = "MySavedCardName", Value = savedCardName }) 3011 <script> 3012 3013 PaymentSubmit = function(e, id) { 3014 let elementname = e; 3015 let elementvalue = id; 3016 const XHR = new XMLHttpRequest(), 3017 FD = new FormData(); 3018 FD.append(elementname, elementvalue); 3019 XHR.addEventListener('load', function (event) { 3020 //Success 3021 }); 3022 // Define what happens in case of error 3023 XHR.addEventListener(' error', function (event) { 3024 //Error 3025 }); 3026 XHR.open('POST', 'Default.aspx?ID=@GetPageIdByNavigationTag("CartOrderlinesFeed")'); 3027 XHR.send(FD); 3028 }; 3029 3030 </script> 3031 } 3032 3033 @helper RenderHiddenPayment() 3034 { 3035 foreach (LoopItem payment in GetLoop("Paymethods")) 3036 { 3037 string selected = "checked"; 3038 3039 <div class="form__field-group u-margin-bottom"> 3040 <input type="radio" name="EcomCartPaymethodID" id="EcomCartPaymethodID_@payment.GetString("Ecom:Cart.Paymethod.ID")" value="@payment.GetString("Ecom:Cart.Paymethod.ID")" @selected /> 3041 <label for="EcomCartPaymethodID_@payment.GetString("Ecom:Cart.Paymethod.ID")" class="u-inline">@payment.GetString("Ecom:Cart.Paymethod.Name")</label> 3042 </div> 3043 } 3044 } 3045 3046 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3047 @using Dynamicweb.Core 3048 @using System 3049 @using System.Linq 3050 @using System.Collections.Generic 3051 @using Dynamicweb.Rapido.Blocks 3052 @using Dynamicweb.Rapido.Blocks.Components 3053 @using Dynamicweb.Rapido.Blocks.Components.General 3054 3055 @{ 3056 BlocksPage shippingCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 3057 string shippingCardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 3058 List<LoopItem> shippingMethods = GetLoop("Shippingmethods"); 3059 if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideShippingWarningsAndErrors")) 3060 { 3061 shippingMethods = shippingMethods.Where(s => !(string.Concat(s.GetString("Ecom:Cart.Shippingmethod.Error"), s.GetString("Ecom:Cart.Shippingmethod.Warning")).IsNotNullOrEmpty() && s.GetDouble("Ecom:Cart.ShippingMethod.Price.Price").Equals(0))).ToList(); 3062 } 3063 var shippingDeliveryCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 3064 if (string.IsNullOrEmpty(shippingDeliveryCountryCode)) 3065 { 3066 shippingDeliveryCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 3067 } 3068 bool shippingCountryIsNotSupported = !string.IsNullOrEmpty(shippingDeliveryCountryCode) && !GetLoop("Countries").Any(country => country.GetString("Ecom:Country.Code2") == shippingDeliveryCountryCode); 3069 3070 var shippingBlock = new Block() 3071 { 3072 Id = "Shipping", 3073 SortId = 20, 3074 Design = new Design 3075 { 3076 RenderType = RenderType.Column, 3077 Size = "6-auto" 3078 } 3079 }; 3080 3081 var shippingHeader = new Block 3082 { 3083 Id = "BillingAddressHeader", 3084 SortId = 10, 3085 Component = new Heading { Level = 3, Title = Translate("Shipping"), Icon = new Icon { Prefix = "fas", Name = "fa-truck", LabelPosition = IconLabelPosition.After } }, 3086 Design = new Design 3087 { 3088 RenderType = RenderType.CardHeader, 3089 CssClass = "u-color-light--bg" 3090 } 3091 }; 3092 3093 var shippingBody = new Block 3094 { 3095 Id = "BillingAddressBody", 3096 SortId = 20, 3097 Design = new Design { 3098 RenderType = RenderType.CardBody, 3099 CssClass = "u-color-light--bg " + shippingCardHeightClass 3100 } 3101 }; 3102 3103 if (shippingCountryIsNotSupported) 3104 { 3105 shippingBody.Component = new NotificationMessage { MessageType = NotificationMessageType.Error, Message = Translate("There is no available shipping options") }; 3106 shippingBlock.Add(shippingHeader); 3107 shippingBlock.Add(shippingBody); 3108 shippingCheckoutPage.Add("OrderContainerRow", shippingBlock); 3109 } 3110 else if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideShipping") && shippingMethods.Count > 0) 3111 { 3112 shippingBody.Template = RenderShipping(shippingMethods); 3113 shippingBlock.Add(shippingHeader); 3114 shippingBlock.Add(shippingBody); 3115 shippingCheckoutPage.Add("OrderContainerRow", shippingBlock); 3116 3117 Block parcelShopsModal = new Block() 3118 { 3119 Id = "ParcelShopsModal", 3120 SortId = 10, 3121 Component = new Modal 3122 { 3123 Id = "ParcelShops", 3124 Heading = new Heading 3125 { 3126 Title = Pageview.Device.ToString() != "Mobile" ? Translate("Choose a parcel shop") : Translate("Choose") 3127 }, 3128 BodyTemplate = RenderParcelShopsModalContent(), 3129 Width = ModalWidth.Lg 3130 } 3131 }; 3132 shippingCheckoutPage.Add("CheckoutTopSnippets", parcelShopsModal); 3133 3134 Block parcelShopsScriptTemplates = new Block() 3135 { 3136 Id = "ShippingProviderTemplates", 3137 SortId = 10, 3138 Template = RenderShippingProviderTemplates() 3139 }; 3140 shippingCheckoutPage.Add("CheckoutBottomSnippets", parcelShopsScriptTemplates); 3141 } 3142 } 3143 3144 @helper RenderShipping(List<LoopItem> shippingMethods) 3145 { 3146 if (shippingMethods == null) 3147 { 3148 shippingMethods = GetLoop("Shippingmethods"); 3149 } 3150 bool defaultShippingIsSet = Dynamicweb.Ecommerce.Orders.Shipping.GetDefaultShippingMethod(Dynamicweb.Ecommerce.Common.Context.Cart.ShippingMethodCountryCode) != null; 3151 bool haveShippingContent = shippingMethods.Count != 1 || !defaultShippingIsSet; 3152 bool showShippingsBlock = haveShippingContent; 3153 string errorMessage = GetString("Ecom:Cart.ValidationError.EcomCartShippingmethodId.ErrorMessage"); 3154 3155 foreach (LoopItem shipping in shippingMethods) 3156 { 3157 bool selected = Converter.ToBoolean(shipping.GetString("Ecom:Cart.Shippingmethod.IsSelected")); 3158 object shippingProviderContent = selected ? Newtonsoft.Json.JsonConvert.DeserializeObject(shipping.GetString("Ecom:ShippingProvider.Content")) : null; 3159 string hideLabel = haveShippingContent ? "" : "u-hidden"; 3160 string leftMargin = haveShippingContent ? "u-margin--radio-button-indent" : ""; 3161 3162 @Render(new RadioButtonField 3163 { 3164 OnChange = "Cart.SubmitCart()", 3165 Label = shipping.GetString("Ecom:Cart.Shippingmethod.Name"), 3166 Name = "EcomCartShippingmethodId", 3167 Id = "EcomCartShippingmethodId_" + shipping.GetString("Ecom:Cart.Shippingmethod.ID"), 3168 Value = shipping.GetString("Ecom:Cart.Shippingmethod.ID"), 3169 CssClass = hideLabel, 3170 Checked = selected, 3171 WrapperCssClass = shippingProviderContent != null ? "u-margin-bottom" : "" 3172 }) 3173 3174 if (shippingProviderContent != null) 3175 { 3176 showShippingsBlock = true; 3177 3178 <div id="ShippingProviderContent" class="@leftMargin" data-template="ShippingProviderContentTemplate"></div> 3179 <script> 3180 document.addEventListener("DOMContentLoaded", function (event) { 3181 HandlebarsBolt.CreateItemsFromJson(@shippingProviderContent, "ShippingProviderContent", "ShippingProviderContentTemplate"); 3182 HandlebarsBolt.CreateItemsFromJson(@shippingProviderContent, "ParcelShops", "ParcelShopsTemplate"); 3183 RememberState.SetCookie("useAnotherAddress", false); 3184 }); 3185 3186 function setParcelShopToDeliveryFields(number, address) { 3187 Cart.FillShippingAddress(address); 3188 document.getElementById("parcelShopNumber").value = number; 3189 Cart.SubmitCart(); 3190 } 3191 </script> 3192 } 3193 3194 if (shippingProviderContent != null && @shipping.GetString("Ecom:ShippingProvider.Content").Length < 10) 3195 { 3196 @Render(new Button { ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--full u-no-margin u-margin-bottom", OnClick = "Cart.SubmitCart()", Title = Translate("Get parcel shops") }) 3197 <small class="help-text dw-mod">@Translate("Requires a valid address")</small> 3198 } 3199 3200 } 3201 if (!string.IsNullOrEmpty(errorMessage)) 3202 { 3203 @Render(new NotificationMessage { Message = errorMessage, MessageType = NotificationMessageType.Error }) 3204 } 3205 3206 if (!showShippingsBlock) 3207 { 3208 <script> 3209 var shippingBlock = document.getElementById("Block__Shipping"); 3210 if (shippingBlock) { 3211 shippingBlock.classList.add("u-hidden"); 3212 } 3213 </script> 3214 } 3215 } 3216 3217 @helper RenderParcelShopsModalContent() 3218 { 3219 <div class="grid grid--bleed"> 3220 <div class="grid__col-auto u-margin-right"> 3221 <ul class="list list--clean list--scroll dw-mod" id="ParcelShops" data-template="ParcelShopsTemplate"></ul> 3222 </div> 3223 @if (Pageview.Device.ToString() != "Mobile") 3224 { 3225 <div class="grid__col-8"> 3226 <div class="map-container"> 3227 <div id="MapCanvas" class="map-container__canvas"></div> 3228 </div> 3229 </div> 3230 } 3231 </div> 3232 } 3233 3234 @helper RenderShippingAddressFromParcelShop() 3235 { 3236 @Render(new HiddenField { Name = "EcomOrderDeliveryName", Id = "EcomOrderDeliveryName", Value = "{{company}}" }) 3237 @Render(new HiddenField { Name = "EcomOrderDeliveryCompany", Id = "EcomOrderDeliveryCompany", Value = "{{company}}" }) 3238 @Render(new HiddenField { Name = "EcomOrderDeliveryAddress", Id = "EcomOrderDeliveryAddress", Value = "{{address}}" }) 3239 @Render(new HiddenField { Name = "EcomOrderDeliveryZip", Id = "EcomOrderDeliveryZip", Value = "{{zip}}" }) 3240 @Render(new HiddenField { Name = "EcomOrderDeliveryCity", Id = "EcomOrderDeliveryCity", Value = "{{city}}" }) 3241 @Render(new HiddenField { Name = "EcomOrderDeliveryRegion", Id = "EcomOrderDeliveryRegion", Value = "" }) 3242 @Render(new HiddenField { Name = "EcomOrderDeliveryCountry", Id = "EcomOrderDeliveryCountry", Value = "{{countryCode}}" }) 3243 3244 @Render(new HiddenField { Name = "EcomOrderDeliveryEmail", Id = "EcomOrderDeliveryEmail", Value = "" }) 3245 @Render(new HiddenField { Name = "EcomOrderDeliveryPhone", Id = "EcomOrderDeliveryPhone", Value = "" }) 3246 } 3247 3248 @helper RenderShippingProviderTemplates() 3249 { 3250 <script id="ShippingProviderContentTemplate" type="text/x-template"> 3251 {{#.}} 3252 <div class="{{hideShippingProvider}}"> 3253 {{#SelectedParcelShop}} 3254 <div class="u-hidden"> 3255 <input type="radio" id="parcelShopNumber" class="u-no-margin" name="{{fieldPrefix}}{{fieldPostfix}}" value="{{number}}" {{selected}} /> 3256 </div> 3257 <div> 3258 @Render(new Icon { Prefix = "fas", Name = "fa-map-marker", Label = "<span class='u-bold'>{{company}}</span>" }) 3259 <div>{{address}}</div> 3260 <div>{{zip}} {{city}}</div> 3261 <div>{{country}}</div> 3262 </div> 3263 @RenderShippingAddressFromParcelShop() 3264 {{/SelectedParcelShop}} 3265 {{^SelectedParcelShop}} 3266 @Translate("No points found") 3267 {{/SelectedParcelShop}} 3268 <div class="u-margin-top"> 3269 <label for="ParcelShopsModalTrigger" class="btn btn--secondary btn--full dw-mod" onclick="Maps.Init({containerId: 'MapCanvas', locationsList: {{toJSON ParcelShops}}, markerCallback: Cart.SelectParcelShop, selectionCallback: 'setParcelShopToDeliveryFields', buttonText: '@Translate("Select")'})">@Translate("Change parcel shop")</label> 3270 </div> 3271 </div> 3272 {{/.}} 3273 </script> 3274 3275 <script id="ParcelShopsTemplate" type="text/x-template"> 3276 {{#.}} 3277 {{#ParcelShops}} 3278 <li data-number="{{number}}" data-lat="{{latitude}}" data-lng="{{longitude}}" class="u-border-bottom u-padding-bottom"> 3279 <input type="radio" name="{{fieldPrefix}}{{fieldPostfix}}" value="{{number}}" class="form__control" id="{{fieldPrefix}}ParcelShopNumber_{{number}}" {{selected}} 3280 onclick="setParcelShopToDeliveryFields('{{number}}', { 3281 Name: '{{company}}', @*is it ok???*@ 3282 Company: '{{company}}', 3283 Address: '{{address}}', 3284 Zip: '{{zip}}', 3285 City: '{{city}}', 3286 Country: '{{countryCode}}' 3287 })" /> 3288 <label for="{{fieldPrefix}}ParcelShopNumber_{{number}}" class="u-flex"> 3289 <span> 3290 <span class="u-margin-bottom u-block u-bold">{{company}}</span> 3291 <span class="u-line-height--normal u-font-size--sm"> 3292 <span class="u-block">{{address}}</span> 3293 <span class="u-block">{{zip}} {{city}}</span> 3294 <span class="u-block">{{country}}</span> 3295 </span> 3296 </span> 3297 </label> 3298 </li> 3299 {{/ParcelShops}} 3300 {{/.}} 3301 </script> 3302 3303 3304 string mapsScriptUrl = "//maps.googleapis.com/maps/api/js"; 3305 mapsScriptUrl += !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleMapsAPIKey")) ? "?key=" + Pageview.AreaSettings.GetItem("Settings").GetString("GoogleMapsAPIKey") : ""; 3306 3307 <script src="@mapsScriptUrl"></script> 3308 } 3309 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3310 @using Dynamicweb.Core 3311 @using System 3312 @using System.Web 3313 @using System.Collections.Generic 3314 @using Dynamicweb.Rapido.Blocks 3315 @using Dynamicweb.Rapido.Blocks.Components 3316 @using Dynamicweb.Rapido.Blocks.Components.General 3317 3318 @{ 3319 BlocksPage voucherCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 3320 string voucherCardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 3321 3322 if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideVoucher")) 3323 { 3324 Block voucherBlock = new Block() 3325 { 3326 Id = "Voucher", 3327 SortId = 30, 3328 Design = new Design 3329 { 3330 RenderType = RenderType.Column, 3331 Size = "6-auto" 3332 }, 3333 BlocksList = new List<Block> { 3334 new Block { 3335 Id = "VoucherHeader", 3336 SortId = 10, 3337 Component = new Heading { Level = 3, Title = Translate("Voucher"), Icon = new Icon { Prefix = "fas", Name = "fa-gift", LabelPosition = IconLabelPosition.After } }, 3338 Design = new Design { 3339 RenderType = RenderType.CardHeader, 3340 CssClass = "u-color-light--bg" 3341 } 3342 }, 3343 new Block { 3344 Id = "VoucherBody", 3345 SortId = 20, 3346 Template = RenderVoucher(), 3347 Design = new Design { 3348 RenderType = RenderType.CardBody, 3349 CssClass = "u-color-light--bg " + voucherCardHeightClass 3350 } 3351 } 3352 } 3353 }; 3354 voucherCheckoutPage.Add("OrderContainerRow", voucherBlock); 3355 } 3356 } 3357 3358 @helper RenderVoucher() 3359 { 3360 string cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 3361 <div class="form__field-combi"> 3362 @Render(new TextField { Placeholder = Translate("Enter voucher code"), Name = "EcomOrderVoucherCode", Id = "EcomOrderVoucherCode", Value = GetString("Ecom:Order.Customer.VoucherCode"), CssClass = "u-full-width" }) 3363 @Render(new Button { ButtonType = ButtonType.Button, OnClick = "VoucherSubmit('EcomOrderVoucherCode', document.getElementById('EcomOrderVoucherCode').value);", Id = "EcomOrderVoucherApply", Title = Translate("Apply"), CssClass = "btn--condensed u-no-margin" }) 3364 </div> 3365 <div class="js-handlebars-root" id="VoucherCodeContaner" data-template="VoucherTemplate" data-json-feed="/Default.aspx?ID=@cartFeedPageId" data-preloader="minimal"> </div> 3366 3367 3368 <script id="VoucherTemplate" type="text/x-template"> 3369 {{#.}} 3370 <div class="field-error u-full-width dw-mod"> {{{errorVoucher}}}</div> 3371 <div class="field-success u-full-width dw-mod">{{{messageVoucher}}}</div> 3372 {{/.}} 3373 </script> 3374 3375 <script> 3376 3377 document.getElementById("VoucherCodeContaner").addEventListener("contentLoaded", function (event) { 3378 var input = document.getElementById("EcomOrderVoucherCode"); 3379 var inputVoucher = document.querySelector("#VoucherCodeContaner .field-error"); 3380 var stepButtonId = document.getElementById("CartV2.GotoStep3") ? "CartV2.GotoStep3" : "CartV2.GotoStep1"; 3381 var stepButton = document.getElementById(stepButtonId); 3382 3383 if (inputVoucher.innerHTML.length>1) { 3384 stepButton.classList.add("disabled-btn") 3385 } 3386 else { 3387 stepButton.classList.remove("disabled-btn") 3388 } 3389 3390 }); 3391 // Execute a function when the user releases a key on the keyboard 3392 document.getElementById("EcomOrderVoucherCode").addEventListener("keypress", function (event) { 3393 // Number 13 is the "Enter" key on the keyboard 3394 if (event.keyCode === 13) { 3395 // Cancel the default action, if needed 3396 event.preventDefault(); 3397 // Trigger the button element with a click 3398 document.getElementById("EcomOrderVoucherApply").click(); 3399 } 3400 }); 3401 3402 VoucherSubmit = function (e, id) { 3403 var selectForm = document.getElementById("OrderSubmit"); // Select the form by ID. 3404 let elementname = e; 3405 let elementvalue = id; 3406 clearTimeout(updateDelay); 3407 3408 updateDelay = setTimeout(function () { 3409 const XHR = new XMLHttpRequest(), 3410 FD = new FormData(); 3411 FD.append(elementname, elementvalue); 3412 XHR.addEventListener('load', function (event) { 3413 //Success 3414 }); 3415 // Define what happens in case of error 3416 XHR.addEventListener(' error', function (event) { 3417 //Error 3418 }); 3419 XHR.open('POST', 'Default.aspx?ID=@cartFeedPageId'); 3420 XHR.send(FD); 3421 3422 3423 HandlebarsBolt.UpdateContent('SummaryCart', 3424 '/Default.aspx?ID=@cartFeedPageId' + '&redirect=false', 3425 '/Default.aspx?ID=@cartFeedPageId' + '&redirect=false', 3426 'CartOrderlineSummary', 'minimal'); 3427 HandlebarsBolt.UpdateContent('VoucherCodeContaner', 3428 '/Default.aspx?ID=@cartFeedPageId' + '&redirect=false', 3429 '/Default.aspx?ID=@cartFeedPageId' + '&redirect=false', 3430 'VoucherTemplate', 'minimal'); 3431 3432 }, 100); 3433 3434 }; 3435 3436 </script> 3437 } 3438 3439 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3440 @using Dynamicweb.Core 3441 @using System 3442 @using System.Web 3443 @using System.Collections.Generic 3444 @using Dynamicweb.Rapido.Blocks 3445 @using Dynamicweb.Rapido.Blocks.Components 3446 @using Dynamicweb.Rapido.Blocks.Components.General 3447 3448 @{ 3449 BlocksPage recurringCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 3450 string recurringCardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 3451 3452 if (!string.IsNullOrWhiteSpace(GetString("Ecom:Order.PaymentMethod.RecurringSupport")) && !Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideRecurringOrder")) 3453 { 3454 Block recurringOrderBlock = new Block() 3455 { 3456 Id = "RecurringOrder", 3457 SortId = 40, 3458 Design = new Design 3459 { 3460 RenderType = RenderType.Column, 3461 Size = "12" 3462 }, 3463 BlocksList = new List<Block> { 3464 new Block { 3465 Id = "RecurringOrderHeader", 3466 SortId = 10, 3467 Component = new Heading { Level = 3, Title = Translate("Recurring order"), Icon = new Icon { Prefix = "fas", Name = "fa-calendar", LabelPosition = IconLabelPosition.After } }, 3468 Design = new Design { 3469 RenderType = RenderType.CardHeader, 3470 CssClass = "u-color-light--bg" 3471 } 3472 }, 3473 new Block { 3474 Id = "RecurringOrderBody", 3475 SortId = 20, 3476 Template = RenderRecurringOrder(), 3477 Design = new Design { 3478 RenderType = RenderType.CardBody, 3479 CssClass = "u-color-light--bg " + recurringCardHeightClass 3480 } 3481 } 3482 } 3483 }; 3484 recurringCheckoutPage.Add("OrderContainerRow", recurringOrderBlock); 3485 } 3486 } 3487 3488 @helper RenderRecurringOrder() { 3489 string dateFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; 3490 string startDate = !string.IsNullOrEmpty(GetString("Ecom:Order.Recurring.StartDate.Clean")) ? GetDate("Ecom:Order.Recurring.StartDate.Clean").ToString(dateFormat) : ""; 3491 string endDate = !string.IsNullOrEmpty(GetString("Ecom:Order.Recurring.EndDate.Clean")) ? GetDate("Ecom:Order.Recurring.EndDate.Clean").ToString(dateFormat) : ""; 3492 dateFormat = dateFormat.Replace("dd", "d"); 3493 dateFormat = dateFormat.Replace("MM", "m"); 3494 dateFormat = dateFormat.Replace("yyyy", "Y"); 3495 string endLabel = Pageview.Device.ToString() != "Mobile" ? Translate("And it should end on") : Translate("End date"); 3496 3497 @Render(new CheckboxField { 3498 Label = Translate("Create recurring order"), 3499 Name = "EcomRecurringOrderCreate", 3500 Id = "EcomRecurringOrderCreate", 3501 Checked = GetBoolean("Ecom:Order.Recurring.Enabled"), 3502 ExtraAttributes = new Dictionary<string, string>() { 3503 { "data-expand", "EcomRecurringOrderCreate" } 3504 } 3505 }) 3506 3507 <div class="expandable--collapsed" data-trigger="EcomRecurringOrderCreate"> 3508 <label for="Country">@Translate("I want my order every")</label> 3509 <div class="grid grid--external-bleed-x"> 3510 <div class="grid__col-6 grid__col--bleed-y"> 3511 @{ 3512 SelectField selectInterval = new SelectField 3513 { 3514 Id = "EcomOrderRecurringInterval", 3515 Name = "EcomOrderRecurringInterval", 3516 OnChange = "Cart.SubmitCart()", 3517 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerState.ErrorMessage") 3518 }; 3519 for (var i = 1; i <= 12; i++) 3520 { 3521 bool selected = GetInteger("Ecom:Order.Recurring.Interval") == i ? true : false; 3522 selectInterval.Options.Add(new SelectFieldOption { Label = i.ToString(), Value = i.ToString(), Checked = selected }); 3523 } 3524 @Render(selectInterval) 3525 } 3526 </div> 3527 <div class="grid__col-6 grid__col--bleed-y"> 3528 @{ 3529 var units = new[] { "Days", "Weeks", "Months" }; 3530 3531 SelectField selectUnit = new SelectField 3532 { 3533 Id = "EcomOrderRecurringIntervalUnit", 3534 Name = "EcomOrderRecurringIntervalUnit", 3535 OnChange = "Cart.SubmitCart()", 3536 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerState.ErrorMessage") 3537 }; 3538 for (int i = 0; i < units.Length; i++) 3539 { 3540 bool selected = GetInteger("Ecom:Order.Recurring.IntervalUnit") == i ? true : false; 3541 selectUnit.Options.Add(new SelectFieldOption { Label = Translate(units[i]), Value = i.ToString(), Checked = selected }); 3542 } 3543 @Render(selectUnit) 3544 } 3545 </div> 3546 </div> 3547 3548 <div class="grid grid--external-bleed-x"> 3549 <div class="grid__col-6 grid__col--bleed-y"> 3550 @Render(new DateTimeField { 3551 Label = Translate("Start date"), 3552 Id = "EcomOrderRecurringStartDate", 3553 Name = "EcomOrderRecurringStartDate", 3554 Placeholder = Translate("Never"), 3555 Value = startDate, 3556 DateFormat = dateFormat, 3557 MinDate = "today" 3558 }) 3559 </div> 3560 <div class="grid__col-6 grid__col--bleed-y"> 3561 @Render(new DateTimeField { 3562 Label = endLabel, 3563 Id = "EcomOrderRecurringEndDate", 3564 Name = "EcomOrderRecurringEndDate", 3565 Placeholder = Translate("Never"), 3566 Value = endDate, 3567 DateFormat = dateFormat, 3568 MinDate = "today" 3569 }) 3570 </div> 3571 </div> 3572 </div> 3573 } 3574 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3575 @using Dynamicweb 3576 @using Dynamicweb.Core 3577 @using System 3578 @using System.Web 3579 @using System.Collections.Generic 3580 @using Dynamicweb.Rapido.Blocks 3581 @using Dynamicweb.Rapido.Blocks.Components 3582 @using Dynamicweb.Rapido.Blocks.Components.General 3583 3584 @functions{ 3585 BlocksPage reviewOrderCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 3586 string cartFeedPageId; 3587 bool canCompleteOrder = true; 3588 } 3589 3590 @{ 3591 string reviewOrderType = checkoutPageType ?? "onestep"; //The "checkoutPageType" comes from the main template for the cart page 3592 3593 cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 3594 3595 if (!String.IsNullOrWhiteSpace(GetString("Ecom:OrderContext.ID"))) 3596 { 3597 cartFeedPageId += "&OrderContext=" + GetString("Ecom:OrderContext.ID"); 3598 } 3599 3600 3601 var paymentCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 3602 var shippingCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 3603 var paymentCountryIsSupported = string.IsNullOrEmpty(paymentCountryCode) || GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == paymentCountryCode)); 3604 var shippingCountryIsSupported = string.IsNullOrEmpty(shippingCountryCode) ? paymentCountryIsSupported : GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == shippingCountryCode)); 3605 3606 canCompleteOrder = paymentCountryIsSupported && shippingCountryIsSupported; 3607 3608 Block reviewOrderBlock = new Block() 3609 { 3610 Id = "ReviewOrder", 3611 SortId = 50, 3612 SkipRenderBlocksList = true, 3613 Template = RenderReviewOrder() 3614 }; 3615 reviewOrderCheckoutPage.Add("OrderContainerRow", reviewOrderBlock); 3616 3617 if (reviewOrderType == "onestep") 3618 { 3619 Block inlineAcceptanceBlock = new Block() 3620 { 3621 Id = "Acceptance", 3622 SortId = 10, 3623 Template = RenderInlineAcceptance() 3624 }; 3625 reviewOrderCheckoutPage.Add("ReviewOrder", inlineAcceptanceBlock); 3626 3627 Block reviewOrderFooterBlock = new Block() 3628 { 3629 Id = "ReviewOrderFooter", 3630 SortId = 20, 3631 Template = RenderReviewOrderFooter() 3632 }; 3633 reviewOrderCheckoutPage.Add("ReviewOrder", reviewOrderFooterBlock); 3634 } 3635 3636 if (reviewOrderType == "quote") 3637 { 3638 Block reviewOrderFooterBlock = new Block() 3639 { 3640 Id = "ReviewOrderFooter", 3641 SortId = 20, 3642 Template = RenderReviewOrderFooterQuote() 3643 }; 3644 reviewOrderCheckoutPage.Add("ReviewOrder", reviewOrderFooterBlock); 3645 } 3646 3647 Block reviewOrderScriptTemplates = new Block() 3648 { 3649 Id = "ReviewOrderScriptTempaltes", 3650 SortId = 30, 3651 BlocksList = new List<Block> { 3652 new Block { 3653 Id = "CartContentTemplate", 3654 SortId = 10, 3655 Template = RenderCartContentTemplate() 3656 }, 3657 new Block { 3658 Id = "CartOrderlineTemplate", 3659 SortId = 20, 3660 Template = RenderCartOrderlineTemplate() 3661 }, 3662 new Block { 3663 Id = "CartOrderlineMobileTemplate", 3664 SortId = 30, 3665 Template = RenderCartOrderlineMobileTemplate() 3666 }, 3667 new Block { 3668 Id = "CartOrderlineDiscountTemplate", 3669 SortId = 40, 3670 Template = RenderCartOrderlineDiscountTemplate() 3671 }, 3672 new Block { 3673 Id = "EmptyCartTemplate", 3674 SortId = 50, 3675 Template = RenderEmptyCartTemplate() 3676 }, 3677 new Block 3678 { 3679 Id = "EmptyCartObserver", 3680 SortId = 60, 3681 Template = RenderEmptyCartObserver() 3682 } 3683 } 3684 }; 3685 reviewOrderCheckoutPage.Add("CheckoutBottomSnippets", reviewOrderScriptTemplates); 3686 3687 Block reviewOrderScripts = new Block() 3688 { 3689 Id = "ReviewOrderScripts", 3690 SortId = 40, 3691 Template = RenderOrderScripts() 3692 }; 3693 reviewOrderCheckoutPage.Add("CheckoutBottomSnippets", reviewOrderScripts); 3694 } 3695 3696 @helper RenderReviewOrder() 3697 { 3698 <div class="grid__col-12"> 3699 <div class="js-handlebars-root" id="Cart" data-template="CartContent" data-cart-id="@cartFeedPageId" data-json-feed="/Default.aspx?ID=@cartFeedPageId" data-preloader="overlay"></div> 3700 </div> 3701 } 3702 3703 @helper RenderCartContentTemplate() 3704 { 3705 List<Block> subBlocks = reviewOrderCheckoutPage.GetBlockListById("ReviewOrder").OrderBy(item => item.SortId).ToList(); 3706 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3707 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 3708 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(GetString("Ecom:Order.ID")); 3709 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 3710 3711 <script id="CartContent" type="text/x-template"> 3712 {{#.}} 3713 @if (useGoogleTagManager) 3714 { 3715 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text> 3716 } 3717 <div class="card-header u-color-light--bg dw-mod"> 3718 @Render(new Heading { Title = Translate("Review order") + "({{numberofproducts}})", Level = 3, Icon = new Icon { Prefix = "fas", Name = "fa-list-ul", LabelPosition = IconLabelPosition.After } }) 3719 </div> 3720 <div class="card u-color-light--bg u-no-padding--xs dw-mod"> 3721 {{#unless isEmpty}} 3722 <table class="table cart-table dw-mod"> 3723 <tbody id="OrderLines"> 3724 {{#OrderLines}} 3725 {{> (lookup . 'template') }} 3726 {{/OrderLines}} 3727 </tbody> 3728 </table> 3729 {{/unless}} 3730 <div class="grid u-border-top"> 3731 <div class="grid__col-sm-6"> 3732 @if (Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 3733 { 3734 <text> 3735 {{#if userPoints}} 3736 <div class="u-border u-border-color--loyalty-points u-padding--lg u-full-height"> 3737 @Render(new Heading { Title = Translate("Your point balance"), Level = 3 }) 3738 <div class="u-font-size--lg u-margin-bottom"> 3739 <span class="u-color--loyalty-points">{{userPoints}}</span> @Translate("points") 3740 </div> 3741 <div>@Translate("On this order you will use"): <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")</div> 3742 </div> 3743 {{/if}} 3744 </text> 3745 } 3746 </div> 3747 3748 <div class="grid__col-sm-6"> 3749 @if (!pointShop) 3750 { 3751 <text> 3752 {{#unless hideSubTotal}} 3753 <div> 3754 <div class="cart-summary__subtotals dw-mod">@Translate("Subtotal")</div> 3755 <div class="cart-summary__subtotals u-pull--right dw-mod"> 3756 @if (hasTaxSettings) 3757 { 3758 <text>{{subtotalpricewithouttaxes}}</text> 3759 } 3760 else 3761 { 3762 <text>{{subtotalprice}}</text> 3763 } 3764 </div> 3765 </div> 3766 {{/unless}} 3767 </text> 3768 <text> 3769 {{#unless hidePaymentfee}} 3770 <div> 3771 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-credit-card", Label = "{{paymentmethod}}", LabelPosition = IconLabelPosition.After })</div> 3772 <div class="cart-summary__info u-pull--right dw-mod">{{paymentfee}}</div> 3773 </div> 3774 {{/unless}} 3775 </text> 3776 } 3777 {{#unless hideShippingfee}} 3778 <div> 3779 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-truck", Label = "{{shippingmethod}}", LabelPosition = IconLabelPosition.After })</div> 3780 <div class="cart-summary__info u-pull--right dw-mod">{{shippingfee}}</div> 3781 </div> 3782 {{/unless}} 3783 {{#if hasTaxSettings}} 3784 <div> 3785 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-hand-holding-usd", Label = Translate("Sales Tax"), LabelPosition = IconLabelPosition.After })</div> 3786 <div class="cart-summary__info u-pull--right dw-mod">{{totaltaxes}}</div> 3787 </div> 3788 {{/if}} 3789 @if (Pageview.User != null && Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints")) 3790 { 3791 <text> 3792 {{#if earnings}} 3793 <div> 3794 <div class="cart-summary__info dw-mod">@Translate("Earnings")</div> 3795 <div class="cart-summary__info u-pull--right dw-mod"><span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")</div> 3796 </div> 3797 {{/if}} 3798 </text> 3799 } 3800 <div class="cart-summary__totals-container dw-mod"> 3801 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 3802 <div class="cart-summary__totals u-pull--right dw-mod"> 3803 @if (pointShop) 3804 { 3805 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points") 3806 } 3807 else 3808 { 3809 <text>{{totalprice}}</text> 3810 } 3811 </div> 3812 </div> 3813 @if (!pointShop && !hasTaxSettings) 3814 { 3815 <div class="u-ta-right"> 3816 <small class="cart-summary__info dw-mod">@Translate("VAT"):</small> 3817 <small class="cart-summary__info dw-mod">{{totalvat}}</small> 3818 </div> 3819 3820 if (isPricesWithVATEnabled) 3821 { 3822 <div class="u-ta-right"> 3823 <small class="cart-summary__info dw-mod">@Translate("Total price without VAT"):</small> 3824 <small class="cart-summary__info dw-mod">{{totalPriceWithoutVat}}</small> 3825 </div> 3826 } 3827 else 3828 { 3829 <div class="u-ta-right"> 3830 <small class="cart-summary__info dw-mod">@Translate("Total price with VAT"):</small> 3831 <small class="cart-summary__info dw-mod">{{totalPriceWithVat}}</small> 3832 </div> 3833 } 3834 } 3835 {{#if showCheckoutDisclaimer}} 3836 <div class="u-ta-right"> 3837 <small>{{checkoutDisclaimer}}</small> 3838 </div> 3839 {{/if}} 3840 </div> 3841 </div> 3842 3843 <div class="grid"> 3844 <div class="grid__col-12 grid__col--line-top"></div> 3845 </div> 3846 3847 {{#unless hideComment}} 3848 <div class="grid__cell u-padding--xs"> 3849 @Render(new TextareaField { Rows = 3, Placeholder = Translate("Enter comment"), Name = "EcomOrderCustomerComment", Id = "EcomOrderCustomerComment", Value = "{{comment}}" }) 3850 </div> 3851 {{/unless}} 3852 <div class="u-margin-bottom--lg"> 3853 @foreach (LoopItem error in GetLoop("ValidationErrors")) 3854 { 3855 @Render(new NotificationMessage { Message = error.GetString("Ecom:Cart.ValidationError.ErrorMessage"), MessageType = NotificationMessageType.Error }) 3856 } 3857 </div> 3858 3859 @RenderBlockList(subBlocks) 3860 </div> 3861 {{/.}} 3862 </script> 3863 } 3864 3865 @helper RenderCartOrderlineTemplate() 3866 { 3867 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3868 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 3869 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 3870 3871 @* Template for the orderlines *@ 3872 <script id="CartOrderline" type="text/x-template"> 3873 {{#unless isEmpty}} 3874 <tr id="Orderline{{id}}" class="cart-orderline"> 3875 <td class="cart-orderline__cell cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 3876 <div class="cart-orderline__cell__block {{hideimage}} dw-mod"> 3877 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 3878 </div> 3879 </td> 3880 <td class="cart-orderline__cell u-va-middle dw-mod" title="{{name}} {{variantname}}"> 3881 <a href="{{link}}" class="u-color-inherit cart-orderline__name">{{name}}</a> 3882 {{#if productnumber}} 3883 <div class="cart-orderline__cell__block item-number dw-mod">#{{productnumber}}</div> 3884 {{/if}} 3885 {{#if variantname}} 3886 <div class="cart-orderline__cell__block item-number dw-mod">{{variantname}}</div> 3887 {{/if}} 3888 {{#if unitname}} 3889 <div class="cart-orderline__cell__block item-number dw-mod">{{unitname}}</div> 3890 {{/if}} 3891 </td> 3892 <td class="cart-orderline__cell u-ta-right u-hidden-xs u-hidden-xxs dw-mod" width="120"> 3893 {{#if pointsTotal}} 3894 <span class="u-color--loyalty-points">{{pointPrice}}</span> @Translate("points") 3895 {{else}} 3896 {{unitprice}} 3897 {{/if}} 3898 </td> 3899 3900 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 3901 { 3902 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 3903 @Render(new NumberField 3904 { 3905 Id = "Quantity_{{orderLineId}}", 3906 Min = 1, 3907 OnChange = "Cart.ChangeQuantity('" + cartFeedPageId + "', '{{orderLineId}}', this.value)", 3908 Name = "QuantityOrderLine{{orderLineId}}", 3909 Value = "{{quantity}}", 3910 CssClass = "u-w80px", 3911 ActionButton = new Button 3912 { 3913 ButtonType = ButtonType.Button, 3914 ButtonLayout = ButtonLayout.Clean, 3915 OnClick = "{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}} Cart.UpdateCart(null, '/Default.aspx?ID=" + cartFeedPageId + "', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);", 3916 Icon = new Icon { Prefix = "fas", Name = "fa-times", LabelPosition = IconLabelPosition.After } 3917 } 3918 }) 3919 </td> 3920 } 3921 else 3922 { 3923 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 3924 @Render(new HiddenField { Id = "Quantity_{{orderLineId}}", Name = "QuantityOrderLine{{orderLineId}}", Value = "{{quantity}}" }) 3925 <div class="u-w80px u-no-margin">{{quantity}}</div> 3926 </td> 3927 } 3928 3929 <td class="cart-orderline__cell u-ta-right dw-mod"> 3930 {{#if pointsTotal}} 3931 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 3932 {{else}} 3933 <div>{{totalprice}}</div> 3934 {{/if}} 3935 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 3936 { 3937 <text> 3938 {{#if canBePurchasedWithPoints}} 3939 @Render(new Button { Title = Translate("Use") + " {{pointPrice}} " + Translate("points"), ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.None, CssClass = "btn btn--loyalty-points btn--sm u-no-margin", OnClick = "Cart.BuyForPoints('" + GetGlobalValue("Global:Page.ID") + "', '" + cartFeedPageId + "', '{{orderLineId}}', '{{id}}', '{{variantId}}');", Icon = new Icon { Prefix = "far", Name = "fa-tag", LabelPosition = IconLabelPosition.After } }) 3940 {{/if}} 3941 </text> 3942 } 3943 </td> 3944 </tr> 3945 {{/unless}} 3946 <tr class="{{hideBomItems}}"> 3947 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"><div class="{{hideimage}}"></div></td> 3948 <td colspan="5" class="u-no-padding"> 3949 <table class="u-no-margin u-color-light-gray--bg"> 3950 <tbody> 3951 {{#BomItems}} 3952 <tr> 3953 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 3954 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 3955 </td> 3956 <td title="{{name}} {{variantname}}"> 3957 <a href="{{link}}" class="u-color-inherit dw-mod">{{name}}</a> 3958 {{#if productnumber}} 3959 <div class="item-number dw-mod">#{{productnumber}}</div> 3960 {{/if}} 3961 {{#if variantname}} 3962 <div class="item-number dw-mod">{{variantname}}</div> 3963 {{/if}} 3964 {{#if unitname}} 3965 <div class="item-number dw-mod">{{unitname}}</div> 3966 {{/if}} 3967 </td> 3968 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 3969 <td>{{quantity}}</td> 3970 <td>&nbsp;</td> 3971 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 3972 </tr> 3973 {{/BomItems}} 3974 </tbody> 3975 </table> 3976 </td> 3977 </tr> 3978 </script> 3979 } 3980 3981 @helper RenderCartOrderlineMobileTemplate() 3982 { 3983 <script id="CartOrderlineMobile" type="text/x-template"> 3984 {{#unless isEmpty}} 3985 <tr id="Orderline{{id}}"> 3986 <td class="cart-table__image dw-mod"> 3987 <div class="{{hideimage}}"> 3988 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 3989 </div> 3990 </td> 3991 <td title="{{name}} {{variantname}}" colspan="4"> 3992 <a href="{{link}}" class="u-color-inherit">{{name}}</a> 3993 {{#if productnumber}} 3994 <div>#{{productnumber}}</div> 3995 {{/if}} 3996 {{#if variantname}} 3997 <div>{{variantname}}</div> 3998 {{/if}} 3999 {{#if unitname}} 4000 <div>{{unitname}}</div> 4001 {{/if}} 4002 </td> 4003 </tr> 4004 <tr class="table__row--no-border"> 4005 <td class="cart-table__image dw-mod"></td> 4006 <td colspan="4"> 4007 <div class="u-pull--left"> 4008 @Render(new NumberField 4009 { 4010 Id = "Quantity_{{orderLineId}}", 4011 Min = 1, 4012 OnChange = "Cart.ChangeQuantity('" + cartFeedPageId + "', '{{orderLineId}}', this.value)", 4013 Name = "QuantityOrderLine{{orderLineId}}", 4014 Value = "{{quantity}}", 4015 CssClass = "u-w80px", 4016 ActionButton = new Button 4017 { 4018 ButtonType = ButtonType.Button, 4019 ButtonLayout = ButtonLayout.Clean, 4020 OnClick = "{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}} Cart.UpdateCart(null, '/Default.aspx?ID=" + cartFeedPageId + "', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);", 4021 Icon = new Icon { Prefix = "fas", Name = "fa-times", LabelPosition = IconLabelPosition.After } 4022 } 4023 }) 4024 </div> 4025 <div class="u-pull--right u-ta-right"> 4026 {{#if pointsTotal}} 4027 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 4028 {{else}} 4029 <div>{{totalprice}}</div> 4030 {{/if}} 4031 {{#if canBePurchasedWithPoints}} 4032 @Render(new Button { Title = Translate("Use") + "{{pointPrice}}" + Translate("points"), ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.LinkClean, CssClass = "btn--loyalty-points btn--sm u-no-margin u-margin-top", OnClick = "Cart.BuyForPoints('" + GetGlobalValue("Global:Page.ID") + "', '" + cartFeedPageId + "', '{{orderLineId}}', '{{id}}', '{{variantId}}');", Icon = new Icon { Prefix = "far", Name = "fa-tag", LabelPosition = IconLabelPosition.After } }) 4033 {{/if}} 4034 </div> 4035 </td> 4036 </tr> 4037 {{/unless}} 4038 <tr class="{{hideBomItems}}"> 4039 <td colspan="6" class="u-no-padding"> 4040 <table class="u-no-margin u-color-light-gray--bg"> 4041 <tbody> 4042 {{#BomItems}} 4043 <tr> 4044 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 4045 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 4046 </td> 4047 <td title="{{name}} {{variantname}}"> 4048 <a href="{{link}}" title="{{name}} {{variantname}}">{{name}}</a> 4049 {{#if productnumber}} 4050 <div>#{{productnumber}}</div> 4051 {{/if}} 4052 {{#if variantname}} 4053 <div>{{variantname}}</div> 4054 {{/if}} 4055 {{#if unitname}} 4056 <div>{{unitname}}</div> 4057 {{/if}} 4058 </td> 4059 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 4060 <td>{{quantity}}</td> 4061 <td>&nbsp;</td> 4062 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 4063 </tr> 4064 {{/BomItems}} 4065 </tbody> 4066 </table> 4067 </td> 4068 </tr> 4069 </script> 4070 } 4071 4072 @helper RenderCartOrderlineDiscountTemplate() 4073 { 4074 <script id="CartOrderlineDiscount" type="text/x-template"> 4075 <tr class="table__row--no-border"> 4076 <td class="cart-table__image dw-mod">&nbsp;</td> 4077 <td colspan="3">{{name}}</td> 4078 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 4079 <td class="cart-table__price u-ta-right dw-mod">{{totalprice}}</td> 4080 </tr> 4081 </script> 4082 } 4083 4084 @helper RenderEmptyCartTemplate() 4085 { 4086 <script id="EmptyCart" type="text/x-template"> 4087 @Translate("You have no items in the cart") 4088 </script> 4089 } 4090 4091 @helper RenderInlineAcceptance() 4092 { 4093 <div class="grid__cell u-padding--xs"> 4094 @if (GetBoolean("Ecom:Cart.UseNewsletterSubscription")) 4095 { 4096 @Render(new HiddenField { Name = "EcomOrderSubscribeToNewsletter" }) 4097 @Render(new CheckboxField { Name = "EcomOrderSubscribeToNewsletter", Id = "EcomOrderSubscribeToNewsletter", Label = Translate("Subscribe to newsletter") }) 4098 } 4099 4100 @if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions")) 4101 { 4102 @Render(new HiddenField { Name = "EcomOrderCustomerAccepted", Id = "EcomOrderCustomerAccepted", Value = "1" }) 4103 } 4104 else 4105 { 4106 string termsPageIt = GetPageIdByNavigationTag("TermsAndConditions").ToString(); 4107 @Render(new CheckboxField 4108 { 4109 Name = "EcomOrderCustomerAccepted", 4110 Id = "EcomOrderCustomerAccepted", 4111 OnChange = canCompleteOrder ? "Cart.EnableCheckoutButton()" : "", 4112 Label = Translate("I accept the") + " <a href=\"/Default.aspx?ID=" + termsPageIt + "\">" + Translate("terms and conditions") + "</a>", 4113 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerAccepted.ErrorMessage") 4114 }) 4115 } 4116 </div> 4117 } 4118 4119 @helper RenderReviewOrderFooter() 4120 { 4121 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 4122 4123 <div class="grid"> 4124 <div class="grid__col-12 grid__col--line-top"></div> 4125 </div> 4126 4127 <div class="grid__cell-footer"> 4128 <div class="grid__cell u-padding--xs"> 4129 <div class="u-pull--right"> 4130 @Render(new Button 4131 { 4132 ButtonType = ButtonType.Submit, 4133 ButtonLayout = ButtonLayout.Primary, 4134 CssClass = "btn--condensed u-pull--right u-no-margin", 4135 Title = Translate("Go to checkout"), 4136 Id = GetString("CartV2.NextStepButtonName"), 4137 OnClick = "Buttons.LockButton(event, true)", 4138 Disabled = !canCompleteOrder || !Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions"), 4139 Name = GetString("CartV2.NextStepButtonName") 4140 }) 4141 </div> 4142 <div class="u-pull--left"> 4143 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", Title = Translate("Empty cart"), OnClick = "googleEnchantImpressionEmptyCart(); Cart.EmptyCart(event);" }) 4144 </div> 4145 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 4146 { 4147 <div class="u-pull--right"> 4148 @Render(new Link { Href = "/Default.aspx?ID=" + quotesCartPageId, ButtonLayout = ButtonLayout.Link, CssClass = "btn--condensed u-no-margin u-margin-right--lg u-no-margin--xs", Title = Translate("Create quote request") }) 4149 </div> 4150 } 4151 </div> 4152 </div> 4153 } 4154 4155 @helper RenderReviewOrderFooterQuote() 4156 { 4157 string submitButtonTitle = Pageview.Device.ToString() == "Mobile" ? Translate("Submit") : Translate("Submit quote request"); 4158 4159 <div class="grid"> 4160 <div class="grid__col-12 grid__col--line-top"></div> 4161 </div> 4162 4163 <div class="grid__cell-footer"> 4164 <div class="grid__cell u-padding--xs"> 4165 <div class="u-pull--right"> 4166 @Render(new Button 4167 { 4168 ButtonType = ButtonType.Submit, 4169 ButtonLayout = ButtonLayout.Primary, 4170 CssClass = "btn--condensed u-pull--right u-no-margin", 4171 Title = submitButtonTitle, 4172 Id = GetString("CartV2.NextStepButtonName"), 4173 OnClick = "Buttons.LockButton(event, true)", 4174 Name = GetString("CartV2.NextStepButtonName") 4175 }) 4176 </div> 4177 <div class="u-pull--left"> 4178 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", OnClick = "googleEnchantImpressionEmptyCart(); EmptyCartQuote(event);", Title = Translate("Empty cart") }) 4179 </div> 4180 </div> 4181 </div> 4182 4183 } 4184 <script> 4185 EmptyCartQuote = function (e) { 4186 e.preventDefault(); 4187 4188 var url = "/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed").ToString()"; 4189 Cart.UpdateCart('miniCart', url, "cartcmd=emptycart&OrderContext=RESTOCK&redirect=false", true); 4190 RememberState.SetCookie("useAnotherAddress", false); 4191 var event = new CustomEvent('emptyCart'); 4192 document.dispatchEvent(event); 4193 } 4194 </script> 4195 @helper RenderOrderScripts() 4196 { 4197 if (!string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID"))) 4198 { 4199 <script> 4200 fbq('track', 'InitiateCheckout', { 4201 currency: '@GetString("Ecom:Order.Price.Currency.Code")', 4202 value: @GetDouble("Ecom:Order.Price.Price"), 4203 num_items: "@GetInteger("Ecom:Order.OrderLines.TotalProductQuantity")" 4204 }); 4205 </script> 4206 } 4207 } 4208 4209 @helper RenderEmptyCartObserver() 4210 { 4211 <script> 4212 document.addEventListener("cartUpdated", function(event) { 4213 let data = event.detail.data[0]; 4214 if (data.numberofproducts == 0) { 4215 location.reload(); 4216 } else { 4217 HandlebarsBolt.CreateItemsFromJson(data, "Cart"); 4218 } 4219 }); 4220 </script> 4221 } 4222 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4223 @using Dynamicweb.Core 4224 @using System 4225 @using System.Web 4226 @using System.Collections.Generic 4227 @using Dynamicweb.Rapido.Blocks 4228 @using Dynamicweb.Ecommerce.Orders 4229 4230 @{ 4231 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 4232 4233 BlocksPage googleImpressionsPage = BlocksPage.GetBlockPage("CheckoutPage"); 4234 4235 Block googleImpressionsBlock = new Block() 4236 { 4237 Id = "GoogleImpressionsBlock", 4238 SortId = 10, 4239 Template = RenderScript() 4240 }; 4241 4242 if (useGoogleTagManager) 4243 { 4244 googleImpressionsPage.Add("CheckoutBottomSnippets", googleImpressionsBlock); 4245 } 4246 } 4247 4248 @helper RenderScript() 4249 { 4250 var currentStep = 1; 4251 4252 foreach (LoopItem step in GetLoop("StepButtons")) 4253 { 4254 if (step.GetBoolean("Step.Current")) 4255 { 4256 currentStep = step.GetInteger("Step.Number"); 4257 break; 4258 } 4259 } 4260 <script> 4261 dataLayer.push({ 4262 "event": "checkout", 4263 "ecommerce": { 4264 "currencyCode": "@Dynamicweb.Ecommerce.Services.Currencies.GetDefaultCurrency().Code", 4265 "checkout": { 4266 "actionField": {"step": @currentStep}, 4267 "products": [ 4268 @foreach (LoopItem orderline in GetLoop("OrderLines").Where(o => o.GetBoolean("Ecom:Order:OrderLine.IsProduct") == true).ToList()) 4269 { 4270 var groupObject = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(orderline.GetString("Ecom:Product.PrimaryOrFirstGroupID")); 4271 <text> 4272 { 4273 "name": "@orderline.GetString("Ecom:Order:OrderLine.ProductName")", 4274 "id": "@orderline.GetString("Ecom:Product.ID")", 4275 "price": "@orderline.GetDouble("Ecom:Order:OrderLine.UnitPrice.Price")", 4276 "brand": "@orderline.GetString("Ecom:Product:Field.brand.Value")", 4277 "category": "@(groupObject != null ? groupObject.Name : "")", 4278 "variant": "@orderline.GetString("Ecom:Order:OrderLine.ProductVariantID")", 4279 "quantity": @orderline.GetInteger("Ecom:Order:OrderLine.Quantity") 4280 }, 4281 </text> 4282 } 4283 ] 4284 } 4285 } 4286 }); 4287 </script> 4288 } 4289 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4290 @using Dynamicweb.Core 4291 @using System 4292 @using System.Web 4293 @using System.Collections.Generic 4294 @using Dynamicweb.Rapido.Blocks 4295 4296 @{ 4297 BlocksPage snippetsCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 4298 4299 snippetsCheckoutPage.Add("CheckoutBottomSnippets", new Block 4300 { 4301 Id = "CartAddressesJavascript", 4302 SortId = 50, 4303 Template = RenderCartAddressesJavascript() 4304 }); 4305 } 4306 4307 @helper RenderCartAddressesJavascript() 4308 { 4309 <script> 4310 function resetStateField(stateFieldId) { 4311 let stateField = document.getElementById(stateFieldId); 4312 if (stateField) { 4313 stateField.value = ""; 4314 let disabledOption = stateField.querySelector("option:checked"); 4315 if (disabledOption) { 4316 disabledOption.disabled = false; 4317 disabledOption.removeAttribute("disabled"); 4318 } 4319 } 4320 } 4321 4322 document.addEventListener("DOMContentLoaded", function () { 4323 regionLabels.InitDictionary({ 4324 "CA": "@Translate("Province")", 4325 "US": "@Translate("State")" 4326 }); 4327 regionLabels.LocalizeRegionLabels("EcomOrderCustomerRegion", "EcomOrderCustomerCountry"); 4328 regionLabels.LocalizeRegionLabels("EcomOrderDeliveryRegion", "EcomOrderDeliveryCountry"); 4329 }); 4330 </script> 4331 } 4332 4333 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4334 @using Dynamicweb.Core 4335 @using System 4336 @using System.Web 4337 @using System.Collections.Generic 4338 @using Dynamicweb.Rapido.Blocks 4339 4340 @{ 4341 var DistributorOrderRouter = GetString("DistributorOrderRouter"); 4342 } 4343 4344 @{ 4345 BlocksPage customBlocksPage = BlocksPage.GetBlockPage("CheckoutPage"); 4346 Block CustomOrderline = new Block() 4347 { 4348 Id = "CartOrderlineTemplate", 4349 SortId = 20, 4350 Template = RenderCartOrderlineTemplateCustom() 4351 }; 4352 customBlocksPage.ReplaceBlock(CustomOrderline); 4353 4354 var ShippingAddressBody = customBlocksPage.GetBlockById("ShippingAddressBody"); 4355 if (ShippingAddressBody != null) 4356 { 4357 if (checkoutPageType != "multistep") 4358 { 4359 4360 Block CommentCustom = new Block() 4361 { 4362 Id = "CommentTemplate", 4363 SortId = 50, 4364 Template = RenderCartComment() 4365 }; 4366 4367 4368 customBlocksPage.Add("ShippingAddressBody", CommentCustom); 4369 } 4370 if (checkoutPageType == "multistep") 4371 { 4372 if (GetString("CartV2.CurrentStepButtonName") == "CartV2.GotoStep1") 4373 { 4374 Block CommentCustom = new Block() 4375 { 4376 Id = "CommentTemplate", 4377 SortId = 50, 4378 Template = RenderCartComment() 4379 }; 4380 customBlocksPage.Add("ShippingAddressBody", CommentCustom); 4381 } 4382 4383 } 4384 4385 } 4386 4387 4388 Block CustomContent = new Block() 4389 { 4390 Id = "CartContentTemplate", 4391 SortId = 20, 4392 Template = RenderCartContentTemplateCustom() 4393 }; 4394 customBlocksPage.ReplaceBlock(CustomContent); 4395 4396 4397 4398 4399 Block CustomDiscount = new Block() 4400 { 4401 Id = "CartOrderlineDiscountTemplate", 4402 SortId = 20, 4403 Template = RenderCartOrderlineDiscountTemplateCustom() 4404 }; 4405 customBlocksPage.ReplaceBlock(CustomDiscount); 4406 4407 Block acceptanceBlockCustom = new Block() 4408 { 4409 Id = "Acceptance", 4410 SortId = 10, 4411 Design = new Design 4412 { 4413 RenderType = RenderType.Column, 4414 Size = "12" 4415 }, 4416 BlocksList = new List<Block> 4417 { 4418 new Block { 4419 Id = "AcceptanceBody", 4420 SortId = 10, 4421 Template = RenderAcceptanceCustom() 4422 } 4423 } 4424 }; 4425 customBlocksPage.ReplaceBlock(acceptanceBlockCustom); 4426 4427 Block reviewOrderFooterBlockCustom = new Block() 4428 { 4429 Id = "ReviewOrderFooter", 4430 SortId = 20, 4431 Template = RenderReviewOrderFooterCustom() 4432 }; 4433 customBlocksPage.ReplaceBlock(reviewOrderFooterBlockCustom); 4434 if (checkoutPageType == "quote") 4435 { 4436 Block reviewOrderFooterBlockCustomQuote = new Block() 4437 { 4438 Id = "ReviewOrderFooter", 4439 SortId = 20, 4440 Template = RenderReviewOrderFooterQuoteCustom() 4441 }; 4442 customBlocksPage.ReplaceBlock(reviewOrderFooterBlockCustomQuote); 4443 } 4444 4445 4446 } 4447 4448 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4449 @using Dynamicweb 4450 @using Dynamicweb.Core 4451 @using System.Collections; 4452 @using System 4453 @using System.Web 4454 @using System.Linq; 4455 @using System.Collections.Generic 4456 @using Dynamicweb.Rapido.Blocks 4457 @using Dynamicweb.Rapido.Blocks.Components 4458 @using Dynamicweb.Rapido.Blocks.Components.General 4459 4460 @helper RenderCartOrderlineTemplateCustom() 4461 { 4462 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 4463 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 4464 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 4465 string pageUrlN = GetPageIdByNavigationTag("GetUserInfo").ToString(); 4466 string feedFullUrlN = "Default.aspx?ID=" + pageUrlN; 4467 var userCode = GetString("UserManagement:User.Item.Code"); 4468 var errorLoopCount = GetLoop("ValidationErrors").Where(x => x.GetString("Ecom:Cart.ValidationError.FieldName") == "OrderlineError").Count(); 4469 DateTime userExpireDate = GetDate("UserManagement:User.Item.CodeExpire"); 4470 var exDate = userExpireDate.ToString("yyyy-MM-dd"); 4471 var date = GetGlobalValue("Global:Server.Date.GeneralDate"); 4472 DateTime dt = Convert.ToDateTime(date); 4473 var currentday = dt.ToString("yyyy-MM-dd"); 4474 var currentUser = GetInteger("UserManagement:User.ID").ToString(); 4475 string cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 4476 if (!string.IsNullOrWhiteSpace(GetString("Ecom:OrderContext.ID"))) 4477 { 4478 cartFeedPageIdCustom += "&OrderContext=" + GetString("Ecom:OrderContext.ID"); 4479 } 4480 4481 @* Template for the orderlines *@ 4482 4483 <script id="CartOrderline" type="text/x-template"> 4484 4485 {{#unless isEmpty}} 4486 <tr id="Orderline{{id}}" class="cart-orderline"> 4487 <td class="cart-orderline__cell cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 4488 <div class="cart-orderline__cell__block {{hideimage}} dw-mod"> 4489 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 4490 </div> 4491 </td> 4492 <td class="cart-orderline__cell u-va-middle dw-mod" title="{{name}} {{variantname}}"> 4493 <a href="{{link}}" class="u-color-inherit cart-orderline__name">{{name}}</a> 4494 {{#if productnumber}} 4495 <div class="cart-orderline__cell__block item-number dw-mod">#{{productnumber}}</div> 4496 {{/if}} 4497 {{#if variantname}} 4498 <div class="cart-orderline__cell__block item-number dw-mod">{{variantname}}</div> 4499 {{/if}} 4500 {{#if unitname}} 4501 <div class="cart-orderline__cell__block item-number dw-mod">{{unitname}}</div> 4502 {{/if}} 4503 {{#if trainingInfo}} 4504 <div class="cart-orderline__cell__block item-number dw-mod">{{trainingInfo}} @Translate("hr")</div> 4505 {{/if}} 4506 4507 </td> 4508 <td class="cart-orderline__cell u-ta-right u-hidden-xs u-hidden-xxs dw-mod" width="120"> 4509 {{#if pointsTotal}} 4510 <span class="u-color--loyalty-points">{{pointPrice}}</span> @Translate("points") 4511 {{else}} 4512 {{unitprice}} 4513 {{/if}} 4514 </td> 4515 4516 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 4517 { 4518 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 4519 @Render(new NumberField 4520 { 4521 Id = "Quantity_{{orderLineId}}", 4522 Min = 1, 4523 OnChange = "Cart.ChangeQuantity('" + cartFeedPageIdCustom + "', '{{orderLineId}}', this.value)", 4524 Name = "QuantityOrderLine{{orderLineId}}", 4525 Value = "{{quantity}}", 4526 CssClass = "u-w80px", 4527 ActionButton = new Button 4528 { 4529 ButtonType = ButtonType.Button, 4530 ButtonLayout = ButtonLayout.Clean, 4531 OnClick = "{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}} Cart.UpdateCart(null, '/Default.aspx?ID=" + cartFeedPageIdCustom + "', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);", 4532 Icon = new Icon { Prefix = "fas", Name = "fa-times", LabelPosition = IconLabelPosition.After } 4533 } 4534 }) 4535 </td> 4536 } 4537 else 4538 { 4539 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 4540 @Render(new HiddenField { Id = "Quantity_{{orderLineId}}", Name = "QuantityOrderLine{{orderLineId}}", Value = "{{quantity}}" }) 4541 <div class="u-w80px u-no-margin">{{quantity}}</div> 4542 </td> 4543 } 4544 4545 <td class="cart-orderline__cell u-ta-right dw-mod"> 4546 {{#if pointsTotal}} 4547 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 4548 {{else}} 4549 <div>{{totalprice}}</div> 4550 {{/if}} 4551 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 4552 { 4553 <text> 4554 {{#if canBePurchasedWithPoints}} 4555 @Render(new Button { Title = Translate("Use") + " {{pointPrice}} " + Translate("points"), ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.None, CssClass = "btn btn--loyalty-points btn--sm u-no-margin", OnClick = "Cart.BuyForPoints('" + GetGlobalValue("Global:Page.ID") + "', '" + cartFeedPageIdCustom + "', '{{orderLineId}}', '{{id}}', '{{variantId}}');", Icon = new Icon { Prefix = "far", Name = "fa-tag", LabelPosition = IconLabelPosition.After } }) 4556 {{/if}} 4557 </text> 4558 } 4559 </td> 4560 </tr> 4561 {{/unless}} 4562 <tr class="{{hideBomItems}}"> 4563 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"><div class="{{hideimage}}"></div></td> 4564 <td colspan="5" class="u-no-padding"> 4565 <table class="u-no-margin u-color-light-gray--bg"> 4566 <tbody> 4567 {{#BomItems}} 4568 <tr> 4569 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 4570 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 4571 </td> 4572 <td title="{{name}} {{variantname}}"> 4573 <a href="{{link}}" class="u-color-inherit dw-mod">{{name}}</a> 4574 {{#if productnumber}} 4575 <div class="item-number dw-mod">#{{productnumber}}</div> 4576 {{/if}} 4577 {{#if variantname}} 4578 <div class="item-number dw-mod">{{variantname}}</div> 4579 {{/if}} 4580 {{#if unitname}} 4581 <div class="item-number dw-mod">{{unitname}}</div> 4582 {{/if}} 4583 </td> 4584 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 4585 <td>{{quantity}}</td> 4586 <td>&nbsp;</td> 4587 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 4588 </tr> 4589 {{/BomItems}} 4590 </tbody> 4591 </table> 4592 </td> 4593 </tr> 4594 </script> 4595 4596 } 4597 @helper RenderCartContentTemplateCustom() 4598 { 4599 BlocksPage customBlocksPageOrder = BlocksPage.GetBlockPage("CheckoutPage"); 4600 List<Block> subBlocksCustom = customBlocksPageOrder.GetBlockListById("ReviewOrder").OrderBy(item => item.SortId).ToList(); 4601 4602 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 4603 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 4604 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(GetString("Ecom:Order.ID")); 4605 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 4606 int cartFeedPageIdCustom; 4607 cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed"); 4608 4609 <script id="CartContent" type="text/x-template"> 4610 4611 {{#.}} 4612 @if (useGoogleTagManager) 4613 { 4614 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text> 4615 } 4616 4617 <div class="card-header u-color-light--bg dw-mod"> 4618 @Render(new Heading { Title = Translate("Review order") + "({{numberofproducts}})", Level = 3, Icon = new Icon { Prefix = "fas", Name = "fa-list-ul", LabelPosition = IconLabelPosition.After } }) 4619 </div> 4620 4621 <div class="card u-color-light--bg u-no-padding--xs dw-mod"> 4622 4623 {{#unless orderIsAuthenticatedClean}} 4624 <input type="text" id="OrderIsAuthenticated" name="OrderIsAuthenticated" value="no" style="display:none"> 4625 <input type="checkbox" id="isAuthenticated" name="OrderIsAuthenticated" style="display:none"> 4626 {{else}} 4627 <input type="text" id="OrderIsAuthenticated" name="OrderIsAuthenticated" value="yes" style="display:none"> 4628 <input type="checkbox" id="isAuthenticated" checked="checked" name="OrderIsAuthenticated" style="display:none"> 4629 {{/unless}} 4630 {{#unless isEmpty}} 4631 {{#unless notRequireAuthorization}} 4632 {{#unless orderIsAuthenticatedClean}} 4633 <div class="grid "> 4634 <div class="grid__col-xs-12 grid__col-sm-6 autorization-code"> 4635 <div class="alert-box u-color-danger txt-small u-margin-bottom">{{orderIsAuthenticatedError}}</div> 4636 <input id="{{AuthorizationCodeName}}" name="{{AuthorizationCodeName}}" class="u-full-width dw-mod" value="{{AuthorizationCode}}" placeholder=" @Translate("Enter your code")"/> 4637 </div> 4638 </div> 4639 {{/unless}} 4640 {{/unless}} 4641 <table class="table cart-table dw-mod"> 4642 <tbody id="OrderLines"> 4643 {{#OrderLines}} 4644 {{> (lookup . 'template') }} 4645 {{/OrderLines}} 4646 </tbody> 4647 </table> 4648 {{/unless}} 4649 <div class="grid u-border-top"> 4650 <div class="grid__col-sm-6"> 4651 @if (Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 4652 { 4653 <text> 4654 {{#if userPoints}} 4655 <div class="u-border u-border-color--loyalty-points u-padding--lg u-full-height"> 4656 @Render(new Heading { Title = Translate("Your point balance"), Level = 3 }) 4657 <div class="u-font-size--lg u-margin-bottom"> 4658 <span class="u-color--loyalty-points">{{userPoints}}</span> @Translate("points") 4659 </div> 4660 <div>@Translate("On this order you will use"): <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")</div> 4661 </div> 4662 {{/if}} 4663 </text> 4664 } 4665 </div> 4666 4667 <div class="grid__col-sm-6"> 4668 @if (GetLoop("DWExtranetSecondaryUsers").Count > 0 || !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.SecondaryUser.UserID"))) 4669 { 4670 <div class="grid"> 4671 <div class="grid__col-xs-12 alert-box u-color-danger txt-small u-hidden" id="error-discount">@Translate("Allowing only decimals numbers")</div> 4672 <input type="text" onchange="isDecimalsThis(this)" onkeyup="isDecimalsThis(this);" id="OrderDiscountPercentage" name="OrderDiscountPercentage" class="orderDiscount u-no-margin u-margin-top grid__col-lg-3 grid__col-md-3 grid__col-sm-3 grid__col-xs-5" value="" /> 4673 <select id="discountSelect" name="discountSelect" class="u-no-margin grid__col-lg-5 u-margin-top grid__col-md-5 grid__col-sm-5 grid__col-xs-6-auto u-no-padding " onchange="changeDiscount(this)"> 4674 <option value="OrderDiscountPercentage">@Translate("Percentage")</option> 4675 <option value="OrderDiscount">@Translate("Fixed Price")</option> 4676 <select> 4677 <button id="discountBtn" onclick="HandlebarsBolt.UpdateContent('Cart', '/Default.aspx?ID=@cartFeedPageIdCustom&CartCmd=setdiscount&OrderDiscountPercentage='+ document.getElementById('OrderDiscountPercentage').value);return false;" class="u-margin-top grid__col-lg-3 grid__col-md-3 grid__col-sm-3 grid__col-xs-12-auto btn--condensed u-no-margin btn btn--primary dw-mod u-pull--right disabled" id="addDiscount">@Translate("Add discount")</button> 4678 </div> 4679 4680 } 4681 4682 @if (!pointShop) 4683 { 4684 <text> 4685 {{#unless hideSubTotal}} 4686 <div> 4687 <div class="cart-summary__subtotals dw-mod">@Translate("Subtotal")</div> 4688 <div class="cart-summary__subtotals u-pull--right dw-mod"> 4689 @if (hasTaxSettings) 4690 { 4691 <text>{{subtotalpricewithouttaxes}}</text> 4692 } 4693 else 4694 { 4695 <text>{{subtotalprice}}</text> 4696 } 4697 </div> 4698 </div> 4699 {{/unless}} 4700 </text> 4701 <text> 4702 {{#unless hidePaymentfee}} 4703 <div> 4704 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-credit-card", Label = "{{paymentmethod}}", LabelPosition = IconLabelPosition.After })</div> 4705 <div class="cart-summary__info u-pull--right dw-mod">{{paymentfee}}</div> 4706 </div> 4707 {{/unless}} 4708 </text> 4709 } 4710 {{#unless hideShippingfee}} 4711 <div> 4712 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-truck", Label = "{{shippingmethod}}", LabelPosition = IconLabelPosition.After })</div> 4713 <div class="cart-summary__info u-pull--right dw-mod">{{shippingfee}}</div> 4714 </div> 4715 {{#unless notTxtForShippingFree}} 4716 <div> 4717 <div class="cart-summary__info dw-mod"><span class="txt-small">@Translate("Free shipping - Buy for additional") {{aditionalPriceForFreeShipping}}</span> </div> 4718 <div class="cart-summary__info u-pull--right dw-mod"></div> 4719 </div> 4720 {{/unless}} 4721 {{/unless}} 4722 {{#if hasTaxSettings}} 4723 <div> 4724 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-hand-holding-usd", Label = Translate("Sales Tax"), LabelPosition = IconLabelPosition.After })</div> 4725 <div class="cart-summary__info u-pull--right dw-mod">{{totaltaxes}}</div> 4726 </div> 4727 {{/if}} 4728 @if (Pageview.User != null && Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints")) 4729 { 4730 <text> 4731 {{#if earnings}} 4732 <div> 4733 <div class="cart-summary__info dw-mod">@Translate("Earnings")</div> 4734 <div class="cart-summary__info u-pull--right dw-mod"><span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")</div> 4735 </div> 4736 {{/if}} 4737 </text> 4738 } 4739 <div class="cart-summary__totals-container dw-mod"> 4740 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 4741 <div class="cart-summary__totals u-pull--right dw-mod"> 4742 @if (pointShop) 4743 { 4744 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points") 4745 } 4746 else 4747 { 4748 <text>{{totalprice}}</text> 4749 } 4750 </div> 4751 </div> 4752 @if (!pointShop && !hasTaxSettings) 4753 { 4754 <div class="u-ta-right"> 4755 <small class="cart-summary__info dw-mod">@Translate("VAT"):</small> 4756 <small class="cart-summary__info dw-mod">{{totalvat}}</small> 4757 </div> 4758 4759 if (isPricesWithVATEnabled) 4760 { 4761 <div class="u-ta-right"> 4762 <small class="cart-summary__info dw-mod">@Translate("Total price without VAT"):</small> 4763 <small class="cart-summary__info dw-mod">{{totalPriceWithoutVat}}</small> 4764 </div> 4765 } 4766 else 4767 { 4768 <div class="u-ta-right"> 4769 <small class="cart-summary__info dw-mod">@Translate("Total price with VAT"):</small> 4770 <small class="cart-summary__info dw-mod">{{totalPriceWithVat}}</small> 4771 </div> 4772 } 4773 } 4774 {{#if showCheckoutDisclaimer}} 4775 <div class="u-ta-right"> 4776 <small>{{checkoutDisclaimer}}</small> 4777 </div> 4778 {{/if}} 4779 </div> 4780 </div> 4781 4782 <div class="u-margin-bottom--lg"> 4783 <div id="errorCode"> 4784 4785 </div> 4786 @foreach (LoopItem error in GetLoop("ValidationErrors")) 4787 { 4788 @Render(new NotificationMessage { Message = error.GetString("Ecom:Cart.ValidationError.ErrorMessage"), MessageType = NotificationMessageType.Error }) 4789 } 4790 </div> 4791 </div> 4792 {{/.}} 4793 </script> 4794 4795 } 4796 @helper RenderCartOrderlineDiscountTemplateCustom() 4797 { 4798 <script id="CartOrderlineDiscount" type="text/x-template"> 4799 <tr class="table__row--no-border discount-row"> 4800 <td class="cart-table__image dw-mod"> 4801 {{#unless notDiscountImage}} 4802 <img src="{{{image}}}"> 4803 {{/unless}} 4804 </td> 4805 <td colspan="3">{{name}}</td> 4806 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 4807 <td class="cart-table__price u-ta-right dw-mod">{{totalprice}}</td> 4808 </tr> 4809 </script> 4810 } 4811 @helper RenderCartComment() 4812 { 4813 var cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed"); 4814 <div class="grid__col-12"> 4815 <div class="js-handlebars-root" id="CartComment" data-template="CartCommentCustom" data-json-feed="/Default.aspx?ID=@cartFeedPageIdCustom"></div> 4816 </div> 4817 4818 <script id="CartCommentCustom" type="text/x-template"> 4819 {{#.}} 4820 <div class=""> 4821 <div class="grid"> 4822 <div class="grid__col-12 grid__col--line-top"></div> 4823 </div> 4824 {{#unless hideComment}} 4825 <div class="grid__cell u-padding--xs"> 4826 @Render(new TextareaField { Rows = 3, Placeholder = Translate("Enter comment"), Name = "EcomOrderCustomerComment", Id = "EcomOrderCustomerComment", Value = "{{comment}}" }) 4827 </div> 4828 {{/unless}} 4829 </div> 4830 {{/.}} 4831 </script> 4832 } 4833 @helper RenderReviewOrderFooterCustom() 4834 { 4835 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 4836 var emptyOrContinueBtn = Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage") != null ? Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage").SelectedValue : "empty"; 4837 string reviewOrderType = checkoutPageType ?? "onestep"; //The "checkoutPageType" comes from the main template for the cart page 4838 int cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed"); 4839 var paymentCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 4840 var shippingCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 4841 var paymentCountryIsSupported = string.IsNullOrEmpty(paymentCountryCode) || GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == paymentCountryCode)); 4842 var shippingCountryIsSupported = string.IsNullOrEmpty(shippingCountryCode) ? paymentCountryIsSupported : GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == shippingCountryCode)); 4843 4844 bool canCompleteOrderCustom = paymentCountryIsSupported && shippingCountryIsSupported; 4845 <div class="grid"> 4846 <div class="grid__col-12 grid__col--line-top"></div> 4847 </div> 4848 4849 <div class="grid__cell-footer"> 4850 <div class="grid__cell u-padding--xs"> 4851 <div class="u-pull--right"> 4852 @Render(new Button 4853 { 4854 ButtonType = ButtonType.Submit, 4855 ButtonLayout = ButtonLayout.Primary, 4856 CssClass = "btn--condensed u-pull--right u-no-margin", 4857 Title = Translate("Go to checkout"), 4858 Id = GetString("CartV2.NextStepButtonName"), 4859 OnClick = "Buttons.LockButton(event, true)", 4860 Disabled = !canCompleteOrderCustom || !Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions"), 4861 Name = GetString("CartV2.NextStepButtonName") 4862 }) 4863 </div> 4864 <div class="u-pull--left"> 4865 @if (emptyOrContinueBtn == "empty") 4866 { 4867 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", Title = Translate("Empty cart"), OnClick = "googleEnchantImpressionEmptyCart(); Cart.EmptyCart(event);" }) 4868 4869 } 4870 else 4871 { 4872 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", Title = Translate("Continue shopping"), OnClick = "GoToProductPage();" }) 4873 4874 } 4875 </div> 4876 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 4877 { 4878 <div class="u-pull--right"> 4879 @Render(new Link { Href = "/Default.aspx?ID=" + quotesCartPageId, ButtonLayout = ButtonLayout.Link, CssClass = "btn--condensed u-no-margin u-margin-right--lg u-no-margin--xs", Title = Translate("Create quote request") }) 4880 </div> 4881 } 4882 </div> 4883 </div> 4884 4885 4886 4887 } 4888 4889 @helper RenderReviewOrderFooterQuoteCustom() 4890 { 4891 string submitButtonTitle = Pageview.Device.ToString() == "Mobile" ? Translate("Submit") : Translate("Submit quote request"); 4892 4893 <div class="grid"> 4894 <div class="grid__col-12 grid__col--line-top"></div> 4895 </div> 4896 4897 <div class="grid__cell-footer"> 4898 <div class="grid__cell u-padding--xs"> 4899 <div class="u-pull--right"> 4900 @Render(new Button 4901 { 4902 ButtonType = ButtonType.Submit, 4903 ButtonLayout = ButtonLayout.Primary, 4904 CssClass = "btn--condensed u-pull--right u-no-margin", 4905 Title = submitButtonTitle, 4906 Id = GetString("CartV2.NextStepButtonName"), 4907 OnClick = "Buttons.LockButton(event, true)", 4908 Name = GetString("CartV2.NextStepButtonName") 4909 }) 4910 </div> 4911 <div class="u-pull--left"> 4912 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", OnClick = "googleEnchantImpressionEmptyCart(); Cart.EmptyCart(event);", Title = Translate("Empty cart") }) 4913 </div> 4914 </div> 4915 </div> 4916 } 4917 <script type="text/javascript"> 4918 function getCook(cookiename) { 4919 // Get name followed by anything except a semicolon 4920 var cookiestring = RegExp(cookiename + "=[^;]+").exec(document.cookie); 4921 // Return everything after the equal sign, or an empty string if the cookie name not found 4922 return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, "") : ""); 4923 } 4924 function GoToProductPage() { 4925 var cookieValue = getCook('ProductLink'); 4926 if (document.cookie.indexOf("ProductLink=") >= 0) { 4927 location.href = cookieValue; 4928 4929 } 4930 else{ 4931 location.href = "/Default.aspx?ID=@GetPageIdByNavigationTag("ProductsPage")"; 4932 } 4933 4934 } 4935 </script> 4936 <script type="text/javascript"> 4937 isDecimalsThis=function(input){ 4938 let str = input.value 4939 const regExp = /^\d*(\.)?(\d{0,2})?$/ 4940 status = regExp.test(str) ? 'valid' : 'invalid' 4941 if (status === "valid") { 4942 document.getElementById("discountBtn").classList.remove("disabled") 4943 document.getElementById("error-discount").classList.add("u-hidden"); 4944 } 4945 else { 4946 document.getElementById("discountBtn").classList.add("disabled"); 4947 document.getElementById("error-discount").classList.remove("u-hidden"); 4948 } 4949 4950 console.log(status + ' : ' + input.value) 4951 4952 } 4953 changeDiscount = function (l) { 4954 let discoutnBtn = document.getElementById("discountBtn"); 4955 let selectElement = l.value; 4956 let inputElement = document.getElementsByClassName("orderDiscount")[0]; 4957 inputElement.setAttribute("id", selectElement); 4958 inputElement.setAttribute("name", selectElement); 4959 discoutnBtn.setAttribute("onclick", "HandlebarsBolt.UpdateContent('Cart', '/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")&CartCmd=setdiscount&" + selectElement + "='+ document.getElementById('" + selectElement+"').value);return false;") 4960 4961 } 4962 var getJSON = function (url, callback) { 4963 var xhr = new XMLHttpRequest(); 4964 xhr.open('GET', url, true); 4965 xhr.responseType = 'json'; 4966 xhr.onload = function () { 4967 var status = xhr.status; 4968 if (status === 200) { 4969 callback(null, xhr.response); 4970 } else { 4971 callback(status, xhr.response); 4972 } 4973 }; 4974 xhr.send(); 4975 }; 4976 4977 ValidationCode = function (l, e, id) { 4978 l.preventDefault() 4979 var selectForm = document.getElementById("OrderSubmit"); // Select the form by ID. 4980 4981 let elementname = e; 4982 let elementvalue = id; 4983 clearTimeout(updateDelay); 4984 4985 updateDelay = setTimeout(function () { 4986 const XHR = new XMLHttpRequest(), 4987 FD = new FormData(); 4988 FD.append(elementname, elementvalue); 4989 XHR.addEventListener('load', function (event) { 4990 //Success 4991 }); 4992 // Define what happens in case of error 4993 XHR.addEventListener(' error', function (event) { 4994 //Error 4995 }); 4996 XHR.open('POST', 'Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")'); 4997 XHR.send(FD); 4998 4999 getJSON('/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")', 5000 function (err, data) { 5001 if (err !== null) { 5002 console.log('Something went wrong: ' + err); 5003 } else { 5004 5005 if (data[0].orderIsAuthenticatedClean === false) { 5006 HandlebarsBolt.UpdateContent('Cart', 5007 '/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")' + '&redirect=false', 5008 '/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")' + '&redirect=false', 5009 'CartContent', 'minimal'); 5010 } 5011 else { 5012 document.getElementById('OrderSubmit').dispatchEvent(new Event('submit')); 5013 document.getElementById('OrderSubmit').submit(); 5014 } 5015 } 5016 }) 5017 5018 5019 }, 100); 5020 5021 }; 5022 5023 5024 </script> 5025 5026 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5027 @using Dynamicweb 5028 @using Dynamicweb.Core 5029 @using System.Collections; 5030 @using System 5031 @using System.Web 5032 @using System.Linq; 5033 @using System.Collections.Generic 5034 @using Dynamicweb.Rapido.Blocks 5035 @using Dynamicweb.Rapido.Blocks.Components 5036 @using Dynamicweb.Rapido.Blocks.Components.General 5037 5038 5039 @helper RenderAcceptanceCustom() 5040 { 5041 if (GetBoolean("Ecom:Cart.UseNewsletterSubscription")) 5042 { 5043 @Render(new HiddenField { Name = "EcomOrderSubscribeToNewsletter" }) 5044 @Render(new CheckboxField { Name = "EcomOrderSubscribeToNewsletter", Id = "EcomOrderSubscribeToNewsletter", Label = Translate("Subscribe to newsletter") }) 5045 } 5046 5047 if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions")) 5048 { 5049 @Render(new HiddenField { Name = "EcomOrderCustomerAccepted", Id = "EcomOrderCustomerAccepted", Value = "1" }) 5050 } 5051 else 5052 { 5053 string termsPageIt = GetPageIdByNavigationTag("TermsAndConditions").ToString(); 5054 @Render(new CheckboxField { Name = "EcomOrderCustomerAccepted", Id = "EcomOrderCustomerAccepted", OnChange = "EnableCheckoutButton()", Label = Translate("I accept") + " <a href=\"/Default.aspx?ID=" + termsPageIt + "\">" + Translate("the terms and conditions") + "</a>", ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerAccepted.ErrorMessage") }) 5055 } 5056 <script type="text/javascript"> 5057 function EnableCheckoutButton() { 5058 var stepButtonId = document.getElementById("CartV2.GotoStep3") ? "CartV2.GotoStep3" : "CartV2.GotoStep1"; 5059 var stepButton = document.getElementById(stepButtonId); 5060 let isValid = true; 5061 5062 if (isValid) { 5063 if (document.getElementById("EcomOrderCustomerAccepted").checked) { 5064 5065 var elements = document.getElementsByClassName('error-input'); 5066 var i; 5067 for (i = 0; i < elements.length; i++) { 5068 var error = elements[i].dataset.error; 5069 var value = elements[i].value; 5070 if (value != "ok" || value == "") { 5071 isValid = false; 5072 console.log(elements[i].dataset.error) 5073 document.getElementById("errorCode").innerHTML += "<div class='field-error u-full-width dw-mod'>" + error + "</div>"; 5074 document.getElementById("EcomOrderCustomerAccepted").checked = true 5075 5076 } 5077 5078 5079 } 5080 5081 5082 if (isValid) { 5083 stepButton.disabled = false; 5084 stepButton.classList.remove('disabled'); 5085 } 5086 5087 } 5088 else { 5089 if (document.getElementById("errorCode")) { 5090 document.getElementById("errorCode").innerHTML = ""; 5091 } 5092 5093 stepButton.disabled = true; 5094 stepButton.classList.add('disabled'); 5095 } 5096 } 5097 5098 5099 5100 } 5101 5102 </script> 5103 } 5104 @if (checkoutPageType == "multistep") 5105 { 5106 5107 <text>@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5108 @using Dynamicweb.Core 5109 @using System 5110 @using System.Web 5111 @using System.Collections.Generic 5112 @using Dynamicweb.Rapido.Blocks 5113 5114 @{ 5115 BlocksPage stepNavigationCheckoutPageCustom = BlocksPage.GetBlockPage("CheckoutPage"); 5116 5117 Block checkoutStepNavigationCustom = new Block() 5118 { 5119 Id = "StepNavigation", 5120 SortId = 50, 5121 Template = RenderStepNavigationCustom(), 5122 Design = new Design 5123 { 5124 RenderType = RenderType.Column, 5125 Size = "12" 5126 } 5127 5128 }; 5129 stepNavigationCheckoutPageCustom.ReplaceBlock(checkoutStepNavigationCustom); 5130 } 5131 5132 @helper RenderStepNavigationCustom() 5133 { 5134 var paymentCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 5135 var shippingCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 5136 var paymentCountryIsSupported = string.IsNullOrEmpty(paymentCountryCode) || GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == paymentCountryCode)); 5137 var shippingCountryIsSupported = string.IsNullOrEmpty(shippingCountryCode) ? paymentCountryIsSupported : GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == shippingCountryCode)); 5138 var emptyOrContinueBtn = Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage") != null ? Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage").SelectedValue : "empty"; 5139 5140 var canCompleteOrder = paymentCountryIsSupported && shippingCountryIsSupported; 5141 5142 5143 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 5144 int currentStep = 1; 5145 string disableNextButton = ""; 5146 string nextButtonName = Translate("Next"); 5147 5148 foreach (LoopItem step in GetLoop("StepButtons")) 5149 { 5150 if (step.GetBoolean("Step.Current")) 5151 { 5152 currentStep = step.GetInteger("Step.Number"); 5153 } 5154 5155 if (step.GetInteger("Step.Number") == currentStep + 1) 5156 { 5157 if (Pageview.Device.ToString() != "Mobile") 5158 { 5159 nextButtonName = Translate("Go to") + " " + step.GetString("Step.Name"); 5160 } 5161 else 5162 { 5163 nextButtonName = step.GetString("Step.Name"); 5164 } 5165 } 5166 } 5167 5168 if (currentStep == GetLoop("StepButtons").Count - 1) 5169 { 5170 disableNextButton = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions") ? "" : "disabled"; //not disable button if terms are hidden 5171 nextButtonName = Translate("Confirm order"); 5172 } 5173 5174 if (currentStep > 1 && !canCompleteOrder) 5175 { 5176 disableNextButton = "disabled"; 5177 } 5178 bool RequireAuthorization = GetLoop("OrderLines").Any(x => x.GetBoolean("Ecom:Product:Field.RequireAuthorization")); 5179 <div class="card u-color-light--bg dw-mod"> 5180 @if (currentStep == 1) 5181 { 5182 <div class="u-pull--left"> 5183 @if (emptyOrContinueBtn == "empty") 5184 { 5185 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", Title = Translate("Empty cart"), OnClick = "googleEnchantImpressionEmptyCart(); Cart.EmptyCart(event);" }) 5186 5187 } 5188 else 5189 { 5190 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", Title = Translate("Continue shopping"), OnClick = "GoToProductPage();" }) 5191 5192 } 5193 </div> 5194 5195 } 5196 else 5197 { 5198 <div class="u-pull--left"> 5199 5200 <button type="submit" class="btn btn--secondary btn--condensed dw-mod u-pull--right u-no-margin" name="@GetString("CartV2.PreviousStepButtonName")" id="@GetString("CartV2.PreviousStepButtonName")"><i class="fas fa-angle-left"></i> @Translate("Back")</button> 5201 </div> 5202 } 5203 5204 <div class="u-pull--right"> 5205 @if (RequireAuthorization) 5206 { 5207 <button type="submit" class="btn btn--primary btn--condensed dw-mod u-pull--right u-no-margin @disableNextButton" name="@GetString("CartV2.NextStepButtonName")" id="@GetString("CartV2.NextStepButtonName")" @disableNextButton onclick="ValidationCode(event,'AuthorizationCode', document.getElementById('AuthorizationCode').value)">@nextButtonName <i class="fas fa-angle-right"></i></button> 5208 } 5209 else 5210 { 5211 <button type="submit" class="btn btn--primary btn--condensed dw-mod u-pull--right u-no-margin @disableNextButton" name="@GetString("CartV2.NextStepButtonName")" id="@GetString("CartV2.NextStepButtonName")" @disableNextButton >@nextButtonName <i class="fas fa-angle-right"></i></button> 5212 5213 } 5214 </div> 5215 5216 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 5217 { 5218 <div class="u-pull--right"> 5219 <a href="/Default.aspx?ID=@quotesCartPageId" class="btn btn--condensed btn--link dw-mod u-no-margin u-margin-right--lg u-no-margin--xs">@Translate("Create quote request")</a> 5220 </div> 5221 } 5222 </div> 5223 } 5224 <script type="text/javascript"> 5225 function getCook(cookiename) { 5226 // Get name followed by anything except a semicolon 5227 var cookiestring = RegExp(cookiename + "=[^;]+").exec(document.cookie); 5228 // Return everything after the equal sign, or an empty string if the cookie name not found 5229 return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, "") : ""); 5230 } 5231 function GoToProductPage() { 5232 var cookieValue = getCook('ProductLink'); 5233 if (document.cookie.indexOf("ProductLink=") >= 0) { 5234 location.href = cookieValue; 5235 5236 } 5237 else{ 5238 location.href = "/Default.aspx?ID=@GetPageIdByNavigationTag("ProductsPage")"; 5239 } 5240 5241 } 5242 </script></text> 5243 <text>@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5244 @using Dynamicweb.Core 5245 @using System 5246 @using System.Web 5247 @using System.Linq 5248 @using System.Collections.Generic 5249 @using System.Text.RegularExpressions 5250 @using Dynamicweb.Extensibility 5251 @using Dynamicweb.Content 5252 @using Dynamicweb.Core 5253 @using Dynamicweb.Ecommerce.Orders 5254 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 5255 @using Dynamicweb.Rapido.Blocks 5256 @using Dynamicweb.Rapido.Blocks.Components 5257 @using Dynamicweb.Rapido.Blocks.Components.General 5258 5259 @{ 5260 BlocksPage staticSummaryCheckoutPageCustom = BlocksPage.GetBlockPage("CheckoutPage"); 5261 5262 Block staticSummaryCustom = new Block() 5263 { 5264 Id = "StaticSummary", 5265 SortId = 20, 5266 Design = new Design 5267 { 5268 RenderType = RenderType.Column, 5269 Size = "12" 5270 }, 5271 BlocksList = new List<Block> { 5272 new Block { 5273 Id = "StaticSummaryHeader", 5274 SortId = 10, 5275 Component = new Heading { Level = 3, Title = Translate("Summary") + " (" + GetString("Ecom:Order.OrderLines.TotalProductQuantity") + ")", Icon = new Icon { Prefix = "fas", Name = "fa-list-ul", LabelPosition = IconLabelPosition.After } }, 5276 Design = new Design { 5277 RenderType = RenderType.CardHeader, 5278 CssClass = "u-color-light--bg" 5279 } 5280 }, 5281 new Block { 5282 Id = "StaticSummaryBody", 5283 SortId = 20, 5284 Template = RenderStaticSummaryCustom(), 5285 Design = new Design { 5286 RenderType = RenderType.CardBody, 5287 CssClass = "u-color-light--bg u-no-padding--xs" 5288 } 5289 } 5290 } 5291 }; 5292 staticSummaryCheckoutPageCustom.ReplaceBlock(staticSummaryCustom); 5293 } 5294 5295 5296 @helper RenderStaticSummaryCustom() 5297 { 5298 int productCatalog = GetPageIdByNavigationTag("ProductsPage"); 5299 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(GetString("Ecom:Order.ID")); 5300 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 5301 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 5302 double shippingFeePrice = GetDouble("Ecom:Order.ShippingFee.Price"); 5303 double minPriceForFree = 0; 5304 double minPriceForFreeShip = 0; 5305 double aditionalPriceForFreeShipping = 0; 5306 double totalPriceWithoutFormated = GetDouble("Ecom:Order.Price.Price"); 5307 var shippingMethods = GetLoop("Shippingmethods"); 5308 var currency = Dynamicweb.Ecommerce.Services.Currencies.GetDefaultCurrency(); 5309 foreach (LoopItem shipping in shippingMethods) 5310 { 5311 5312 if (shipping.GetString("Ecom:Cart.Shippingmethod.Name") == GetString("Ecom:Order.ShippingMethod")) 5313 { 5314 minPriceForFree = shipping.GetDouble("Ecom:Cart.Shippingmethod.MinimumPriceForFreeFee.Price"); 5315 minPriceForFreeShip = minPriceForFree; 5316 if (shipping.GetDouble("Ecom:Cart.Shippingmethod.MinimumPriceForFreeFee.Price") > (totalPriceWithoutFormated - shippingFeePrice)) 5317 { 5318 aditionalPriceForFreeShipping = minPriceForFree - (totalPriceWithoutFormated - shippingFeePrice); 5319 5320 } 5321 5322 } 5323 } 5324 string cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 5325 if (!String.IsNullOrWhiteSpace(GetString("Ecom:OrderContext.ID"))) 5326 { 5327 cartFeedPageId += "&OrderContext=" + GetString("Ecom:OrderContext.ID"); 5328 } 5329 <div class="js-handlebars-root" id="SummaryCart" data-template="CartOrderlineSummary" data-cart-id="@cartFeedPageId" data-json-feed="/Default.aspx?ID=@cartFeedPageId" data-preloader="minimal"> 5330 5331 5332 </div> 5333 <script id="CartOrderlineSummary" type="text/x-template"> 5334 {{#.}} 5335 <table class="table cart-table u-margin-bottom u-border-bottom dw-mod"> 5336 <tbody> 5337 {{#OrderLines}} 5338 {{> (lookup . 'template') }} 5339 {{/OrderLines}} 5340 5341 5342 </tbody> 5343 5344 </table> 5345 @if (!pointShop) 5346 { 5347 <text> 5348 {{#unless hideSubTotal}} 5349 <div class="u-padding-bottom u-padding-x"> 5350 <div class="cart-summary__subtotals dw-mod">@Translate("Subtotal") </div> 5351 <div class="cart-summary__subtotals u-pull--right dw-mod"> 5352 @if (hasTaxSettings) 5353 { 5354 <text> 5355 {{subtotalpricewithouttaxes}} 5356 </text> 5357 5358 } 5359 else 5360 { 5361 <text> 5362 {{subtotalprice}} 5363 </text> 5364 5365 } 5366 </div> 5367 </div> 5368 {{/unless}} 5369 </text> 5370 <text> 5371 {{#unless hidePaymentfee}} 5372 <div class="u-padding-bottom u-padding-x"> 5373 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-credit-card", Label = "{{paymentmethod}}", LabelPosition = IconLabelPosition.After })</div> 5374 <div class="cart-summary__info u-pull--right dw-mod">{{paymentfee}}</div> 5375 </div> 5376 {{/unless}} 5377 </text> 5378 } 5379 5380 {{#unless hideShippingfee}} 5381 <div class="u-padding-bottom u-padding-x"> 5382 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-truck", Label = "{{shippingmethod}}", LabelPosition = IconLabelPosition.After })</div> 5383 <div class="cart-summary__info u-pull--right dw-mod">{{shippingfee}}</div> 5384 </div> 5385 {{#unless notTxtForShippingFree}} 5386 <div class="u-padding-bottom u-padding-x"> 5387 <div class="cart-summary__info dw-mod"><span class="txt-small">@Translate("Free shipping - Buy for additional") {{aditionalPriceForFreeShipping}}</span> </div> 5388 <div class="cart-summary__info u-pull--right dw-mod"></div> 5389 </div> 5390 {{/unless}} 5391 {{/unless}} 5392 5393 5394 5395 {{#if hasTaxSettings}} 5396 <div class="u-padding-bottom u-padding-x"> 5397 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-hand-holding-usd", Label = Translate("Sales Tax"), LabelPosition = IconLabelPosition.After })</div> 5398 <div class="cart-summary__info u-pull--right dw-mod">{{totaltaxes}}</div> 5399 </div> 5400 5401 5402 {{/if}} 5403 5404 @if (Pageview.User != null && Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints") && GetDouble("Ecom:Order.RewardTotalPoints") > 0) 5405 { 5406 <text> 5407 {{#if earnings}} 5408 <div class="u-padding-bottom u-padding-x"> 5409 <div class="cart-summary__info dw-mod">@Translate("Earnings")</div> 5410 <div class="cart-summary__info u-pull--right dw-mod"><span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")</div> 5411 </div> 5412 {{/if}} 5413 </text> 5414 5415 } 5416 5417 <div class="u-padding u-border-top"> 5418 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 5419 <div class="cart-summary__totals u-pull--right dw-mod">{{totalprice}}</div> 5420 </div> 5421 5422 @if (!pointShop && !hasTaxSettings) 5423 { 5424 <div class="u-ta-right u-padding-x"> 5425 <small class="cart-summary__info dw-mod">@Translate("VAT"):</small> 5426 <small class="cart-summary__info dw-mod">{{totalvat}}</small> 5427 </div> 5428 5429 if (isPricesWithVATEnabled) 5430 { 5431 <div class="u-ta-right u-padding-x"> 5432 <small class="cart-summary__info dw-mod">@Translate("Total price without VAT"):</small> 5433 <small class="cart-summary__info dw-mod">{{totalPriceWithoutVat}}</small> 5434 </div> 5435 } 5436 else 5437 { 5438 <div class="u-ta-right u-padding-x"> 5439 <small class="cart-summary__info dw-mod">@Translate("Total price with VAT"):</small> 5440 <small class="cart-summary__info dw-mod">{{totalPriceWithVat}}</small> 5441 </div> 5442 } 5443 } 5444 5445 {{#if showCheckoutDisclaimer}} 5446 <div class="u-ta-right"> 5447 <small class="u-full-width">{{checkoutDisclaimer}}</small> 5448 </div> 5449 {{/if}} 5450 5451 {{/.}} 5452 </script> 5453 <script id="CartOrderline" type="text/x-template"> 5454 {{#unless isEmpty}} 5455 <tr> 5456 <td class="u-w60px"> 5457 {{quantity}} x 5458 </td> 5459 <td title="{{name}} {{variantname}}"> 5460 <a href="{{link}}" class="u-color-inherit">{{name}}</a> 5461 <div>{{{variantname}}}</div> 5462 <div>{{unitname}}</div> 5463 @*{{#if trainingInfo}} 5464 <div class="cart-orderline__cell__block item-number dw-mod"><small>{{trainingInfo}} </small></div> 5465 {{/if}}*@ 5466 </td> 5467 {{#if pointsTotal}} 5468 <td class="u-ta-right u-w120px"> 5469 <span class="u-color--loyalty-points">{{pointPrice}}</span> @Translate("points") 5470 </td> 5471 {{else}} 5472 5473 <td class="u-ta-right u-w120px">{{totalprice}}</td> 5474 {{/if}} 5475 </tr> 5476 <tr class="{{hideBomItems}}"> 5477 <td colspan="3" class="u-no-padding"> 5478 <table class="u-no-margin u-color-light-gray--bg"> 5479 <tbody> 5480 {{#BomItems}} 5481 <tr> 5482 <td class="u-w60px">{{quantity}} x</td> 5483 <td title="{{name}} {{variantname}}"> 5484 <a href="{{link}}">{{name}}</a> 5485 <div>{{variantname}}</div> 5486 <div>{{unitname}}</div> 5487 </td> 5488 </tr> 5489 {{/BomItems}} 5490 </tbody> 5491 </table> 5492 </td> 5493 </tr> 5494 {{/unless}} 5495 </script> 5496 <script id="CartOrderlineDiscount" type="text/x-template"> 5497 <tr class="table__row--no-border"> 5498 <td class="u-w60px"> 5499 {{#unless notDiscountImage}} 5500 <img src="{{{image}}}"> 5501 {{/unless}} 5502 </td> 5503 <td>{{name}}</td> 5504 <td class="cart-table__price u-ta-right dw-mod">{{totalprice}}</td> 5505 </tr> 5506 </script> 5507 5508 } 5509 </text> 5510 5511 } 5512 5513 5514 5515 @helper RenderCheckoutForm() 5516 { 5517 List<Block> subBlocks = checkoutPage.GetBlockListById("CheckoutForm").OrderBy(item => item.SortId).ToList(); 5518 string pageId = GetGlobalValue("Global:Page.ID"); 5519 5520 <section class="multiple-paragraphs-container u-color-light-gray--bg paragraph-container--full-width"> 5521 <div class="center-container center-container--with-background-image dw-mod"> 5522 <div class="paragraph-container u-padding"> 5523 <form name="ordersubmit" id="OrderSubmit" method="post" action="/Default.aspx?ID=@pageId" autocomplete="off"> 5524 <div class="grid"> 5525 @RenderBlockList(subBlocks) 5526 </div> 5527 </form> 5528 </div> 5529 </div> 5530 </section> 5531 } 5532 5533 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 5534 @RenderBlockList(checkoutPage.BlocksRoot.BlocksList)