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_82efca07bcb94253aeebf296cd2e9423.<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 4435
   at RazorEngine.Templating.TemplateWriter.ToString()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_82efca07bcb94253aeebf296cd2e9423.<>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_82efca07bcb94253aeebf296cd2e9423.<>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_82efca07bcb94253aeebf296cd2e9423.<>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_82efca07bcb94253aeebf296cd2e9423.<>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_82efca07bcb94253aeebf296cd2e9423.<>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_82efca07bcb94253aeebf296cd2e9423.<>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_82efca07bcb94253aeebf296cd2e9423.Execute() in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\Cart.cshtml:line 5450
   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 @Render(new HiddenField { Name = "EcomOrderDeliveryCompany", Id = "EcomOrderDeliveryCompany" }) 2403 @Render(new HiddenField { Name = "EcomOrderDeliveryName", Id = "EcomOrderDeliveryName" }) 2404 @Render(new HiddenField { Name = "EcomOrderDeliveryPhone", Id = "EcomOrderDeliveryPhone" }) 2405 @Render(new HiddenField { Name = "EcomOrderDeliveryEmail", Id = "EcomOrderDeliveryEmail" }) 2406 @Render(new HiddenField { Name = "EcomOrderDeliveryAddress", Id = "EcomOrderDeliveryAddress" }) 2407 @Render(new HiddenField { Name = "EcomOrderDeliveryZip", Id = "EcomOrderDeliveryZip" }) 2408 @Render(new HiddenField { Name = "EcomOrderDeliveryCity", Id = "EcomOrderDeliveryCity" }) 2409 @Render(new HiddenField { Name = "EcomOrderDeliveryRegion", Id = "EcomOrderDeliveryRegion" }) 2410 @Render(new HiddenField { Name = "EcomOrderDeliveryCountry", Id = "EcomOrderDeliveryCountry" }) 2411 } 2412 2413 @helper RenderStaticShippingField(string name, string value, string cssClass = "", string displayedValue = "") 2414 { 2415 if (string.IsNullOrEmpty(displayedValue)) 2416 { 2417 displayedValue = value; 2418 } 2419 2420 @Render(new HiddenField { Name = name, Id = name, Value = value }) 2421 2422 if (!string.IsNullOrEmpty(displayedValue)) 2423 { 2424 <div class="@cssClass">@displayedValue</div> 2425 } 2426 } 2427 2428 @helper RenderStaticShippingAddress() 2429 { 2430 @RenderStaticShippingField("EcomOrderDeliveryName", GetString("Ecom:Order.Delivery.Name"), "u-bold") 2431 @RenderStaticShippingField("EcomOrderDeliveryCompany", GetString("Ecom:Order.Delivery.Company")) 2432 @RenderStaticShippingField("EcomOrderDeliveryAddress", GetString("Ecom:Order.Delivery.Address")) 2433 @RenderStaticShippingField("EcomOrderDeliveryZip", GetString("Ecom:Order.Delivery.Zip"), "u-inline") 2434 @RenderStaticShippingField("EcomOrderDeliveryCity", GetString("Ecom:Order.Delivery.City"), "u-inline") 2435 2436 if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Region"))) 2437 { 2438 var stateName = ""; 2439 foreach (var state in GetLoop("DeliveryRegions")) 2440 { 2441 if (state.GetString("Ecom:DeliveryRegion.RegionCode") == GetString("Ecom:Order.Delivery.Region")) 2442 { 2443 stateName = state.GetString("Ecom:DeliveryRegion.Name"); 2444 } 2445 } 2446 2447 @RenderStaticShippingField("EcomOrderDeliveryRegion", GetString("Ecom:Order.Delivery.Region"), "", stateName) 2448 } 2449 else 2450 { 2451 @RenderStaticShippingField("EcomOrderDeliveryRegion", "") 2452 } 2453 2454 foreach (LoopItem country in GetLoop("Countries")) 2455 { 2456 if (country.GetBoolean("Ecom:Country.IsDeliveryCountryOrDefault")) 2457 { 2458 @RenderStaticShippingField("EcomOrderDeliveryCountry", country.GetString("Ecom:Country.Code2"), "", country.GetString("Ecom:Country.Name")) 2459 break; 2460 } 2461 } 2462 2463 if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Email")) && !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Phone"))) 2464 { 2465 <div class="u-margin-bottom"></div> 2466 } 2467 2468 @RenderStaticShippingField("EcomOrderDeliveryEmail", GetString("Ecom:Order.Delivery.Email")) 2469 @RenderStaticShippingField("EcomOrderDeliveryPhone", GetString("Ecom:Order.Delivery.Phone")) 2470 2471 <div class="u-margin-bottom"></div> 2472 } 2473 2474 @helper RenderAddressesJavascript() 2475 { 2476 <script> 2477 function setUseBillingAddress(useBillingAddress) { 2478 RememberState.SetCookie("useAnotherAddress", !useBillingAddress) 2479 document.getElementById("useBillingAddress").checked = useBillingAddress; 2480 document.getElementById("useBillingAddress").setAttribute("checked", useBillingAddress); 2481 } 2482 2483 function changeShippingAddressToBilling() { 2484 setUseBillingAddress(true); 2485 document.querySelector(".js-shipping-address-container").classList.add("u-hidden"); 2486 Cart.FillShippingAddress({ 2487 Company: "", 2488 Name: "", 2489 Phone: "", 2490 Email: "", 2491 Address: "", 2492 Zip: "", 2493 City: "", 2494 Region: "", 2495 Country: "" 2496 }); 2497 Cart.SubmitCart() 2498 } 2499 </script> 2500 2501 if (addressesViewMode != "editable") 2502 { 2503 <script> 2504 let manageAddressPageId = "@GetPageIdByNavigationTag("AddressesForCheckout")"; 2505 2506 function showLoader(bodyElement) { 2507 let minHeightContainer = document.createElement("div"); 2508 minHeightContainer.className = "u-min-h180px"; 2509 let loader = document.createElement("div"); 2510 loader.className = "modal__loader"; 2511 let spinner = document.createElement("i"); 2512 spinner.className = "fa-4x fa-circle-notch fa-spin fas u-color-light"; 2513 loader.appendChild(spinner); 2514 minHeightContainer.appendChild(loader); 2515 bodyElement.innerHTML = ""; 2516 bodyElement.appendChild(minHeightContainer); 2517 } 2518 2519 //refresh addresses list 2520 function showAddressesListModal() { 2521 showLoader(document.querySelector("#MyAddressesSelectorModal .modal__body")); 2522 document.querySelector("#MyAddressesSelectorModalTrigger").checked = true; 2523 Request.Fetch().get( 2524 "Default.aspx?ID=" + manageAddressPageId, 2525 function (result) { 2526 document.querySelector("#MyAddressesSelectorModal .modal__body").innerHTML = result; 2527 }, 2528 function () { }, 2529 false 2530 ); 2531 } 2532 2533 var countries = []; 2534 2535 @foreach (var country in GetLoop("Countries")) 2536 { 2537 <text>countries.push("@country.GetString("Ecom:Country.Code2")");</text> 2538 } 2539 2540 function countryIsAvailable(countryCode) 2541 { 2542 return countries.indexOf(countryCode) != -1; 2543 } 2544 2545 function selectAddress(address) { 2546 if (countryIsAvailable(address.Country)) { 2547 Cart.FillShippingAddress(address); 2548 Cart.SubmitCart(); 2549 } else { 2550 document.getElementById("CountryIsNotAvailableModalTrigger").checked = true; 2551 } 2552 } 2553 </script> 2554 } 2555 2556 if (addressesViewMode == "static") 2557 { 2558 <script> 2559 let countryRegions = { 2560 2561 @foreach (var country in GetLoop("Countries")) 2562 { 2563 var regions = Dynamicweb.Ecommerce.Services.Countries.GetRegions(country.GetString("Ecom:Country.Code2")); 2564 2565 if (regions.Count > 0) 2566 { 2567 <text>"@country.GetString("Ecom:Country.Code2")": {</text> 2568 } 2569 2570 <text>@string.Join(",", regions.Select(region => "\"" + region.RegionCode + "\": \"" + region.Name + "\""))</text> 2571 2572 if (regions.Count > 0) 2573 { 2574 <text>},</text> 2575 } 2576 } 2577 2578 } 2579 2580 function changeCountry(countryCode) { 2581 document.getElementById("countryHidden").value = countryCode; 2582 let stateField = document.getElementById("UserManagement_Form_State"); 2583 stateField.innerHTML = ""; 2584 let currentRegions = countryRegions[countryCode] 2585 2586 if (currentRegions != null) { 2587 for (let regionCode in currentRegions) { 2588 let option = document.createElement("option"); 2589 option.text = currentRegions[regionCode]; 2590 option.value = regionCode; 2591 stateField.add(option); 2592 } 2593 stateField.closest(".js-state-field").classList.remove("u-hidden"); 2594 } else { 2595 let option = document.createElement("option"); 2596 option.value = ""; 2597 stateField.add(option); 2598 stateField.closest(".js-state-field").classList.add("u-hidden"); 2599 } 2600 } 2601 </script> 2602 <script id="AddAddressFormTemplate" type="text/html"> 2603 </script> 2604 <script id="AddAddressHeadingTemplate" type="text/html"> 2605 @Render(new Heading { Title = Translate("Add address"), Icon = new Icon { Prefix = "far", Name = "fa-plus", LabelPosition = IconLabelPosition.After } }) 2606 </script> 2607 <script id="EditAddressHeadingTemplate" type="text/html"> 2608 @Render(new Heading { Title = Translate("Edit address"), Icon = new Icon { Prefix = "fas", Name = "fa-pencil", LabelPosition = IconLabelPosition.After } }) 2609 </script> 2610 <script> 2611 //get add address form 2612 document.addEventListener("DOMContentLoaded", function () { 2613 Request.Fetch().get( 2614 "Default.aspx?ID=" + manageAddressPageId + "&ManageAddressesFormAction=Add", 2615 function (result) { 2616 document.querySelector("#AddAddressFormTemplate").innerHTML = result; 2617 document.querySelector("#ManageAddressModal .modal__body").innerHTML = document.getElementById("AddAddressFormTemplate").innerHTML; 2618 }, 2619 function () { }, 2620 false 2621 ); 2622 }); 2623 2624 function openAddAddressModal() { 2625 //get already saved template to prevent additional loading 2626 document.getElementById("MyAddressesSelectorModalTrigger").checked = false; 2627 document.querySelector("#ManageAddressModal .modal__header").innerHTML = document.getElementById("AddAddressHeadingTemplate").innerHTML; 2628 document.querySelector("#ManageAddressModal .modal__body").innerHTML = document.getElementById("AddAddressFormTemplate").innerHTML; 2629 regionLabels.LocalizeRegionLabels("UserManagement_Form_State", "UserManagement_Form_Country", true); 2630 document.getElementById("ManageAddressModalTrigger").checked = true; 2631 } 2632 2633 //open edit modal 2634 function openEditAddressModal(addressId) { 2635 document.getElementById("MyAddressesSelectorModalTrigger").checked = false; 2636 showLoader(document.querySelector("#ManageAddressModal .modal__body")); 2637 document.querySelector("#ManageAddressModal .modal__header").innerHTML = document.getElementById("EditAddressHeadingTemplate").innerHTML; 2638 document.getElementById("ManageAddressModalTrigger").checked = true; 2639 Request.Fetch().post( 2640 "Default.aspx?ID=" + manageAddressPageId, 2641 { 2642 "ManageAddressesFormAction": "Update", 2643 "SelectedAddressId": addressId 2644 }, 2645 function (result) { 2646 document.querySelector("#ManageAddressModal .modal__body").innerHTML = result; 2647 regionLabels.LocalizeRegionLabels("UserManagement_Form_State", "UserManagement_Form_Country", true); 2648 }, 2649 function () { }, 2650 false 2651 ); 2652 } 2653 2654 //save address (add / edit) 2655 function saveAddress(mode) { 2656 let form = document.getElementById("AddressForm"); 2657 let formData = new FormData(form); 2658 if (!form.checkValidity()) { 2659 // Create the temporary button, click and remove it 2660 var tmpSubmit = document.createElement("button"); 2661 form.appendChild(tmpSubmit); 2662 tmpSubmit.click(); 2663 form.removeChild(tmpSubmit); 2664 } else { 2665 Request.Fetch().post( 2666 "Default.aspx?ID=" + manageAddressPageId + "&ManageAddressesFormAction=Add", 2667 formData, 2668 function (result) { 2669 document.getElementById("ManageAddressModalTrigger").checked = false; 2670 showAddressesListModal(); 2671 }, 2672 function () { }, 2673 false 2674 ); 2675 } 2676 } 2677 2678 //delete 2679 function deleteAddress(addressId, button) { 2680 Request.Fetch().post( 2681 "Default.aspx?ID=" + manageAddressPageId, 2682 { 2683 SelectedAddressId: addressId, 2684 ManageAddressesFormAction: "Delete" 2685 }, 2686 function (result) { 2687 button.closest(".media-list-item").remove(); 2688 }, 2689 function () { }, 2690 false 2691 ); 2692 } 2693 </script> 2694 } 2695 } 2696 2697 @helper RenderEditableShippingAddress() 2698 { 2699 @Render(new TextField { Label = Translate("Company"), Name = "EcomOrderDeliveryCompany", Id = "EcomOrderDeliveryCompany", Value = GetString("Ecom:Order.Delivery.Company"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCompany.ErrorMessage") }) 2700 @Render(new TextField { Label = Translate("Name"), Name = "EcomOrderDeliveryName", Id = "EcomOrderDeliveryName", Value = GetString("Ecom:Order.Delivery.Name"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryName.ErrorMessage") }) 2701 2702 <div class="form__fields-collection form__fields-collection--2-3"> 2703 @Render(new TextField { Label = Translate("Phone"), Name = "EcomOrderDeliveryPhone", Id = "EcomOrderDeliveryPhone", Value = GetString("Ecom:Order.Delivery.Phone"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryPhone.ErrorMessage") }) 2704 @Render(new TextField { Label = Translate("Email"), Name = "EcomOrderDeliveryEmail", Id = "EcomOrderDeliveryEmail", Value = GetString("Ecom:Order.Delivery.Email"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryEmail.ErrorMessage") }) 2705 </div> 2706 2707 @Render(new TextField { Label = Translate("Address"), Name = "EcomOrderDeliveryAddress", Id = "EcomOrderDeliveryAddress", Value = GetString("Ecom:Order.Delivery.Address"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryAddress.ErrorMessage") }) 2708 2709 <div class="form__fields-collection form__fields-collection--2-3"> 2710 @Render(new TextField { Label = Translate("Zip"), Name = "EcomOrderDeliveryZip", Id = "EcomOrderDeliveryZip", Value = GetString("Ecom:Order.Delivery.Zip"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryZip.ErrorMessage") }) 2711 @Render(new TextField { Label = Translate("City"), Name = "EcomOrderDeliveryCity", Id = "EcomOrderDeliveryCity", Value = GetString("Ecom:Order.Delivery.City"), ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCity.ErrorMessage") }) 2712 </div> 2713 2714 if (GetLoop("DeliveryRegions").Count > 0) 2715 { 2716 SelectField selectState = new SelectField 2717 { 2718 Id = "EcomOrderDeliveryRegion", 2719 Name = "EcomOrderDeliveryRegion", 2720 Label = Translate("State/Region"), 2721 OnChange = "Cart.SubmitCart()", 2722 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryRegion.ErrorMessage"), 2723 Value = GetString("Ecom:Order.Delivery.Region") 2724 }; 2725 selectState.Options.Add(new SelectFieldOption 2726 { 2727 Label = Translate("Nothing selected"), 2728 Value = "", 2729 Disabled = true, 2730 Checked = true 2731 }); 2732 foreach (LoopItem state in GetLoop("DeliveryRegions")) 2733 { 2734 selectState.Options.Add(new SelectFieldOption { Label = state.GetString("Ecom:DeliveryRegion.Name"), Value = state.GetString("Ecom:DeliveryRegion.RegionCode") }); 2735 } 2736 @Render(selectState) 2737 } 2738 else 2739 { 2740 @Render(new HiddenField { Id = "EcomOrderDeliveryRegion", Name = "EcomOrderDeliveryRegion" }) 2741 } 2742 2743 SelectField selectCountry = new SelectField 2744 { 2745 Id = "EcomOrderDeliveryCountry", 2746 Name = "EcomOrderDeliveryCountry", 2747 Label = Translate("Country"), 2748 OnChange = "resetStateField('EcomOrderDeliveryRegion');Cart.SubmitCart()", 2749 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCountry.ErrorMessage") 2750 }; 2751 2752 foreach (LoopItem country in GetLoop("Countries")) 2753 { 2754 selectCountry.Options.Add(new SelectFieldOption { Label = country.GetString("Ecom:Country.Name"), Value = country.GetString("Ecom:Country.Code2"), Checked = country.GetBoolean("Ecom:Country.IsDeliveryCountryOrDefault") }); 2755 } 2756 2757 @Render(selectCountry) 2758 } 2759 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2760 @using Dynamicweb.Core 2761 @using System 2762 @using System.Web 2763 @using System.Linq 2764 @using System.Collections.Generic 2765 @using Dynamicweb.Rapido.Blocks 2766 @using Dynamicweb.Rapido.Blocks.Components 2767 @using Dynamicweb.Rapido.Blocks.Components.General 2768 2769 @{ 2770 BlocksPage paymentCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 2771 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 2772 string paymentCardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 2773 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")); 2774 2775 var paymentBlock = new Block() 2776 { 2777 Id = "Payment", 2778 SortId = 10, 2779 Design = new Design 2780 { 2781 RenderType = RenderType.Column, 2782 Size = "6-auto" 2783 } 2784 }; 2785 2786 var paymentHeader = new Block 2787 { 2788 Id = "PaymentHeader", 2789 SortId = 10, 2790 Component = new Heading { Level = 3, Title = Translate("Payment"), Icon = new Icon { Prefix = "fas", Name = "fa-credit-card", LabelPosition = IconLabelPosition.After } }, 2791 Design = new Design 2792 { 2793 RenderType = RenderType.CardHeader, 2794 CssClass = "u-color-light--bg" 2795 } 2796 }; 2797 2798 var paymentBody = new Block 2799 { 2800 Id = "PaymentBody", 2801 SortId = 20, 2802 Design = new Design 2803 { 2804 RenderType = RenderType.CardBody, 2805 CssClass = "u-color-light--bg " + paymentCardHeightClass 2806 } 2807 }; 2808 2809 if (paymentCountryIsNotSupported) 2810 { 2811 paymentBlock.Add(paymentHeader); 2812 paymentBody.Component = new NotificationMessage { MessageType = NotificationMessageType.Error, Message = Translate("There is no available payment options") }; 2813 paymentBlock.Add(paymentBody); 2814 } 2815 else if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HidePayment") && GetLoop("Paymethods").Count != 0 && !pointShop) 2816 { 2817 paymentBlock.Add(paymentHeader); 2818 paymentBody.Template = RenderPayment(); 2819 paymentBlock.Add(paymentBody); 2820 } 2821 else 2822 { 2823 paymentBlock.Template = RenderHiddenPayment(); 2824 paymentBlock.Design.CssClass = "u-hidden"; 2825 } 2826 2827 paymentCheckoutPage.Add("OrderContainerRow", paymentBlock); 2828 } 2829 2830 @helper RenderPayment() 2831 { 2832 string errorMessage = GetString("Ecom:Cart.ValidationError.EcomCartPaymethodId.ErrorMessage"); 2833 string savedCardName = ""; 2834 foreach (LoopItem payment in GetLoop("Paymethods")) 2835 { 2836 bool isExist = false; 2837 bool supportSavedCards = payment.GetBoolean("Ecom:Cart.Paymethod.SupportSavedCard") && Dynamicweb.Core.Converter.ToBoolean(GetGlobalValue("Global:Extranet.UserName")); 2838 bool cardIsSaved = !String.IsNullOrEmpty(payment.GetString("Ecom:Order.SavedCardName")) ? true : false; 2839 2840 if (Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetItems("Distributor_Payments") != null && Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetItems("Distributor_Payments").Count > 0) 2841 { 2842 2843 foreach (var lang in Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetItems("Distributor_Payments")) 2844 { 2845 if (lang.GetString("Payment") == payment.GetString("Ecom:Cart.Paymethod.Name")) 2846 { 2847 isExist = true; 2848 if (Dynamicweb.Frontend.PageView.Current().User.CurrentSecondaryUser != null) 2849 { 2850 <div> 2851 <div class="u-margin-bottom"> 2852 @Render(new RadioButtonField 2853 { 2854 Name = "EcomCartPaymethodId", 2855 Label = payment.GetString("Ecom:Cart.Paymethod.Name"), 2856 Id = "EcomCartPaymethodId_" + payment.GetString("Ecom:Cart.Paymethod.ID"), 2857 Value = payment.GetString("Ecom:Cart.Paymethod.ID"), 2858 OnChange = "Cart.DeselectRadioGroup('EcomCartSavedCardID'); PaymentSubmit('EcomCartPaymethodId_" + payment.GetString("Ecom:Cart.Paymethod.ID") + "','" + payment.GetString("Ecom:Cart.Paymethod.ID") + "')", 2859 Checked = payment.GetBoolean("Ecom:Cart.Paymethod.IsSelected"), 2860 ExtraAttributes = new Dictionary<string, string> 2861 () { 2862 { "data-expand", "savedCards_" + payment.GetString("Ecom:Cart.Paymethod.Name").Replace(" ", "_") } 2863 } 2864 }) 2865 </div> 2866 </div> 2867 } 2868 2869 } 2870 2871 2872 } 2873 } 2874 2875 2876 2877 if (!isExist) 2878 { 2879 <div> 2880 <div class="u-margin-bottom"> 2881 @Render(new RadioButtonField 2882 { 2883 Name = "EcomCartPaymethodId", 2884 Label = payment.GetString("Ecom:Cart.Paymethod.Name"), 2885 Id = "EcomCartPaymethodId_" + payment.GetString("Ecom:Cart.Paymethod.ID"), 2886 Value = payment.GetString("Ecom:Cart.Paymethod.ID"), 2887 OnChange = "Cart.DeselectRadioGroup('EcomCartSavedCardID'); PaymentSubmit('EcomCartPaymethodId_" + payment.GetString("Ecom:Cart.Paymethod.ID") + "','" + payment.GetString("Ecom:Cart.Paymethod.ID") + "')", 2888 Checked = payment.GetBoolean("Ecom:Cart.Paymethod.IsSelected"), 2889 ExtraAttributes = new Dictionary<string, string> 2890 () { 2891 { "data-expand", "savedCards_" + payment.GetString("Ecom:Cart.Paymethod.Name").Replace(" ", "_") } 2892 } 2893 }) 2894 </div> 2895 2896 @if (supportSavedCards) 2897 { 2898 <div class="expandable--collapsed dw-mod" data-trigger="savedCards_@payment.GetString("Ecom:Cart.Paymethod.Name").Replace(" ", "_")"> 2899 <div class="u-border-top u-border-bottom u-padding u-margin-bottom show"> 2900 @Render(new CheckboxField { Label = Translate("Save used card"), Name = "EcomOrderSavedCardCreate", Id = "EcomOrderSavedCardCreate_" + payment.GetString("Ecom:Cart.Paymethod.ID"), Value = "true", Checked = cardIsSaved }) 2901 2902 @Render(new TextField 2903 { 2904 Placeholder = Translate("Saved card name"), 2905 Value = payment.GetString("Ecom:Order.SavedCardName"), 2906 OnChange = "document.getElementById('MySavedCardName').value=this.value" 2907 }) 2908 </div> 2909 </div> 2910 } 2911 </div> 2912 } 2913 } 2914 2915 if (!string.IsNullOrEmpty(errorMessage)) 2916 { 2917 @Render(new NotificationMessage { Message = errorMessage, MessageType = NotificationMessageType.Error }) 2918 } 2919 2920 if (GetLoop("SavedCards").Count > 0) 2921 { 2922 <div class="u-bold u-margin-top u-margin-bottom">@Translate("Pay with a saved card")</div> 2923 2924 foreach (LoopItem card in GetLoop("SavedCards")) 2925 { 2926 @Render(new RadioButtonField 2927 { 2928 Name = "EcomCartSavedCardID", 2929 Label = card.GetString("Ecom:SavedCard.Name"), 2930 Value = card.GetString("Ecom:SavedCard.ID"), 2931 OnChange = "Cart.DeselectRadioGroup('EcomCartPaymethodID');PaymentSubmit()", 2932 Checked = card.GetBoolean("Ecom:SavedCard.IsSelected") 2933 }) 2934 2935 if (!card.GetBoolean("Ecom:SavedCard.IsSelected")) 2936 { 2937 savedCardName = card.GetString("Ecom:SavedCard.Name"); 2938 } 2939 } 2940 } 2941 2942 @Render(new HiddenField { Name = "EcomOrderSavedCardName", Id = "MySavedCardName", Value = savedCardName }) 2943 <script> 2944 2945 PaymentSubmit = function(e, id) { 2946 let elementname = e; 2947 let elementvalue = id; 2948 const XHR = new XMLHttpRequest(), 2949 FD = new FormData(); 2950 FD.append(elementname, elementvalue); 2951 XHR.addEventListener('load', function (event) { 2952 //Success 2953 }); 2954 // Define what happens in case of error 2955 XHR.addEventListener(' error', function (event) { 2956 //Error 2957 }); 2958 XHR.open('POST', 'Default.aspx?ID=@GetPageIdByNavigationTag("CartOrderlinesFeed")'); 2959 XHR.send(FD); 2960 }; 2961 2962 </script> 2963 } 2964 2965 @helper RenderHiddenPayment() 2966 { 2967 foreach (LoopItem payment in GetLoop("Paymethods")) 2968 { 2969 string selected = "checked"; 2970 2971 <div class="form__field-group u-margin-bottom"> 2972 <input type="radio" name="EcomCartPaymethodID" id="EcomCartPaymethodID_@payment.GetString("Ecom:Cart.Paymethod.ID")" value="@payment.GetString("Ecom:Cart.Paymethod.ID")" @selected /> 2973 <label for="EcomCartPaymethodID_@payment.GetString("Ecom:Cart.Paymethod.ID")" class="u-inline">@payment.GetString("Ecom:Cart.Paymethod.Name")</label> 2974 </div> 2975 } 2976 } 2977 2978 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2979 @using Dynamicweb.Core 2980 @using System 2981 @using System.Linq 2982 @using System.Collections.Generic 2983 @using Dynamicweb.Rapido.Blocks 2984 @using Dynamicweb.Rapido.Blocks.Components 2985 @using Dynamicweb.Rapido.Blocks.Components.General 2986 2987 @{ 2988 BlocksPage shippingCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 2989 string shippingCardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 2990 List<LoopItem> shippingMethods = GetLoop("Shippingmethods"); 2991 if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideShippingWarningsAndErrors")) 2992 { 2993 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(); 2994 } 2995 var shippingDeliveryCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 2996 if (string.IsNullOrEmpty(shippingDeliveryCountryCode)) 2997 { 2998 shippingDeliveryCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 2999 } 3000 bool shippingCountryIsNotSupported = !string.IsNullOrEmpty(shippingDeliveryCountryCode) && !GetLoop("Countries").Any(country => country.GetString("Ecom:Country.Code2") == shippingDeliveryCountryCode); 3001 3002 var shippingBlock = new Block() 3003 { 3004 Id = "Shipping", 3005 SortId = 20, 3006 Design = new Design 3007 { 3008 RenderType = RenderType.Column, 3009 Size = "6-auto" 3010 } 3011 }; 3012 3013 var shippingHeader = new Block 3014 { 3015 Id = "BillingAddressHeader", 3016 SortId = 10, 3017 Component = new Heading { Level = 3, Title = Translate("Shipping"), Icon = new Icon { Prefix = "fas", Name = "fa-truck", LabelPosition = IconLabelPosition.After } }, 3018 Design = new Design 3019 { 3020 RenderType = RenderType.CardHeader, 3021 CssClass = "u-color-light--bg" 3022 } 3023 }; 3024 3025 var shippingBody = new Block 3026 { 3027 Id = "BillingAddressBody", 3028 SortId = 20, 3029 Design = new Design { 3030 RenderType = RenderType.CardBody, 3031 CssClass = "u-color-light--bg " + shippingCardHeightClass 3032 } 3033 }; 3034 3035 if (shippingCountryIsNotSupported) 3036 { 3037 shippingBody.Component = new NotificationMessage { MessageType = NotificationMessageType.Error, Message = Translate("There is no available shipping options") }; 3038 shippingBlock.Add(shippingHeader); 3039 shippingBlock.Add(shippingBody); 3040 shippingCheckoutPage.Add("OrderContainerRow", shippingBlock); 3041 } 3042 else if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideShipping") && shippingMethods.Count > 0) 3043 { 3044 shippingBody.Template = RenderShipping(shippingMethods); 3045 shippingBlock.Add(shippingHeader); 3046 shippingBlock.Add(shippingBody); 3047 shippingCheckoutPage.Add("OrderContainerRow", shippingBlock); 3048 3049 Block parcelShopsModal = new Block() 3050 { 3051 Id = "ParcelShopsModal", 3052 SortId = 10, 3053 Component = new Modal 3054 { 3055 Id = "ParcelShops", 3056 Heading = new Heading 3057 { 3058 Title = Pageview.Device.ToString() != "Mobile" ? Translate("Choose a parcel shop") : Translate("Choose") 3059 }, 3060 BodyTemplate = RenderParcelShopsModalContent(), 3061 Width = ModalWidth.Lg 3062 } 3063 }; 3064 shippingCheckoutPage.Add("CheckoutTopSnippets", parcelShopsModal); 3065 3066 Block parcelShopsScriptTemplates = new Block() 3067 { 3068 Id = "ShippingProviderTemplates", 3069 SortId = 10, 3070 Template = RenderShippingProviderTemplates() 3071 }; 3072 shippingCheckoutPage.Add("CheckoutBottomSnippets", parcelShopsScriptTemplates); 3073 } 3074 } 3075 3076 @helper RenderShipping(List<LoopItem> shippingMethods) 3077 { 3078 if (shippingMethods == null) 3079 { 3080 shippingMethods = GetLoop("Shippingmethods"); 3081 } 3082 bool defaultShippingIsSet = Dynamicweb.Ecommerce.Orders.Shipping.GetDefaultShippingMethod(Dynamicweb.Ecommerce.Common.Context.Cart.ShippingMethodCountryCode) != null; 3083 bool haveShippingContent = shippingMethods.Count != 1 || !defaultShippingIsSet; 3084 bool showShippingsBlock = haveShippingContent; 3085 string errorMessage = GetString("Ecom:Cart.ValidationError.EcomCartShippingmethodId.ErrorMessage"); 3086 3087 foreach (LoopItem shipping in shippingMethods) 3088 { 3089 bool selected = Converter.ToBoolean(shipping.GetString("Ecom:Cart.Shippingmethod.IsSelected")); 3090 object shippingProviderContent = selected ? Newtonsoft.Json.JsonConvert.DeserializeObject(shipping.GetString("Ecom:ShippingProvider.Content")) : null; 3091 string hideLabel = haveShippingContent ? "" : "u-hidden"; 3092 string leftMargin = haveShippingContent ? "u-margin--radio-button-indent" : ""; 3093 3094 @Render(new RadioButtonField 3095 { 3096 OnChange = "Cart.SubmitCart()", 3097 Label = shipping.GetString("Ecom:Cart.Shippingmethod.Name"), 3098 Name = "EcomCartShippingmethodId", 3099 Id = "EcomCartShippingmethodId_" + shipping.GetString("Ecom:Cart.Shippingmethod.ID"), 3100 Value = shipping.GetString("Ecom:Cart.Shippingmethod.ID"), 3101 CssClass = hideLabel, 3102 Checked = selected, 3103 WrapperCssClass = shippingProviderContent != null ? "u-margin-bottom" : "" 3104 }) 3105 3106 if (shippingProviderContent != null) 3107 { 3108 showShippingsBlock = true; 3109 3110 <div id="ShippingProviderContent" class="@leftMargin" data-template="ShippingProviderContentTemplate"></div> 3111 <script> 3112 document.addEventListener("DOMContentLoaded", function (event) { 3113 HandlebarsBolt.CreateItemsFromJson(@shippingProviderContent, "ShippingProviderContent", "ShippingProviderContentTemplate"); 3114 HandlebarsBolt.CreateItemsFromJson(@shippingProviderContent, "ParcelShops", "ParcelShopsTemplate"); 3115 RememberState.SetCookie("useAnotherAddress", false); 3116 }); 3117 3118 function setParcelShopToDeliveryFields(number, address) { 3119 Cart.FillShippingAddress(address); 3120 document.getElementById("parcelShopNumber").value = number; 3121 Cart.SubmitCart(); 3122 } 3123 </script> 3124 } 3125 3126 if (shippingProviderContent != null && @shipping.GetString("Ecom:ShippingProvider.Content").Length < 10) 3127 { 3128 @Render(new Button { ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--full u-no-margin u-margin-bottom", OnClick = "Cart.SubmitCart()", Title = Translate("Get parcel shops") }) 3129 <small class="help-text dw-mod">@Translate("Requires a valid address")</small> 3130 } 3131 3132 } 3133 if (!string.IsNullOrEmpty(errorMessage)) 3134 { 3135 @Render(new NotificationMessage { Message = errorMessage, MessageType = NotificationMessageType.Error }) 3136 } 3137 3138 if (!showShippingsBlock) 3139 { 3140 <script> 3141 var shippingBlock = document.getElementById("Block__Shipping"); 3142 if (shippingBlock) { 3143 shippingBlock.classList.add("u-hidden"); 3144 } 3145 </script> 3146 } 3147 } 3148 3149 @helper RenderParcelShopsModalContent() 3150 { 3151 <div class="grid grid--bleed"> 3152 <div class="grid__col-auto u-margin-right"> 3153 <ul class="list list--clean list--scroll dw-mod" id="ParcelShops" data-template="ParcelShopsTemplate"></ul> 3154 </div> 3155 @if (Pageview.Device.ToString() != "Mobile") 3156 { 3157 <div class="grid__col-8"> 3158 <div class="map-container"> 3159 <div id="MapCanvas" class="map-container__canvas"></div> 3160 </div> 3161 </div> 3162 } 3163 </div> 3164 } 3165 3166 @helper RenderShippingAddressFromParcelShop() 3167 { 3168 @Render(new HiddenField { Name = "EcomOrderDeliveryName", Id = "EcomOrderDeliveryName", Value = "{{company}}" }) 3169 @Render(new HiddenField { Name = "EcomOrderDeliveryCompany", Id = "EcomOrderDeliveryCompany", Value = "{{company}}" }) 3170 @Render(new HiddenField { Name = "EcomOrderDeliveryAddress", Id = "EcomOrderDeliveryAddress", Value = "{{address}}" }) 3171 @Render(new HiddenField { Name = "EcomOrderDeliveryZip", Id = "EcomOrderDeliveryZip", Value = "{{zip}}" }) 3172 @Render(new HiddenField { Name = "EcomOrderDeliveryCity", Id = "EcomOrderDeliveryCity", Value = "{{city}}" }) 3173 @Render(new HiddenField { Name = "EcomOrderDeliveryRegion", Id = "EcomOrderDeliveryRegion", Value = "" }) 3174 @Render(new HiddenField { Name = "EcomOrderDeliveryCountry", Id = "EcomOrderDeliveryCountry", Value = "{{countryCode}}" }) 3175 3176 @Render(new HiddenField { Name = "EcomOrderDeliveryEmail", Id = "EcomOrderDeliveryEmail", Value = "" }) 3177 @Render(new HiddenField { Name = "EcomOrderDeliveryPhone", Id = "EcomOrderDeliveryPhone", Value = "" }) 3178 } 3179 3180 @helper RenderShippingProviderTemplates() 3181 { 3182 <script id="ShippingProviderContentTemplate" type="text/x-template"> 3183 {{#.}} 3184 <div class="{{hideShippingProvider}}"> 3185 {{#SelectedParcelShop}} 3186 <div class="u-hidden"> 3187 <input type="radio" id="parcelShopNumber" class="u-no-margin" name="{{fieldPrefix}}{{fieldPostfix}}" value="{{number}}" {{selected}} /> 3188 </div> 3189 <div> 3190 @Render(new Icon { Prefix = "fas", Name = "fa-map-marker", Label = "<span class='u-bold'>{{company}}</span>" }) 3191 <div>{{address}}</div> 3192 <div>{{zip}} {{city}}</div> 3193 <div>{{country}}</div> 3194 </div> 3195 @RenderShippingAddressFromParcelShop() 3196 {{/SelectedParcelShop}} 3197 {{^SelectedParcelShop}} 3198 @Translate("No points found") 3199 {{/SelectedParcelShop}} 3200 <div class="u-margin-top"> 3201 <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> 3202 </div> 3203 </div> 3204 {{/.}} 3205 </script> 3206 3207 <script id="ParcelShopsTemplate" type="text/x-template"> 3208 {{#.}} 3209 {{#ParcelShops}} 3210 <li data-number="{{number}}" data-lat="{{latitude}}" data-lng="{{longitude}}" class="u-border-bottom u-padding-bottom"> 3211 <input type="radio" name="{{fieldPrefix}}{{fieldPostfix}}" value="{{number}}" class="form__control" id="{{fieldPrefix}}ParcelShopNumber_{{number}}" {{selected}} 3212 onclick="setParcelShopToDeliveryFields('{{number}}', { 3213 Name: '{{company}}', @*is it ok???*@ 3214 Company: '{{company}}', 3215 Address: '{{address}}', 3216 Zip: '{{zip}}', 3217 City: '{{city}}', 3218 Country: '{{countryCode}}' 3219 })" /> 3220 <label for="{{fieldPrefix}}ParcelShopNumber_{{number}}" class="u-flex"> 3221 <span> 3222 <span class="u-margin-bottom u-block u-bold">{{company}}</span> 3223 <span class="u-line-height--normal u-font-size--sm"> 3224 <span class="u-block">{{address}}</span> 3225 <span class="u-block">{{zip}} {{city}}</span> 3226 <span class="u-block">{{country}}</span> 3227 </span> 3228 </span> 3229 </label> 3230 </li> 3231 {{/ParcelShops}} 3232 {{/.}} 3233 </script> 3234 3235 3236 string mapsScriptUrl = "//maps.googleapis.com/maps/api/js"; 3237 mapsScriptUrl += !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleMapsAPIKey")) ? "?key=" + Pageview.AreaSettings.GetItem("Settings").GetString("GoogleMapsAPIKey") : ""; 3238 3239 <script src="@mapsScriptUrl"></script> 3240 } 3241 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3242 @using Dynamicweb.Core 3243 @using System 3244 @using System.Web 3245 @using System.Collections.Generic 3246 @using Dynamicweb.Rapido.Blocks 3247 @using Dynamicweb.Rapido.Blocks.Components 3248 @using Dynamicweb.Rapido.Blocks.Components.General 3249 3250 @{ 3251 BlocksPage voucherCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 3252 string voucherCardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 3253 3254 if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideVoucher")) 3255 { 3256 Block voucherBlock = new Block() 3257 { 3258 Id = "Voucher", 3259 SortId = 30, 3260 Design = new Design 3261 { 3262 RenderType = RenderType.Column, 3263 Size = "6-auto" 3264 }, 3265 BlocksList = new List<Block> { 3266 new Block { 3267 Id = "VoucherHeader", 3268 SortId = 10, 3269 Component = new Heading { Level = 3, Title = Translate("Voucher"), Icon = new Icon { Prefix = "fas", Name = "fa-gift", LabelPosition = IconLabelPosition.After } }, 3270 Design = new Design { 3271 RenderType = RenderType.CardHeader, 3272 CssClass = "u-color-light--bg" 3273 } 3274 }, 3275 new Block { 3276 Id = "VoucherBody", 3277 SortId = 20, 3278 Template = RenderVoucher(), 3279 Design = new Design { 3280 RenderType = RenderType.CardBody, 3281 CssClass = "u-color-light--bg " + voucherCardHeightClass 3282 } 3283 } 3284 } 3285 }; 3286 voucherCheckoutPage.Add("OrderContainerRow", voucherBlock); 3287 } 3288 } 3289 3290 @helper RenderVoucher() 3291 { 3292 string cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 3293 <div class="form__field-combi"> 3294 @Render(new TextField { Placeholder = Translate("Enter voucher code"), Name = "EcomOrderVoucherCode", Id = "EcomOrderVoucherCode", Value = GetString("Ecom:Order.Customer.VoucherCode"), CssClass = "u-full-width" }) 3295 @Render(new Button { ButtonType = ButtonType.Button, OnClick = "VoucherSubmit('EcomOrderVoucherCode', document.getElementById('EcomOrderVoucherCode').value);", Id = "EcomOrderVoucherApply", Title = Translate("Apply"), CssClass = "btn--condensed u-no-margin" }) 3296 </div> 3297 <div class="js-handlebars-root" id="VoucherCodeContaner" data-template="VoucherTemplate" data-json-feed="/Default.aspx?ID=@cartFeedPageId" data-preloader="minimal"> </div> 3298 3299 3300 <script id="VoucherTemplate" type="text/x-template"> 3301 {{#.}} 3302 <div class="field-error u-full-width dw-mod"> {{{errorVoucher}}}</div> 3303 <div class="field-success u-full-width dw-mod">{{{messageVoucher}}}</div> 3304 {{/.}} 3305 </script> 3306 3307 <script> 3308 3309 document.getElementById("VoucherCodeContaner").addEventListener("contentLoaded", function (event) { 3310 var input = document.getElementById("EcomOrderVoucherCode"); 3311 var inputVoucher = document.querySelector("#VoucherCodeContaner .field-error"); 3312 var stepButtonId = document.getElementById("CartV2.GotoStep3") ? "CartV2.GotoStep3" : "CartV2.GotoStep1"; 3313 var stepButton = document.getElementById(stepButtonId); 3314 3315 if (inputVoucher.innerHTML.length>1) { 3316 stepButton.classList.add("disabled-btn") 3317 } 3318 else { 3319 stepButton.classList.remove("disabled-btn") 3320 } 3321 3322 }); 3323 // Execute a function when the user releases a key on the keyboard 3324 document.getElementById("EcomOrderVoucherCode").addEventListener("keypress", function (event) { 3325 // Number 13 is the "Enter" key on the keyboard 3326 if (event.keyCode === 13) { 3327 // Cancel the default action, if needed 3328 event.preventDefault(); 3329 // Trigger the button element with a click 3330 document.getElementById("EcomOrderVoucherApply").click(); 3331 } 3332 }); 3333 3334 VoucherSubmit = function (e, id) { 3335 var selectForm = document.getElementById("OrderSubmit"); // Select the form by ID. 3336 let elementname = e; 3337 let elementvalue = id; 3338 clearTimeout(updateDelay); 3339 3340 updateDelay = setTimeout(function () { 3341 const XHR = new XMLHttpRequest(), 3342 FD = new FormData(); 3343 FD.append(elementname, elementvalue); 3344 XHR.addEventListener('load', function (event) { 3345 //Success 3346 }); 3347 // Define what happens in case of error 3348 XHR.addEventListener(' error', function (event) { 3349 //Error 3350 }); 3351 XHR.open('POST', 'Default.aspx?ID=@cartFeedPageId'); 3352 XHR.send(FD); 3353 3354 3355 HandlebarsBolt.UpdateContent('SummaryCart', 3356 '/Default.aspx?ID=@cartFeedPageId' + '&redirect=false', 3357 '/Default.aspx?ID=@cartFeedPageId' + '&redirect=false', 3358 'CartOrderlineSummary', 'minimal'); 3359 HandlebarsBolt.UpdateContent('VoucherCodeContaner', 3360 '/Default.aspx?ID=@cartFeedPageId' + '&redirect=false', 3361 '/Default.aspx?ID=@cartFeedPageId' + '&redirect=false', 3362 'VoucherTemplate', 'minimal'); 3363 3364 }, 100); 3365 3366 }; 3367 3368 </script> 3369 } 3370 3371 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3372 @using Dynamicweb.Core 3373 @using System 3374 @using System.Web 3375 @using System.Collections.Generic 3376 @using Dynamicweb.Rapido.Blocks 3377 @using Dynamicweb.Rapido.Blocks.Components 3378 @using Dynamicweb.Rapido.Blocks.Components.General 3379 3380 @{ 3381 BlocksPage recurringCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 3382 string recurringCardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 3383 3384 if (!string.IsNullOrWhiteSpace(GetString("Ecom:Order.PaymentMethod.RecurringSupport")) && !Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideRecurringOrder")) 3385 { 3386 Block recurringOrderBlock = new Block() 3387 { 3388 Id = "RecurringOrder", 3389 SortId = 40, 3390 Design = new Design 3391 { 3392 RenderType = RenderType.Column, 3393 Size = "12" 3394 }, 3395 BlocksList = new List<Block> { 3396 new Block { 3397 Id = "RecurringOrderHeader", 3398 SortId = 10, 3399 Component = new Heading { Level = 3, Title = Translate("Recurring order"), Icon = new Icon { Prefix = "fas", Name = "fa-calendar", LabelPosition = IconLabelPosition.After } }, 3400 Design = new Design { 3401 RenderType = RenderType.CardHeader, 3402 CssClass = "u-color-light--bg" 3403 } 3404 }, 3405 new Block { 3406 Id = "RecurringOrderBody", 3407 SortId = 20, 3408 Template = RenderRecurringOrder(), 3409 Design = new Design { 3410 RenderType = RenderType.CardBody, 3411 CssClass = "u-color-light--bg " + recurringCardHeightClass 3412 } 3413 } 3414 } 3415 }; 3416 recurringCheckoutPage.Add("OrderContainerRow", recurringOrderBlock); 3417 } 3418 } 3419 3420 @helper RenderRecurringOrder() { 3421 string dateFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; 3422 string startDate = !string.IsNullOrEmpty(GetString("Ecom:Order.Recurring.StartDate.Clean")) ? GetDate("Ecom:Order.Recurring.StartDate.Clean").ToString(dateFormat) : ""; 3423 string endDate = !string.IsNullOrEmpty(GetString("Ecom:Order.Recurring.EndDate.Clean")) ? GetDate("Ecom:Order.Recurring.EndDate.Clean").ToString(dateFormat) : ""; 3424 dateFormat = dateFormat.Replace("dd", "d"); 3425 dateFormat = dateFormat.Replace("MM", "m"); 3426 dateFormat = dateFormat.Replace("yyyy", "Y"); 3427 string endLabel = Pageview.Device.ToString() != "Mobile" ? Translate("And it should end on") : Translate("End date"); 3428 3429 @Render(new CheckboxField { 3430 Label = Translate("Create recurring order"), 3431 Name = "EcomRecurringOrderCreate", 3432 Id = "EcomRecurringOrderCreate", 3433 Checked = GetBoolean("Ecom:Order.Recurring.Enabled"), 3434 ExtraAttributes = new Dictionary<string, string>() { 3435 { "data-expand", "EcomRecurringOrderCreate" } 3436 } 3437 }) 3438 3439 <div class="expandable--collapsed" data-trigger="EcomRecurringOrderCreate"> 3440 <label for="Country">@Translate("I want my order every")</label> 3441 <div class="grid grid--external-bleed-x"> 3442 <div class="grid__col-6 grid__col--bleed-y"> 3443 @{ 3444 SelectField selectInterval = new SelectField 3445 { 3446 Id = "EcomOrderRecurringInterval", 3447 Name = "EcomOrderRecurringInterval", 3448 OnChange = "Cart.SubmitCart()", 3449 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerState.ErrorMessage") 3450 }; 3451 for (var i = 1; i <= 12; i++) 3452 { 3453 bool selected = GetInteger("Ecom:Order.Recurring.Interval") == i ? true : false; 3454 selectInterval.Options.Add(new SelectFieldOption { Label = i.ToString(), Value = i.ToString(), Checked = selected }); 3455 } 3456 @Render(selectInterval) 3457 } 3458 </div> 3459 <div class="grid__col-6 grid__col--bleed-y"> 3460 @{ 3461 var units = new[] { "Days", "Weeks", "Months" }; 3462 3463 SelectField selectUnit = new SelectField 3464 { 3465 Id = "EcomOrderRecurringIntervalUnit", 3466 Name = "EcomOrderRecurringIntervalUnit", 3467 OnChange = "Cart.SubmitCart()", 3468 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerState.ErrorMessage") 3469 }; 3470 for (int i = 0; i < units.Length; i++) 3471 { 3472 bool selected = GetInteger("Ecom:Order.Recurring.IntervalUnit") == i ? true : false; 3473 selectUnit.Options.Add(new SelectFieldOption { Label = Translate(units[i]), Value = i.ToString(), Checked = selected }); 3474 } 3475 @Render(selectUnit) 3476 } 3477 </div> 3478 </div> 3479 3480 <div class="grid grid--external-bleed-x"> 3481 <div class="grid__col-6 grid__col--bleed-y"> 3482 @Render(new DateTimeField { 3483 Label = Translate("Start date"), 3484 Id = "EcomOrderRecurringStartDate", 3485 Name = "EcomOrderRecurringStartDate", 3486 Placeholder = Translate("Never"), 3487 Value = startDate, 3488 DateFormat = dateFormat, 3489 MinDate = "today" 3490 }) 3491 </div> 3492 <div class="grid__col-6 grid__col--bleed-y"> 3493 @Render(new DateTimeField { 3494 Label = endLabel, 3495 Id = "EcomOrderRecurringEndDate", 3496 Name = "EcomOrderRecurringEndDate", 3497 Placeholder = Translate("Never"), 3498 Value = endDate, 3499 DateFormat = dateFormat, 3500 MinDate = "today" 3501 }) 3502 </div> 3503 </div> 3504 </div> 3505 } 3506 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3507 @using Dynamicweb 3508 @using Dynamicweb.Core 3509 @using System 3510 @using System.Web 3511 @using System.Collections.Generic 3512 @using Dynamicweb.Rapido.Blocks 3513 @using Dynamicweb.Rapido.Blocks.Components 3514 @using Dynamicweb.Rapido.Blocks.Components.General 3515 3516 @functions{ 3517 BlocksPage reviewOrderCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 3518 string cartFeedPageId; 3519 bool canCompleteOrder = true; 3520 } 3521 3522 @{ 3523 string reviewOrderType = checkoutPageType ?? "onestep"; //The "checkoutPageType" comes from the main template for the cart page 3524 3525 cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 3526 3527 if (!String.IsNullOrWhiteSpace(GetString("Ecom:OrderContext.ID"))) 3528 { 3529 cartFeedPageId += "&OrderContext=" + GetString("Ecom:OrderContext.ID"); 3530 } 3531 3532 3533 var paymentCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 3534 var shippingCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 3535 var paymentCountryIsSupported = string.IsNullOrEmpty(paymentCountryCode) || GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == paymentCountryCode)); 3536 var shippingCountryIsSupported = string.IsNullOrEmpty(shippingCountryCode) ? paymentCountryIsSupported : GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == shippingCountryCode)); 3537 3538 canCompleteOrder = paymentCountryIsSupported && shippingCountryIsSupported; 3539 3540 Block reviewOrderBlock = new Block() 3541 { 3542 Id = "ReviewOrder", 3543 SortId = 50, 3544 SkipRenderBlocksList = true, 3545 Template = RenderReviewOrder() 3546 }; 3547 reviewOrderCheckoutPage.Add("OrderContainerRow", reviewOrderBlock); 3548 3549 if (reviewOrderType == "onestep") 3550 { 3551 Block inlineAcceptanceBlock = new Block() 3552 { 3553 Id = "Acceptance", 3554 SortId = 10, 3555 Template = RenderInlineAcceptance() 3556 }; 3557 reviewOrderCheckoutPage.Add("ReviewOrder", inlineAcceptanceBlock); 3558 3559 Block reviewOrderFooterBlock = new Block() 3560 { 3561 Id = "ReviewOrderFooter", 3562 SortId = 20, 3563 Template = RenderReviewOrderFooter() 3564 }; 3565 reviewOrderCheckoutPage.Add("ReviewOrder", reviewOrderFooterBlock); 3566 } 3567 3568 if (reviewOrderType == "quote") 3569 { 3570 Block reviewOrderFooterBlock = new Block() 3571 { 3572 Id = "ReviewOrderFooter", 3573 SortId = 20, 3574 Template = RenderReviewOrderFooterQuote() 3575 }; 3576 reviewOrderCheckoutPage.Add("ReviewOrder", reviewOrderFooterBlock); 3577 } 3578 3579 Block reviewOrderScriptTemplates = new Block() 3580 { 3581 Id = "ReviewOrderScriptTempaltes", 3582 SortId = 30, 3583 BlocksList = new List<Block> { 3584 new Block { 3585 Id = "CartContentTemplate", 3586 SortId = 10, 3587 Template = RenderCartContentTemplate() 3588 }, 3589 new Block { 3590 Id = "CartOrderlineTemplate", 3591 SortId = 20, 3592 Template = RenderCartOrderlineTemplate() 3593 }, 3594 new Block { 3595 Id = "CartOrderlineMobileTemplate", 3596 SortId = 30, 3597 Template = RenderCartOrderlineMobileTemplate() 3598 }, 3599 new Block { 3600 Id = "CartOrderlineDiscountTemplate", 3601 SortId = 40, 3602 Template = RenderCartOrderlineDiscountTemplate() 3603 }, 3604 new Block { 3605 Id = "EmptyCartTemplate", 3606 SortId = 50, 3607 Template = RenderEmptyCartTemplate() 3608 }, 3609 new Block 3610 { 3611 Id = "EmptyCartObserver", 3612 SortId = 60, 3613 Template = RenderEmptyCartObserver() 3614 } 3615 } 3616 }; 3617 reviewOrderCheckoutPage.Add("CheckoutBottomSnippets", reviewOrderScriptTemplates); 3618 3619 Block reviewOrderScripts = new Block() 3620 { 3621 Id = "ReviewOrderScripts", 3622 SortId = 40, 3623 Template = RenderOrderScripts() 3624 }; 3625 reviewOrderCheckoutPage.Add("CheckoutBottomSnippets", reviewOrderScripts); 3626 } 3627 3628 @helper RenderReviewOrder() 3629 { 3630 <div class="grid__col-12"> 3631 <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> 3632 </div> 3633 } 3634 3635 @helper RenderCartContentTemplate() 3636 { 3637 List<Block> subBlocks = reviewOrderCheckoutPage.GetBlockListById("ReviewOrder").OrderBy(item => item.SortId).ToList(); 3638 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3639 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 3640 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(GetString("Ecom:Order.ID")); 3641 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 3642 3643 <script id="CartContent" type="text/x-template"> 3644 {{#.}} 3645 @if (useGoogleTagManager) 3646 { 3647 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text> 3648 } 3649 <div class="card-header u-color-light--bg dw-mod"> 3650 @Render(new Heading { Title = Translate("Review order") + "({{numberofproducts}})", Level = 3, Icon = new Icon { Prefix = "fas", Name = "fa-list-ul", LabelPosition = IconLabelPosition.After } }) 3651 </div> 3652 <div class="card u-color-light--bg u-no-padding--xs dw-mod"> 3653 {{#unless isEmpty}} 3654 <table class="table cart-table dw-mod"> 3655 <tbody id="OrderLines"> 3656 {{#OrderLines}} 3657 {{> (lookup . 'template') }} 3658 {{/OrderLines}} 3659 </tbody> 3660 </table> 3661 {{/unless}} 3662 <div class="grid u-border-top"> 3663 <div class="grid__col-sm-6"> 3664 @if (Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 3665 { 3666 <text> 3667 {{#if userPoints}} 3668 <div class="u-border u-border-color--loyalty-points u-padding--lg u-full-height"> 3669 @Render(new Heading { Title = Translate("Your point balance"), Level = 3 }) 3670 <div class="u-font-size--lg u-margin-bottom"> 3671 <span class="u-color--loyalty-points">{{userPoints}}</span> @Translate("points") 3672 </div> 3673 <div>@Translate("On this order you will use"): <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")</div> 3674 </div> 3675 {{/if}} 3676 </text> 3677 } 3678 </div> 3679 3680 <div class="grid__col-sm-6"> 3681 @if (!pointShop) 3682 { 3683 <text> 3684 {{#unless hideSubTotal}} 3685 <div> 3686 <div class="cart-summary__subtotals dw-mod">@Translate("Subtotal")</div> 3687 <div class="cart-summary__subtotals u-pull--right dw-mod"> 3688 @if (hasTaxSettings) 3689 { 3690 <text>{{subtotalpricewithouttaxes}}</text> 3691 } 3692 else 3693 { 3694 <text>{{subtotalprice}}</text> 3695 } 3696 </div> 3697 </div> 3698 {{/unless}} 3699 </text> 3700 <text> 3701 {{#unless hidePaymentfee}} 3702 <div> 3703 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-credit-card", Label = "{{paymentmethod}}", LabelPosition = IconLabelPosition.After })</div> 3704 <div class="cart-summary__info u-pull--right dw-mod">{{paymentfee}}</div> 3705 </div> 3706 {{/unless}} 3707 </text> 3708 } 3709 {{#unless hideShippingfee}} 3710 <div> 3711 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-truck", Label = "{{shippingmethod}}", LabelPosition = IconLabelPosition.After })</div> 3712 <div class="cart-summary__info u-pull--right dw-mod">{{shippingfee}}</div> 3713 </div> 3714 {{/unless}} 3715 {{#if hasTaxSettings}} 3716 <div> 3717 <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> 3718 <div class="cart-summary__info u-pull--right dw-mod">{{totaltaxes}}</div> 3719 </div> 3720 {{/if}} 3721 @if (Pageview.User != null && Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints")) 3722 { 3723 <text> 3724 {{#if earnings}} 3725 <div> 3726 <div class="cart-summary__info dw-mod">@Translate("Earnings")</div> 3727 <div class="cart-summary__info u-pull--right dw-mod"><span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")</div> 3728 </div> 3729 {{/if}} 3730 </text> 3731 } 3732 <div class="cart-summary__totals-container dw-mod"> 3733 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 3734 <div class="cart-summary__totals u-pull--right dw-mod"> 3735 @if (pointShop) 3736 { 3737 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points") 3738 } 3739 else 3740 { 3741 <text>{{totalprice}}</text> 3742 } 3743 </div> 3744 </div> 3745 @if (!pointShop && !hasTaxSettings) 3746 { 3747 <div class="u-ta-right"> 3748 <small class="cart-summary__info dw-mod">@Translate("VAT"):</small> 3749 <small class="cart-summary__info dw-mod">{{totalvat}}</small> 3750 </div> 3751 3752 if (isPricesWithVATEnabled) 3753 { 3754 <div class="u-ta-right"> 3755 <small class="cart-summary__info dw-mod">@Translate("Total price without VAT"):</small> 3756 <small class="cart-summary__info dw-mod">{{totalPriceWithoutVat}}</small> 3757 </div> 3758 } 3759 else 3760 { 3761 <div class="u-ta-right"> 3762 <small class="cart-summary__info dw-mod">@Translate("Total price with VAT"):</small> 3763 <small class="cart-summary__info dw-mod">{{totalPriceWithVat}}</small> 3764 </div> 3765 } 3766 } 3767 {{#if showCheckoutDisclaimer}} 3768 <div class="u-ta-right"> 3769 <small>{{checkoutDisclaimer}}</small> 3770 </div> 3771 {{/if}} 3772 </div> 3773 </div> 3774 3775 <div class="grid"> 3776 <div class="grid__col-12 grid__col--line-top"></div> 3777 </div> 3778 3779 {{#unless hideComment}} 3780 <div class="grid__cell u-padding--xs"> 3781 @Render(new TextareaField { Rows = 3, Placeholder = Translate("Enter comment"), Name = "EcomOrderCustomerComment", Id = "EcomOrderCustomerComment", Value = "{{comment}}" }) 3782 </div> 3783 {{/unless}} 3784 <div class="u-margin-bottom--lg"> 3785 @foreach (LoopItem error in GetLoop("ValidationErrors")) 3786 { 3787 @Render(new NotificationMessage { Message = error.GetString("Ecom:Cart.ValidationError.ErrorMessage"), MessageType = NotificationMessageType.Error }) 3788 } 3789 </div> 3790 3791 @RenderBlockList(subBlocks) 3792 </div> 3793 {{/.}} 3794 </script> 3795 } 3796 3797 @helper RenderCartOrderlineTemplate() 3798 { 3799 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3800 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 3801 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 3802 3803 @* Template for the orderlines *@ 3804 <script id="CartOrderline" type="text/x-template"> 3805 {{#unless isEmpty}} 3806 <tr id="Orderline{{id}}" class="cart-orderline"> 3807 <td class="cart-orderline__cell cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 3808 <div class="cart-orderline__cell__block {{hideimage}} dw-mod"> 3809 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 3810 </div> 3811 </td> 3812 <td class="cart-orderline__cell u-va-middle dw-mod" title="{{name}} {{variantname}}"> 3813 <a href="{{link}}" class="u-color-inherit cart-orderline__name">{{name}}</a> 3814 {{#if productnumber}} 3815 <div class="cart-orderline__cell__block item-number dw-mod">#{{productnumber}}</div> 3816 {{/if}} 3817 {{#if variantname}} 3818 <div class="cart-orderline__cell__block item-number dw-mod">{{variantname}}</div> 3819 {{/if}} 3820 {{#if unitname}} 3821 <div class="cart-orderline__cell__block item-number dw-mod">{{unitname}}</div> 3822 {{/if}} 3823 </td> 3824 <td class="cart-orderline__cell u-ta-right u-hidden-xs u-hidden-xxs dw-mod" width="120"> 3825 {{#if pointsTotal}} 3826 <span class="u-color--loyalty-points">{{pointPrice}}</span> @Translate("points") 3827 {{else}} 3828 {{unitprice}} 3829 {{/if}} 3830 </td> 3831 3832 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 3833 { 3834 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 3835 @Render(new NumberField 3836 { 3837 Id = "Quantity_{{orderLineId}}", 3838 Min = 1, 3839 OnChange = "Cart.ChangeQuantity('" + cartFeedPageId + "', '{{orderLineId}}', this.value)", 3840 Name = "QuantityOrderLine{{orderLineId}}", 3841 Value = "{{quantity}}", 3842 CssClass = "u-w80px", 3843 ActionButton = new Button 3844 { 3845 ButtonType = ButtonType.Button, 3846 ButtonLayout = ButtonLayout.Clean, 3847 OnClick = "{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}} Cart.UpdateCart(null, '/Default.aspx?ID=" + cartFeedPageId + "', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);", 3848 Icon = new Icon { Prefix = "fas", Name = "fa-times", LabelPosition = IconLabelPosition.After } 3849 } 3850 }) 3851 </td> 3852 } 3853 else 3854 { 3855 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 3856 @Render(new HiddenField { Id = "Quantity_{{orderLineId}}", Name = "QuantityOrderLine{{orderLineId}}", Value = "{{quantity}}" }) 3857 <div class="u-w80px u-no-margin">{{quantity}}</div> 3858 </td> 3859 } 3860 3861 <td class="cart-orderline__cell u-ta-right dw-mod"> 3862 {{#if pointsTotal}} 3863 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 3864 {{else}} 3865 <div>{{totalprice}}</div> 3866 {{/if}} 3867 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 3868 { 3869 <text> 3870 {{#if canBePurchasedWithPoints}} 3871 @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 } }) 3872 {{/if}} 3873 </text> 3874 } 3875 </td> 3876 </tr> 3877 {{/unless}} 3878 <tr class="{{hideBomItems}}"> 3879 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"><div class="{{hideimage}}"></div></td> 3880 <td colspan="5" class="u-no-padding"> 3881 <table class="u-no-margin u-color-light-gray--bg"> 3882 <tbody> 3883 {{#BomItems}} 3884 <tr> 3885 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 3886 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 3887 </td> 3888 <td title="{{name}} {{variantname}}"> 3889 <a href="{{link}}" class="u-color-inherit dw-mod">{{name}}</a> 3890 {{#if productnumber}} 3891 <div class="item-number dw-mod">#{{productnumber}}</div> 3892 {{/if}} 3893 {{#if variantname}} 3894 <div class="item-number dw-mod">{{variantname}}</div> 3895 {{/if}} 3896 {{#if unitname}} 3897 <div class="item-number dw-mod">{{unitname}}</div> 3898 {{/if}} 3899 </td> 3900 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 3901 <td>{{quantity}}</td> 3902 <td>&nbsp;</td> 3903 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 3904 </tr> 3905 {{/BomItems}} 3906 </tbody> 3907 </table> 3908 </td> 3909 </tr> 3910 </script> 3911 } 3912 3913 @helper RenderCartOrderlineMobileTemplate() 3914 { 3915 <script id="CartOrderlineMobile" type="text/x-template"> 3916 {{#unless isEmpty}} 3917 <tr id="Orderline{{id}}"> 3918 <td class="cart-table__image dw-mod"> 3919 <div class="{{hideimage}}"> 3920 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 3921 </div> 3922 </td> 3923 <td title="{{name}} {{variantname}}" colspan="4"> 3924 <a href="{{link}}" class="u-color-inherit">{{name}}</a> 3925 {{#if productnumber}} 3926 <div>#{{productnumber}}</div> 3927 {{/if}} 3928 {{#if variantname}} 3929 <div>{{variantname}}</div> 3930 {{/if}} 3931 {{#if unitname}} 3932 <div>{{unitname}}</div> 3933 {{/if}} 3934 </td> 3935 </tr> 3936 <tr class="table__row--no-border"> 3937 <td class="cart-table__image dw-mod"></td> 3938 <td colspan="4"> 3939 <div class="u-pull--left"> 3940 @Render(new NumberField 3941 { 3942 Id = "Quantity_{{orderLineId}}", 3943 Min = 1, 3944 OnChange = "Cart.ChangeQuantity('" + cartFeedPageId + "', '{{orderLineId}}', this.value)", 3945 Name = "QuantityOrderLine{{orderLineId}}", 3946 Value = "{{quantity}}", 3947 CssClass = "u-w80px", 3948 ActionButton = new Button 3949 { 3950 ButtonType = ButtonType.Button, 3951 ButtonLayout = ButtonLayout.Clean, 3952 OnClick = "{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}} Cart.UpdateCart(null, '/Default.aspx?ID=" + cartFeedPageId + "', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);", 3953 Icon = new Icon { Prefix = "fas", Name = "fa-times", LabelPosition = IconLabelPosition.After } 3954 } 3955 }) 3956 </div> 3957 <div class="u-pull--right u-ta-right"> 3958 {{#if pointsTotal}} 3959 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 3960 {{else}} 3961 <div>{{totalprice}}</div> 3962 {{/if}} 3963 {{#if canBePurchasedWithPoints}} 3964 @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 } }) 3965 {{/if}} 3966 </div> 3967 </td> 3968 </tr> 3969 {{/unless}} 3970 <tr class="{{hideBomItems}}"> 3971 <td colspan="6" class="u-no-padding"> 3972 <table class="u-no-margin u-color-light-gray--bg"> 3973 <tbody> 3974 {{#BomItems}} 3975 <tr> 3976 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 3977 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 3978 </td> 3979 <td title="{{name}} {{variantname}}"> 3980 <a href="{{link}}" title="{{name}} {{variantname}}">{{name}}</a> 3981 {{#if productnumber}} 3982 <div>#{{productnumber}}</div> 3983 {{/if}} 3984 {{#if variantname}} 3985 <div>{{variantname}}</div> 3986 {{/if}} 3987 {{#if unitname}} 3988 <div>{{unitname}}</div> 3989 {{/if}} 3990 </td> 3991 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 3992 <td>{{quantity}}</td> 3993 <td>&nbsp;</td> 3994 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 3995 </tr> 3996 {{/BomItems}} 3997 </tbody> 3998 </table> 3999 </td> 4000 </tr> 4001 </script> 4002 } 4003 4004 @helper RenderCartOrderlineDiscountTemplate() 4005 { 4006 <script id="CartOrderlineDiscount" type="text/x-template"> 4007 <tr class="table__row--no-border"> 4008 <td class="cart-table__image dw-mod">&nbsp;</td> 4009 <td colspan="3">{{name}}</td> 4010 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 4011 <td class="cart-table__price u-ta-right dw-mod">{{totalprice}}</td> 4012 </tr> 4013 </script> 4014 } 4015 4016 @helper RenderEmptyCartTemplate() 4017 { 4018 <script id="EmptyCart" type="text/x-template"> 4019 @Translate("You have no items in the cart") 4020 </script> 4021 } 4022 4023 @helper RenderInlineAcceptance() 4024 { 4025 <div class="grid__cell u-padding--xs"> 4026 @if (GetBoolean("Ecom:Cart.UseNewsletterSubscription")) 4027 { 4028 @Render(new HiddenField { Name = "EcomOrderSubscribeToNewsletter" }) 4029 @Render(new CheckboxField { Name = "EcomOrderSubscribeToNewsletter", Id = "EcomOrderSubscribeToNewsletter", Label = Translate("Subscribe to newsletter") }) 4030 } 4031 4032 @if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions")) 4033 { 4034 @Render(new HiddenField { Name = "EcomOrderCustomerAccepted", Id = "EcomOrderCustomerAccepted", Value = "1" }) 4035 } 4036 else 4037 { 4038 string termsPageIt = GetPageIdByNavigationTag("TermsAndConditions").ToString(); 4039 @Render(new CheckboxField 4040 { 4041 Name = "EcomOrderCustomerAccepted", 4042 Id = "EcomOrderCustomerAccepted", 4043 OnChange = canCompleteOrder ? "Cart.EnableCheckoutButton()" : "", 4044 Label = Translate("I accept the") + " <a href=\"/Default.aspx?ID=" + termsPageIt + "\">" + Translate("terms and conditions") + "</a>", 4045 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerAccepted.ErrorMessage") 4046 }) 4047 } 4048 </div> 4049 } 4050 4051 @helper RenderReviewOrderFooter() 4052 { 4053 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 4054 4055 <div class="grid"> 4056 <div class="grid__col-12 grid__col--line-top"></div> 4057 </div> 4058 4059 <div class="grid__cell-footer"> 4060 <div class="grid__cell u-padding--xs"> 4061 <div class="u-pull--right"> 4062 @Render(new Button 4063 { 4064 ButtonType = ButtonType.Submit, 4065 ButtonLayout = ButtonLayout.Primary, 4066 CssClass = "btn--condensed u-pull--right u-no-margin", 4067 Title = Translate("Go to checkout"), 4068 Id = GetString("CartV2.NextStepButtonName"), 4069 OnClick = "Buttons.LockButton(event, true)", 4070 Disabled = !canCompleteOrder || !Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions"), 4071 Name = GetString("CartV2.NextStepButtonName") 4072 }) 4073 </div> 4074 <div class="u-pull--left"> 4075 @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);" }) 4076 </div> 4077 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 4078 { 4079 <div class="u-pull--right"> 4080 @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") }) 4081 </div> 4082 } 4083 </div> 4084 </div> 4085 } 4086 4087 @helper RenderReviewOrderFooterQuote() 4088 { 4089 string submitButtonTitle = Pageview.Device.ToString() == "Mobile" ? Translate("Submit") : Translate("Submit quote request"); 4090 4091 <div class="grid"> 4092 <div class="grid__col-12 grid__col--line-top"></div> 4093 </div> 4094 4095 <div class="grid__cell-footer"> 4096 <div class="grid__cell u-padding--xs"> 4097 <div class="u-pull--right"> 4098 @Render(new Button 4099 { 4100 ButtonType = ButtonType.Submit, 4101 ButtonLayout = ButtonLayout.Primary, 4102 CssClass = "btn--condensed u-pull--right u-no-margin", 4103 Title = submitButtonTitle, 4104 Id = GetString("CartV2.NextStepButtonName"), 4105 OnClick = "Buttons.LockButton(event, true)", 4106 Name = GetString("CartV2.NextStepButtonName") 4107 }) 4108 </div> 4109 <div class="u-pull--left"> 4110 @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") }) 4111 </div> 4112 </div> 4113 </div> 4114 } 4115 4116 @helper RenderOrderScripts() 4117 { 4118 if (!string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID"))) 4119 { 4120 <script> 4121 fbq('track', 'InitiateCheckout', { 4122 currency: '@GetString("Ecom:Order.Price.Currency.Code")', 4123 value: @GetDouble("Ecom:Order.Price.Price"), 4124 num_items: "@GetInteger("Ecom:Order.OrderLines.TotalProductQuantity")" 4125 }); 4126 </script> 4127 } 4128 } 4129 4130 @helper RenderEmptyCartObserver() 4131 { 4132 <script> 4133 document.addEventListener("cartUpdated", function(event) { 4134 let data = event.detail.data[0]; 4135 if (data.numberofproducts == 0) { 4136 location.reload(); 4137 } else { 4138 HandlebarsBolt.CreateItemsFromJson(data, "Cart"); 4139 } 4140 }); 4141 </script> 4142 } 4143 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4144 @using Dynamicweb.Core 4145 @using System 4146 @using System.Web 4147 @using System.Collections.Generic 4148 @using Dynamicweb.Rapido.Blocks 4149 @using Dynamicweb.Ecommerce.Orders 4150 4151 @{ 4152 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 4153 4154 BlocksPage googleImpressionsPage = BlocksPage.GetBlockPage("CheckoutPage"); 4155 4156 Block googleImpressionsBlock = new Block() 4157 { 4158 Id = "GoogleImpressionsBlock", 4159 SortId = 10, 4160 Template = RenderScript() 4161 }; 4162 4163 if (useGoogleTagManager) 4164 { 4165 googleImpressionsPage.Add("CheckoutBottomSnippets", googleImpressionsBlock); 4166 } 4167 } 4168 4169 @helper RenderScript() 4170 { 4171 var currentStep = 1; 4172 4173 foreach (LoopItem step in GetLoop("StepButtons")) 4174 { 4175 if (step.GetBoolean("Step.Current")) 4176 { 4177 currentStep = step.GetInteger("Step.Number"); 4178 break; 4179 } 4180 } 4181 <script> 4182 dataLayer.push({ 4183 "event": "checkout", 4184 "ecommerce": { 4185 "currencyCode": "@Dynamicweb.Ecommerce.Services.Currencies.GetDefaultCurrency().Code", 4186 "checkout": { 4187 "actionField": {"step": @currentStep}, 4188 "products": [ 4189 @foreach (LoopItem orderline in GetLoop("OrderLines").Where(o => o.GetBoolean("Ecom:Order:OrderLine.IsProduct") == true).ToList()) 4190 { 4191 var groupObject = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(orderline.GetString("Ecom:Product.PrimaryOrFirstGroupID")); 4192 <text> 4193 { 4194 "name": "@orderline.GetString("Ecom:Order:OrderLine.ProductName")", 4195 "id": "@orderline.GetString("Ecom:Product.ID")", 4196 "price": "@orderline.GetDouble("Ecom:Order:OrderLine.UnitPrice.Price")", 4197 "brand": "@orderline.GetString("Ecom:Product:Field.brand.Value")", 4198 "category": "@(groupObject != null ? groupObject.Name : "")", 4199 "variant": "@orderline.GetString("Ecom:Order:OrderLine.ProductVariantID")", 4200 "quantity": @orderline.GetInteger("Ecom:Order:OrderLine.Quantity") 4201 }, 4202 </text> 4203 } 4204 ] 4205 } 4206 } 4207 }); 4208 </script> 4209 } 4210 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4211 @using Dynamicweb.Core 4212 @using System 4213 @using System.Web 4214 @using System.Collections.Generic 4215 @using Dynamicweb.Rapido.Blocks 4216 4217 @{ 4218 BlocksPage snippetsCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 4219 4220 snippetsCheckoutPage.Add("CheckoutBottomSnippets", new Block 4221 { 4222 Id = "CartAddressesJavascript", 4223 SortId = 50, 4224 Template = RenderCartAddressesJavascript() 4225 }); 4226 } 4227 4228 @helper RenderCartAddressesJavascript() 4229 { 4230 <script> 4231 function resetStateField(stateFieldId) { 4232 let stateField = document.getElementById(stateFieldId); 4233 if (stateField) { 4234 stateField.value = ""; 4235 let disabledOption = stateField.querySelector("option:checked"); 4236 if (disabledOption) { 4237 disabledOption.disabled = false; 4238 disabledOption.removeAttribute("disabled"); 4239 } 4240 } 4241 } 4242 4243 document.addEventListener("DOMContentLoaded", function () { 4244 regionLabels.InitDictionary({ 4245 "CA": "@Translate("Province")", 4246 "US": "@Translate("State")" 4247 }); 4248 regionLabels.LocalizeRegionLabels("EcomOrderCustomerRegion", "EcomOrderCustomerCountry"); 4249 regionLabels.LocalizeRegionLabels("EcomOrderDeliveryRegion", "EcomOrderDeliveryCountry"); 4250 }); 4251 </script> 4252 } 4253 4254 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4255 @using Dynamicweb.Core 4256 @using System 4257 @using System.Web 4258 @using System.Collections.Generic 4259 @using Dynamicweb.Rapido.Blocks 4260 4261 @{ 4262 var DistributorOrderRouter = GetString("DistributorOrderRouter"); 4263 } 4264 4265 @{ 4266 BlocksPage customBlocksPage = BlocksPage.GetBlockPage("CheckoutPage"); 4267 Block CustomOrderline = new Block() 4268 { 4269 Id = "CartOrderlineTemplate", 4270 SortId = 20, 4271 Template = RenderCartOrderlineTemplateCustom() 4272 }; 4273 customBlocksPage.ReplaceBlock(CustomOrderline); 4274 4275 var ShippingAddressBody = customBlocksPage.GetBlockById("ShippingAddressBody"); 4276 if (ShippingAddressBody != null) 4277 { 4278 if (checkoutPageType != "multistep") 4279 { 4280 4281 Block CommentCustom = new Block() 4282 { 4283 Id = "CommentTemplate", 4284 SortId = 50, 4285 Template = RenderCartComment() 4286 }; 4287 4288 4289 customBlocksPage.Add("ShippingAddressBody", CommentCustom); 4290 } 4291 if (checkoutPageType == "multistep") 4292 { 4293 if (GetString("CartV2.CurrentStepButtonName") == "CartV2.GotoStep1") 4294 { 4295 Block CommentCustom = new Block() 4296 { 4297 Id = "CommentTemplate", 4298 SortId = 50, 4299 Template = RenderCartComment() 4300 }; 4301 customBlocksPage.Add("ShippingAddressBody", CommentCustom); 4302 } 4303 4304 } 4305 4306 } 4307 4308 4309 Block CustomContent = new Block() 4310 { 4311 Id = "CartContentTemplate", 4312 SortId = 20, 4313 Template = RenderCartContentTemplateCustom() 4314 }; 4315 customBlocksPage.ReplaceBlock(CustomContent); 4316 4317 4318 4319 4320 Block CustomDiscount = new Block() 4321 { 4322 Id = "CartOrderlineDiscountTemplate", 4323 SortId = 20, 4324 Template = RenderCartOrderlineDiscountTemplateCustom() 4325 }; 4326 customBlocksPage.ReplaceBlock(CustomDiscount); 4327 4328 Block acceptanceBlockCustom = new Block() 4329 { 4330 Id = "Acceptance", 4331 SortId = 10, 4332 Design = new Design 4333 { 4334 RenderType = RenderType.Column, 4335 Size = "12" 4336 }, 4337 BlocksList = new List<Block> 4338 { 4339 new Block { 4340 Id = "AcceptanceBody", 4341 SortId = 10, 4342 Template = RenderAcceptanceCustom() 4343 } 4344 } 4345 }; 4346 customBlocksPage.ReplaceBlock(acceptanceBlockCustom); 4347 4348 Block reviewOrderFooterBlockCustom = new Block() 4349 { 4350 Id = "ReviewOrderFooter", 4351 SortId = 20, 4352 Template = RenderReviewOrderFooterCustom() 4353 }; 4354 customBlocksPage.ReplaceBlock(reviewOrderFooterBlockCustom); 4355 if (checkoutPageType == "quote") 4356 { 4357 Block reviewOrderFooterBlockCustomQuote = new Block() 4358 { 4359 Id = "ReviewOrderFooter", 4360 SortId = 20, 4361 Template = RenderReviewOrderFooterQuoteCustom() 4362 }; 4363 customBlocksPage.ReplaceBlock(reviewOrderFooterBlockCustomQuote); 4364 } 4365 4366 4367 } 4368 4369 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4370 @using Dynamicweb 4371 @using Dynamicweb.Core 4372 @using System.Collections; 4373 @using System 4374 @using System.Web 4375 @using System.Linq; 4376 @using System.Collections.Generic 4377 @using Dynamicweb.Rapido.Blocks 4378 @using Dynamicweb.Rapido.Blocks.Components 4379 @using Dynamicweb.Rapido.Blocks.Components.General 4380 4381 @helper RenderCartOrderlineTemplateCustom() 4382 { 4383 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 4384 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 4385 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 4386 string pageUrlN = GetPageIdByNavigationTag("GetUserInfo").ToString(); 4387 string feedFullUrlN = "Default.aspx?ID=" + pageUrlN; 4388 var userCode = GetString("UserManagement:User.Item.Code"); 4389 var errorLoopCount = GetLoop("ValidationErrors").Where(x => x.GetString("Ecom:Cart.ValidationError.FieldName") == "OrderlineError").Count(); 4390 DateTime userExpireDate = GetDate("UserManagement:User.Item.CodeExpire"); 4391 var exDate = userExpireDate.ToString("yyyy-MM-dd"); 4392 var date = GetGlobalValue("Global:Server.Date.GeneralDate"); 4393 DateTime dt = Convert.ToDateTime(date); 4394 var currentday = dt.ToString("yyyy-MM-dd"); 4395 var currentUser = GetInteger("UserManagement:User.ID").ToString(); 4396 string cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 4397 if (!string.IsNullOrWhiteSpace(GetString("Ecom:OrderContext.ID"))) 4398 { 4399 cartFeedPageIdCustom += "&OrderContext=" + GetString("Ecom:OrderContext.ID"); 4400 } 4401 4402 @* Template for the orderlines *@ 4403 4404 <script id="CartOrderline" type="text/x-template"> 4405 4406 {{#unless isEmpty}} 4407 <tr id="Orderline{{id}}" class="cart-orderline"> 4408 <td class="cart-orderline__cell cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 4409 <div class="cart-orderline__cell__block {{hideimage}} dw-mod"> 4410 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 4411 </div> 4412 </td> 4413 <td class="cart-orderline__cell u-va-middle dw-mod" title="{{name}} {{variantname}}"> 4414 <a href="{{link}}" class="u-color-inherit cart-orderline__name">{{name}}</a> 4415 {{#if productnumber}} 4416 <div class="cart-orderline__cell__block item-number dw-mod">#{{productnumber}}</div> 4417 {{/if}} 4418 {{#if variantname}} 4419 <div class="cart-orderline__cell__block item-number dw-mod">{{variantname}}</div> 4420 {{/if}} 4421 {{#if unitname}} 4422 <div class="cart-orderline__cell__block item-number dw-mod">{{unitname}}</div> 4423 {{/if}} 4424 4425 4426 </td> 4427 <td class="cart-orderline__cell u-ta-right u-hidden-xs u-hidden-xxs dw-mod" width="120"> 4428 {{#if pointsTotal}} 4429 <span class="u-color--loyalty-points">{{pointPrice}}</span> @Translate("points") 4430 {{else}} 4431 {{unitprice}} 4432 {{/if}} 4433 </td> 4434 4435 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 4436 { 4437 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 4438 @Render(new NumberField 4439 { 4440 Id = "Quantity_{{orderLineId}}", 4441 Min = 1, 4442 OnChange = "Cart.ChangeQuantity('" + cartFeedPageIdCustom + "', '{{orderLineId}}', this.value)", 4443 Name = "QuantityOrderLine{{orderLineId}}", 4444 Value = "{{quantity}}", 4445 CssClass = "u-w80px", 4446 ActionButton = new Button 4447 { 4448 ButtonType = ButtonType.Button, 4449 ButtonLayout = ButtonLayout.Clean, 4450 OnClick = "{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}} Cart.UpdateCart(null, '/Default.aspx?ID=" + cartFeedPageIdCustom + "', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);", 4451 Icon = new Icon { Prefix = "fas", Name = "fa-times", LabelPosition = IconLabelPosition.After } 4452 } 4453 }) 4454 </td> 4455 } 4456 else 4457 { 4458 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 4459 @Render(new HiddenField { Id = "Quantity_{{orderLineId}}", Name = "QuantityOrderLine{{orderLineId}}", Value = "{{quantity}}" }) 4460 <div class="u-w80px u-no-margin">{{quantity}}</div> 4461 </td> 4462 } 4463 4464 <td class="cart-orderline__cell u-ta-right dw-mod"> 4465 {{#if pointsTotal}} 4466 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 4467 {{else}} 4468 <div>{{totalprice}}</div> 4469 {{/if}} 4470 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 4471 { 4472 <text> 4473 {{#if canBePurchasedWithPoints}} 4474 @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 } }) 4475 {{/if}} 4476 </text> 4477 } 4478 </td> 4479 </tr> 4480 {{/unless}} 4481 <tr class="{{hideBomItems}}"> 4482 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"><div class="{{hideimage}}"></div></td> 4483 <td colspan="5" class="u-no-padding"> 4484 <table class="u-no-margin u-color-light-gray--bg"> 4485 <tbody> 4486 {{#BomItems}} 4487 <tr> 4488 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 4489 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 4490 </td> 4491 <td title="{{name}} {{variantname}}"> 4492 <a href="{{link}}" class="u-color-inherit dw-mod">{{name}}</a> 4493 {{#if productnumber}} 4494 <div class="item-number dw-mod">#{{productnumber}}</div> 4495 {{/if}} 4496 {{#if variantname}} 4497 <div class="item-number dw-mod">{{variantname}}</div> 4498 {{/if}} 4499 {{#if unitname}} 4500 <div class="item-number dw-mod">{{unitname}}</div> 4501 {{/if}} 4502 </td> 4503 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 4504 <td>{{quantity}}</td> 4505 <td>&nbsp;</td> 4506 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 4507 </tr> 4508 {{/BomItems}} 4509 </tbody> 4510 </table> 4511 </td> 4512 </tr> 4513 </script> 4514 4515 } 4516 @helper RenderCartContentTemplateCustom() 4517 { 4518 BlocksPage customBlocksPageOrder = BlocksPage.GetBlockPage("CheckoutPage"); 4519 List<Block> subBlocksCustom = customBlocksPageOrder.GetBlockListById("ReviewOrder").OrderBy(item => item.SortId).ToList(); 4520 4521 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 4522 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 4523 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(GetString("Ecom:Order.ID")); 4524 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 4525 int cartFeedPageIdCustom; 4526 cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed"); 4527 4528 <script id="CartContent" type="text/x-template"> 4529 4530 {{#.}} 4531 @if (useGoogleTagManager) 4532 { 4533 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text> 4534 } 4535 4536 <div class="card-header u-color-light--bg dw-mod"> 4537 @Render(new Heading { Title = Translate("Review order") + "({{numberofproducts}})", Level = 3, Icon = new Icon { Prefix = "fas", Name = "fa-list-ul", LabelPosition = IconLabelPosition.After } }) 4538 </div> 4539 4540 <div class="card u-color-light--bg u-no-padding--xs dw-mod"> 4541 4542 {{#unless orderIsAuthenticatedClean}} 4543 <input type="text" id="OrderIsAuthenticated" name="OrderIsAuthenticated" value="no" style="display:none"> 4544 <input type="checkbox" id="isAuthenticated" name="OrderIsAuthenticated" style="display:none"> 4545 {{else}} 4546 <input type="text" id="OrderIsAuthenticated" name="OrderIsAuthenticated" value="yes" style="display:none"> 4547 <input type="checkbox" id="isAuthenticated" checked="checked" name="OrderIsAuthenticated" style="display:none"> 4548 {{/unless}} 4549 {{#unless isEmpty}} 4550 {{#unless notRequireAuthorization}} 4551 {{#unless orderIsAuthenticatedClean}} 4552 <div class="grid "> 4553 <div class="grid__col-xs-12 grid__col-sm-6 autorization-code"> 4554 <div class="alert-box u-color-danger txt-small u-margin-bottom">{{orderIsAuthenticatedError}}</div> 4555 <input id="{{AuthorizationCodeName}}" name="{{AuthorizationCodeName}}" class="u-full-width dw-mod" value="{{AuthorizationCode}}" placeholder=" @Translate("Enter your code")"/> 4556 </div> 4557 </div> 4558 {{/unless}} 4559 {{/unless}} 4560 <table class="table cart-table dw-mod"> 4561 <tbody id="OrderLines"> 4562 {{#OrderLines}} 4563 {{> (lookup . 'template') }} 4564 {{/OrderLines}} 4565 </tbody> 4566 </table> 4567 {{/unless}} 4568 <div class="grid u-border-top"> 4569 <div class="grid__col-sm-6"> 4570 @if (Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 4571 { 4572 <text> 4573 {{#if userPoints}} 4574 <div class="u-border u-border-color--loyalty-points u-padding--lg u-full-height"> 4575 @Render(new Heading { Title = Translate("Your point balance"), Level = 3 }) 4576 <div class="u-font-size--lg u-margin-bottom"> 4577 <span class="u-color--loyalty-points">{{userPoints}}</span> @Translate("points") 4578 </div> 4579 <div>@Translate("On this order you will use"): <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")</div> 4580 </div> 4581 {{/if}} 4582 </text> 4583 } 4584 </div> 4585 4586 <div class="grid__col-sm-6"> 4587 @if (GetLoop("DWExtranetSecondaryUsers").Count > 0 || !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.SecondaryUser.UserID"))) 4588 { 4589 <div class="grid"> 4590 <div class="grid__col-xs-12 alert-box u-color-danger txt-small u-hidden" id="error-discount">@Translate("Allowing only decimals numbers")</div> 4591 <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="" /> 4592 <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)"> 4593 <option value="OrderDiscountPercentage">@Translate("Percentage")</option> 4594 <option value="OrderDiscount">@Translate("Fixed Price")</option> 4595 <select> 4596 <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> 4597 </div> 4598 4599 } 4600 4601 @if (!pointShop) 4602 { 4603 <text> 4604 {{#unless hideSubTotal}} 4605 <div> 4606 <div class="cart-summary__subtotals dw-mod">@Translate("Subtotal")</div> 4607 <div class="cart-summary__subtotals u-pull--right dw-mod"> 4608 @if (hasTaxSettings) 4609 { 4610 <text>{{subtotalpricewithouttaxes}}</text> 4611 } 4612 else 4613 { 4614 <text>{{subtotalprice}}</text> 4615 } 4616 </div> 4617 </div> 4618 {{/unless}} 4619 </text> 4620 <text> 4621 {{#unless hidePaymentfee}} 4622 <div> 4623 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-credit-card", Label = "{{paymentmethod}}", LabelPosition = IconLabelPosition.After })</div> 4624 <div class="cart-summary__info u-pull--right dw-mod">{{paymentfee}}</div> 4625 </div> 4626 {{/unless}} 4627 </text> 4628 } 4629 {{#unless hideShippingfee}} 4630 <div> 4631 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-truck", Label = "{{shippingmethod}}", LabelPosition = IconLabelPosition.After })</div> 4632 <div class="cart-summary__info u-pull--right dw-mod">{{shippingfee}}</div> 4633 </div> 4634 {{#unless notTxtForShippingFree}} 4635 <div> 4636 <div class="cart-summary__info dw-mod"><span class="txt-small">@Translate("Free shipping - Buy for additional") {{aditionalPriceForFreeShipping}}</span> </div> 4637 <div class="cart-summary__info u-pull--right dw-mod"></div> 4638 </div> 4639 {{/unless}} 4640 {{/unless}} 4641 {{#if hasTaxSettings}} 4642 <div> 4643 <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> 4644 <div class="cart-summary__info u-pull--right dw-mod">{{totaltaxes}}</div> 4645 </div> 4646 {{/if}} 4647 @if (Pageview.User != null && Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints")) 4648 { 4649 <text> 4650 {{#if earnings}} 4651 <div> 4652 <div class="cart-summary__info dw-mod">@Translate("Earnings")</div> 4653 <div class="cart-summary__info u-pull--right dw-mod"><span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")</div> 4654 </div> 4655 {{/if}} 4656 </text> 4657 } 4658 <div class="cart-summary__totals-container dw-mod"> 4659 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 4660 <div class="cart-summary__totals u-pull--right dw-mod"> 4661 @if (pointShop) 4662 { 4663 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points") 4664 } 4665 else 4666 { 4667 <text>{{totalprice}}</text> 4668 } 4669 </div> 4670 </div> 4671 @if (!pointShop && !hasTaxSettings) 4672 { 4673 <div class="u-ta-right"> 4674 <small class="cart-summary__info dw-mod">@Translate("VAT"):</small> 4675 <small class="cart-summary__info dw-mod">{{totalvat}}</small> 4676 </div> 4677 4678 if (isPricesWithVATEnabled) 4679 { 4680 <div class="u-ta-right"> 4681 <small class="cart-summary__info dw-mod">@Translate("Total price without VAT"):</small> 4682 <small class="cart-summary__info dw-mod">{{totalPriceWithoutVat}}</small> 4683 </div> 4684 } 4685 else 4686 { 4687 <div class="u-ta-right"> 4688 <small class="cart-summary__info dw-mod">@Translate("Total price with VAT"):</small> 4689 <small class="cart-summary__info dw-mod">{{totalPriceWithVat}}</small> 4690 </div> 4691 } 4692 } 4693 {{#if showCheckoutDisclaimer}} 4694 <div class="u-ta-right"> 4695 <small>{{checkoutDisclaimer}}</small> 4696 </div> 4697 {{/if}} 4698 </div> 4699 </div> 4700 4701 <div class="u-margin-bottom--lg"> 4702 <div id="errorCode"> 4703 4704 </div> 4705 @foreach (LoopItem error in GetLoop("ValidationErrors")) 4706 { 4707 @Render(new NotificationMessage { Message = error.GetString("Ecom:Cart.ValidationError.ErrorMessage"), MessageType = NotificationMessageType.Error }) 4708 } 4709 </div> 4710 </div> 4711 {{/.}} 4712 </script> 4713 4714 } 4715 @helper RenderCartOrderlineDiscountTemplateCustom() 4716 { 4717 <script id="CartOrderlineDiscount" type="text/x-template"> 4718 <tr class="table__row--no-border discount-row"> 4719 <td class="cart-table__image dw-mod"> 4720 {{#unless notDiscountImage}} 4721 <img src="{{{image}}}"> 4722 {{/unless}} 4723 </td> 4724 <td colspan="3">{{name}}</td> 4725 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 4726 <td class="cart-table__price u-ta-right dw-mod">{{totalprice}}</td> 4727 </tr> 4728 </script> 4729 } 4730 @helper RenderCartComment() 4731 { 4732 var cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed"); 4733 <div class="grid__col-12"> 4734 <div class="js-handlebars-root" id="CartComment" data-template="CartCommentCustom" data-json-feed="/Default.aspx?ID=@cartFeedPageIdCustom"></div> 4735 </div> 4736 4737 <script id="CartCommentCustom" type="text/x-template"> 4738 {{#.}} 4739 <div class=""> 4740 <div class="grid"> 4741 <div class="grid__col-12 grid__col--line-top"></div> 4742 </div> 4743 {{#unless hideComment}} 4744 <div class="grid__cell u-padding--xs"> 4745 @Render(new TextareaField { Rows = 3, Placeholder = Translate("Enter comment"), Name = "EcomOrderCustomerComment", Id = "EcomOrderCustomerComment", Value = "{{comment}}" }) 4746 </div> 4747 {{/unless}} 4748 </div> 4749 {{/.}} 4750 </script> 4751 } 4752 @helper RenderReviewOrderFooterCustom() 4753 { 4754 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 4755 var emptyOrContinueBtn = Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage") != null ? Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage").SelectedValue : "empty"; 4756 string reviewOrderType = checkoutPageType ?? "onestep"; //The "checkoutPageType" comes from the main template for the cart page 4757 int cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed"); 4758 var paymentCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 4759 var shippingCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 4760 var paymentCountryIsSupported = string.IsNullOrEmpty(paymentCountryCode) || GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == paymentCountryCode)); 4761 var shippingCountryIsSupported = string.IsNullOrEmpty(shippingCountryCode) ? paymentCountryIsSupported : GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == shippingCountryCode)); 4762 4763 bool canCompleteOrderCustom = paymentCountryIsSupported && shippingCountryIsSupported; 4764 <div class="grid"> 4765 <div class="grid__col-12 grid__col--line-top"></div> 4766 </div> 4767 4768 <div class="grid__cell-footer"> 4769 <div class="grid__cell u-padding--xs"> 4770 <div class="u-pull--right"> 4771 @Render(new Button 4772 { 4773 ButtonType = ButtonType.Submit, 4774 ButtonLayout = ButtonLayout.Primary, 4775 CssClass = "btn--condensed u-pull--right u-no-margin", 4776 Title = Translate("Go to checkout"), 4777 Id = GetString("CartV2.NextStepButtonName"), 4778 OnClick = "Buttons.LockButton(event, true)", 4779 Disabled = !canCompleteOrderCustom || !Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions"), 4780 Name = GetString("CartV2.NextStepButtonName") 4781 }) 4782 </div> 4783 <div class="u-pull--left"> 4784 @if (emptyOrContinueBtn == "empty") 4785 { 4786 @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);" }) 4787 4788 } 4789 else 4790 { 4791 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", Title = Translate("Continue shopping"), OnClick = "GoToProductPage();" }) 4792 4793 } 4794 </div> 4795 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 4796 { 4797 <div class="u-pull--right"> 4798 @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") }) 4799 </div> 4800 } 4801 </div> 4802 </div> 4803 4804 4805 4806 } 4807 4808 @helper RenderReviewOrderFooterQuoteCustom() 4809 { 4810 string submitButtonTitle = Pageview.Device.ToString() == "Mobile" ? Translate("Submit") : Translate("Submit quote request"); 4811 4812 <div class="grid"> 4813 <div class="grid__col-12 grid__col--line-top"></div> 4814 </div> 4815 4816 <div class="grid__cell-footer"> 4817 <div class="grid__cell u-padding--xs"> 4818 <div class="u-pull--right"> 4819 @Render(new Button 4820 { 4821 ButtonType = ButtonType.Submit, 4822 ButtonLayout = ButtonLayout.Primary, 4823 CssClass = "btn--condensed u-pull--right u-no-margin", 4824 Title = submitButtonTitle, 4825 Id = GetString("CartV2.NextStepButtonName"), 4826 OnClick = "Buttons.LockButton(event, true)", 4827 Name = GetString("CartV2.NextStepButtonName") 4828 }) 4829 </div> 4830 <div class="u-pull--left"> 4831 @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") }) 4832 </div> 4833 </div> 4834 </div> 4835 } 4836 <script type="text/javascript"> 4837 function getCook(cookiename) { 4838 // Get name followed by anything except a semicolon 4839 var cookiestring = RegExp(cookiename + "=[^;]+").exec(document.cookie); 4840 // Return everything after the equal sign, or an empty string if the cookie name not found 4841 return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, "") : ""); 4842 } 4843 function GoToProductPage() { 4844 var cookieValue = getCook('ProductLink'); 4845 if (document.cookie.indexOf("ProductLink=") >= 0) { 4846 location.href = cookieValue; 4847 4848 } 4849 else{ 4850 location.href = "/Default.aspx?ID=@GetPageIdByNavigationTag("ProductsPage")"; 4851 } 4852 4853 } 4854 </script> 4855 <script type="text/javascript"> 4856 isDecimalsThis=function(input){ 4857 let str = input.value 4858 const regExp = /^\d*(\.)?(\d{0,2})?$/ 4859 status = regExp.test(str) ? 'valid' : 'invalid' 4860 if (status === "valid") { 4861 document.getElementById("discountBtn").classList.remove("disabled") 4862 document.getElementById("error-discount").classList.add("u-hidden"); 4863 } 4864 else { 4865 document.getElementById("discountBtn").classList.add("disabled"); 4866 document.getElementById("error-discount").classList.remove("u-hidden"); 4867 } 4868 4869 console.log(status + ' : ' + input.value) 4870 4871 } 4872 changeDiscount = function (l) { 4873 let discoutnBtn = document.getElementById("discountBtn"); 4874 let selectElement = l.value; 4875 let inputElement = document.getElementsByClassName("orderDiscount")[0]; 4876 inputElement.setAttribute("id", selectElement); 4877 inputElement.setAttribute("name", selectElement); 4878 discoutnBtn.setAttribute("onclick", "HandlebarsBolt.UpdateContent('Cart', '/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")&CartCmd=setdiscount&" + selectElement + "='+ document.getElementById('" + selectElement+"').value);return false;") 4879 4880 } 4881 var getJSON = function (url, callback) { 4882 var xhr = new XMLHttpRequest(); 4883 xhr.open('GET', url, true); 4884 xhr.responseType = 'json'; 4885 xhr.onload = function () { 4886 var status = xhr.status; 4887 if (status === 200) { 4888 callback(null, xhr.response); 4889 } else { 4890 callback(status, xhr.response); 4891 } 4892 }; 4893 xhr.send(); 4894 }; 4895 4896 ValidationCode = function (l, e, id) { 4897 l.preventDefault() 4898 var selectForm = document.getElementById("OrderSubmit"); // Select the form by ID. 4899 4900 let elementname = e; 4901 let elementvalue = id; 4902 clearTimeout(updateDelay); 4903 4904 updateDelay = setTimeout(function () { 4905 const XHR = new XMLHttpRequest(), 4906 FD = new FormData(); 4907 FD.append(elementname, elementvalue); 4908 XHR.addEventListener('load', function (event) { 4909 //Success 4910 }); 4911 // Define what happens in case of error 4912 XHR.addEventListener(' error', function (event) { 4913 //Error 4914 }); 4915 XHR.open('POST', 'Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")'); 4916 XHR.send(FD); 4917 4918 getJSON('/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")', 4919 function (err, data) { 4920 if (err !== null) { 4921 console.log('Something went wrong: ' + err); 4922 } else { 4923 4924 if (data[0].orderIsAuthenticatedClean === false) { 4925 HandlebarsBolt.UpdateContent('Cart', 4926 '/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")' + '&redirect=false', 4927 '/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")' + '&redirect=false', 4928 'CartContent', 'minimal'); 4929 } 4930 else { 4931 document.getElementById('OrderSubmit').dispatchEvent(new Event('submit')); 4932 document.getElementById('OrderSubmit').submit(); 4933 } 4934 } 4935 }) 4936 4937 4938 }, 100); 4939 4940 }; 4941 4942 4943 </script> 4944 4945 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 4946 @using Dynamicweb 4947 @using Dynamicweb.Core 4948 @using System.Collections; 4949 @using System 4950 @using System.Web 4951 @using System.Linq; 4952 @using System.Collections.Generic 4953 @using Dynamicweb.Rapido.Blocks 4954 @using Dynamicweb.Rapido.Blocks.Components 4955 @using Dynamicweb.Rapido.Blocks.Components.General 4956 4957 4958 @helper RenderAcceptanceCustom() 4959 { 4960 if (GetBoolean("Ecom:Cart.UseNewsletterSubscription")) 4961 { 4962 @Render(new HiddenField { Name = "EcomOrderSubscribeToNewsletter" }) 4963 @Render(new CheckboxField { Name = "EcomOrderSubscribeToNewsletter", Id = "EcomOrderSubscribeToNewsletter", Label = Translate("Subscribe to newsletter") }) 4964 } 4965 4966 if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions")) 4967 { 4968 @Render(new HiddenField { Name = "EcomOrderCustomerAccepted", Id = "EcomOrderCustomerAccepted", Value = "1" }) 4969 } 4970 else 4971 { 4972 string termsPageIt = GetPageIdByNavigationTag("TermsAndConditions").ToString(); 4973 @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") }) 4974 } 4975 <script type="text/javascript"> 4976 function EnableCheckoutButton() { 4977 var stepButtonId = document.getElementById("CartV2.GotoStep3") ? "CartV2.GotoStep3" : "CartV2.GotoStep1"; 4978 var stepButton = document.getElementById(stepButtonId); 4979 let isValid = true; 4980 4981 if (isValid) { 4982 if (document.getElementById("EcomOrderCustomerAccepted").checked) { 4983 4984 var elements = document.getElementsByClassName('error-input'); 4985 var i; 4986 for (i = 0; i < elements.length; i++) { 4987 var error = elements[i].dataset.error; 4988 var value = elements[i].value; 4989 if (value != "ok" || value == "") { 4990 isValid = false; 4991 console.log(elements[i].dataset.error) 4992 document.getElementById("errorCode").innerHTML += "<div class='field-error u-full-width dw-mod'>" + error + "</div>"; 4993 document.getElementById("EcomOrderCustomerAccepted").checked = true 4994 4995 } 4996 4997 4998 } 4999 5000 5001 if (isValid) { 5002 stepButton.disabled = false; 5003 stepButton.classList.remove('disabled'); 5004 } 5005 5006 } 5007 else { 5008 if (document.getElementById("errorCode")) { 5009 document.getElementById("errorCode").innerHTML = ""; 5010 } 5011 5012 stepButton.disabled = true; 5013 stepButton.classList.add('disabled'); 5014 } 5015 } 5016 5017 5018 5019 } 5020 5021 </script> 5022 } 5023 @if (checkoutPageType == "multistep") 5024 { 5025 5026 <text>@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5027 @using Dynamicweb.Core 5028 @using System 5029 @using System.Web 5030 @using System.Collections.Generic 5031 @using Dynamicweb.Rapido.Blocks 5032 5033 @{ 5034 BlocksPage stepNavigationCheckoutPageCustom = BlocksPage.GetBlockPage("CheckoutPage"); 5035 5036 Block checkoutStepNavigationCustom = new Block() 5037 { 5038 Id = "StepNavigation", 5039 SortId = 50, 5040 Template = RenderStepNavigationCustom(), 5041 Design = new Design 5042 { 5043 RenderType = RenderType.Column, 5044 Size = "12" 5045 } 5046 5047 }; 5048 stepNavigationCheckoutPageCustom.ReplaceBlock(checkoutStepNavigationCustom); 5049 } 5050 5051 @helper RenderStepNavigationCustom() 5052 { 5053 var paymentCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 5054 var shippingCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 5055 var paymentCountryIsSupported = string.IsNullOrEmpty(paymentCountryCode) || GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == paymentCountryCode)); 5056 var shippingCountryIsSupported = string.IsNullOrEmpty(shippingCountryCode) ? paymentCountryIsSupported : GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == shippingCountryCode)); 5057 var emptyOrContinueBtn = Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage") != null ? Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage").SelectedValue : "empty"; 5058 5059 var canCompleteOrder = paymentCountryIsSupported && shippingCountryIsSupported; 5060 5061 5062 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 5063 int currentStep = 1; 5064 string disableNextButton = ""; 5065 string nextButtonName = Translate("Next"); 5066 5067 foreach (LoopItem step in GetLoop("StepButtons")) 5068 { 5069 if (step.GetBoolean("Step.Current")) 5070 { 5071 currentStep = step.GetInteger("Step.Number"); 5072 } 5073 5074 if (step.GetInteger("Step.Number") == currentStep + 1) 5075 { 5076 if (Pageview.Device.ToString() != "Mobile") 5077 { 5078 nextButtonName = Translate("Go to") + " " + step.GetString("Step.Name"); 5079 } 5080 else 5081 { 5082 nextButtonName = step.GetString("Step.Name"); 5083 } 5084 } 5085 } 5086 5087 if (currentStep == GetLoop("StepButtons").Count - 1) 5088 { 5089 disableNextButton = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions") ? "" : "disabled"; //not disable button if terms are hidden 5090 nextButtonName = Translate("Confirm order"); 5091 } 5092 5093 if (currentStep > 1 && !canCompleteOrder) 5094 { 5095 disableNextButton = "disabled"; 5096 } 5097 bool RequireAuthorization = GetLoop("OrderLines").Any(x => x.GetBoolean("Ecom:Product:Field.RequireAuthorization")); 5098 <div class="card u-color-light--bg dw-mod"> 5099 @if (currentStep == 1) 5100 { 5101 <div class="u-pull--left"> 5102 @if (emptyOrContinueBtn == "empty") 5103 { 5104 @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);" }) 5105 5106 } 5107 else 5108 { 5109 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", Title = Translate("Continue shopping"), OnClick = "GoToProductPage();" }) 5110 5111 } 5112 </div> 5113 5114 } 5115 else 5116 { 5117 <div class="u-pull--left"> 5118 5119 <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> 5120 </div> 5121 } 5122 5123 <div class="u-pull--right"> 5124 @if (RequireAuthorization) 5125 { 5126 <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> 5127 } 5128 else 5129 { 5130 <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> 5131 5132 } 5133 </div> 5134 5135 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 5136 { 5137 <div class="u-pull--right"> 5138 <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> 5139 </div> 5140 } 5141 </div> 5142 } 5143 <script type="text/javascript"> 5144 function getCook(cookiename) { 5145 // Get name followed by anything except a semicolon 5146 var cookiestring = RegExp(cookiename + "=[^;]+").exec(document.cookie); 5147 // Return everything after the equal sign, or an empty string if the cookie name not found 5148 return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, "") : ""); 5149 } 5150 function GoToProductPage() { 5151 var cookieValue = getCook('ProductLink'); 5152 if (document.cookie.indexOf("ProductLink=") >= 0) { 5153 location.href = cookieValue; 5154 5155 } 5156 else{ 5157 location.href = "/Default.aspx?ID=@GetPageIdByNavigationTag("ProductsPage")"; 5158 } 5159 5160 } 5161 </script></text> 5162 <text>@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 5163 @using Dynamicweb.Core 5164 @using System 5165 @using System.Web 5166 @using System.Linq 5167 @using System.Collections.Generic 5168 @using System.Text.RegularExpressions 5169 @using Dynamicweb.Extensibility 5170 @using Dynamicweb.Content 5171 @using Dynamicweb.Core 5172 @using Dynamicweb.Ecommerce.Orders 5173 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 5174 @using Dynamicweb.Rapido.Blocks 5175 @using Dynamicweb.Rapido.Blocks.Components 5176 @using Dynamicweb.Rapido.Blocks.Components.General 5177 5178 @{ 5179 BlocksPage staticSummaryCheckoutPageCustom = BlocksPage.GetBlockPage("CheckoutPage"); 5180 5181 Block staticSummaryCustom = new Block() 5182 { 5183 Id = "StaticSummary", 5184 SortId = 20, 5185 Design = new Design 5186 { 5187 RenderType = RenderType.Column, 5188 Size = "12" 5189 }, 5190 BlocksList = new List<Block> { 5191 new Block { 5192 Id = "StaticSummaryHeader", 5193 SortId = 10, 5194 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 } }, 5195 Design = new Design { 5196 RenderType = RenderType.CardHeader, 5197 CssClass = "u-color-light--bg" 5198 } 5199 }, 5200 new Block { 5201 Id = "StaticSummaryBody", 5202 SortId = 20, 5203 Template = RenderStaticSummaryCustom(), 5204 Design = new Design { 5205 RenderType = RenderType.CardBody, 5206 CssClass = "u-color-light--bg u-no-padding--xs" 5207 } 5208 } 5209 } 5210 }; 5211 staticSummaryCheckoutPageCustom.ReplaceBlock(staticSummaryCustom); 5212 } 5213 5214 5215 @helper RenderStaticSummaryCustom() 5216 { 5217 int productCatalog = GetPageIdByNavigationTag("ProductsPage"); 5218 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(GetString("Ecom:Order.ID")); 5219 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 5220 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 5221 double shippingFeePrice = GetDouble("Ecom:Order.ShippingFee.Price"); 5222 double minPriceForFree = 0; 5223 double minPriceForFreeShip = 0; 5224 double aditionalPriceForFreeShipping = 0; 5225 double totalPriceWithoutFormated = GetDouble("Ecom:Order.Price.Price"); 5226 var shippingMethods = GetLoop("Shippingmethods"); 5227 var currency = Dynamicweb.Ecommerce.Services.Currencies.GetDefaultCurrency(); 5228 foreach (LoopItem shipping in shippingMethods) 5229 { 5230 5231 if (shipping.GetString("Ecom:Cart.Shippingmethod.Name") == GetString("Ecom:Order.ShippingMethod")) 5232 { 5233 minPriceForFree = shipping.GetDouble("Ecom:Cart.Shippingmethod.MinimumPriceForFreeFee.Price"); 5234 minPriceForFreeShip = minPriceForFree; 5235 if (shipping.GetDouble("Ecom:Cart.Shippingmethod.MinimumPriceForFreeFee.Price") > (totalPriceWithoutFormated - shippingFeePrice)) 5236 { 5237 aditionalPriceForFreeShipping = minPriceForFree - (totalPriceWithoutFormated - shippingFeePrice); 5238 5239 } 5240 5241 } 5242 } 5243 string cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 5244 if (!String.IsNullOrWhiteSpace(GetString("Ecom:OrderContext.ID"))) 5245 { 5246 cartFeedPageId += "&OrderContext=" + GetString("Ecom:OrderContext.ID"); 5247 } 5248 <div class="js-handlebars-root" id="SummaryCart" data-template="CartOrderlineSummary" data-cart-id="@cartFeedPageId" data-json-feed="/Default.aspx?ID=@cartFeedPageId" data-preloader="minimal"> 5249 5250 5251 </div> 5252 <script id="CartOrderlineSummary" type="text/x-template"> 5253 {{#.}} 5254 <table class="table cart-table u-margin-bottom u-border-bottom dw-mod"> 5255 <tbody> 5256 {{#OrderLines}} 5257 {{> (lookup . 'template') }} 5258 {{/OrderLines}} 5259 5260 5261 </tbody> 5262 5263 </table> 5264 @if (!pointShop) 5265 { 5266 <text> 5267 {{#unless hideSubTotal}} 5268 <div class="u-padding-bottom u-padding-x"> 5269 <div class="cart-summary__subtotals dw-mod">@Translate("Subtotal") </div> 5270 <div class="cart-summary__subtotals u-pull--right dw-mod"> 5271 @if (hasTaxSettings) 5272 { 5273 <text> 5274 {{subtotalpricewithouttaxes}} 5275 </text> 5276 5277 } 5278 else 5279 { 5280 <text> 5281 {{subtotalprice}} 5282 </text> 5283 5284 } 5285 </div> 5286 </div> 5287 {{/unless}} 5288 </text> 5289 <text> 5290 {{#unless hidePaymentfee}} 5291 <div class="u-padding-bottom u-padding-x"> 5292 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-credit-card", Label = "{{paymentmethod}}", LabelPosition = IconLabelPosition.After })</div> 5293 <div class="cart-summary__info u-pull--right dw-mod">{{paymentfee}}</div> 5294 </div> 5295 {{/unless}} 5296 </text> 5297 } 5298 5299 {{#unless hideShippingfee}} 5300 <div class="u-padding-bottom u-padding-x"> 5301 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-truck", Label = "{{shippingmethod}}", LabelPosition = IconLabelPosition.After })</div> 5302 <div class="cart-summary__info u-pull--right dw-mod">{{shippingfee}}</div> 5303 </div> 5304 {{#unless notTxtForShippingFree}} 5305 <div class="u-padding-bottom u-padding-x"> 5306 <div class="cart-summary__info dw-mod"><span class="txt-small">@Translate("Free shipping - Buy for additional") {{aditionalPriceForFreeShipping}}</span> </div> 5307 <div class="cart-summary__info u-pull--right dw-mod"></div> 5308 </div> 5309 {{/unless}} 5310 {{/unless}} 5311 5312 5313 5314 {{#if hasTaxSettings}} 5315 <div class="u-padding-bottom u-padding-x"> 5316 <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> 5317 <div class="cart-summary__info u-pull--right dw-mod">{{totaltaxes}}</div> 5318 </div> 5319 5320 5321 {{/if}} 5322 5323 @if (Pageview.User != null && Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints") && GetDouble("Ecom:Order.RewardTotalPoints") > 0) 5324 { 5325 <text> 5326 {{#if earnings}} 5327 <div class="u-padding-bottom u-padding-x"> 5328 <div class="cart-summary__info dw-mod">@Translate("Earnings")</div> 5329 <div class="cart-summary__info u-pull--right dw-mod"><span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")</div> 5330 </div> 5331 {{/if}} 5332 </text> 5333 5334 } 5335 5336 <div class="u-padding u-border-top"> 5337 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 5338 <div class="cart-summary__totals u-pull--right dw-mod">{{totalprice}}</div> 5339 </div> 5340 5341 @if (!pointShop && !hasTaxSettings) 5342 { 5343 <div class="u-ta-right u-padding-x"> 5344 <small class="cart-summary__info dw-mod">@Translate("VAT"):</small> 5345 <small class="cart-summary__info dw-mod">{{totalvat}}</small> 5346 </div> 5347 5348 if (isPricesWithVATEnabled) 5349 { 5350 <div class="u-ta-right u-padding-x"> 5351 <small class="cart-summary__info dw-mod">@Translate("Total price without VAT"):</small> 5352 <small class="cart-summary__info dw-mod">{{totalPriceWithoutVat}}</small> 5353 </div> 5354 } 5355 else 5356 { 5357 <div class="u-ta-right u-padding-x"> 5358 <small class="cart-summary__info dw-mod">@Translate("Total price with VAT"):</small> 5359 <small class="cart-summary__info dw-mod">{{totalPriceWithVat}}</small> 5360 </div> 5361 } 5362 } 5363 5364 {{#if showCheckoutDisclaimer}} 5365 <div class="u-ta-right"> 5366 <small class="u-full-width">{{checkoutDisclaimer}}</small> 5367 </div> 5368 {{/if}} 5369 5370 {{/.}} 5371 </script> 5372 <script id="CartOrderline" type="text/x-template"> 5373 {{#unless isEmpty}} 5374 <tr> 5375 <td class="u-w60px"> 5376 {{quantity}} x 5377 </td> 5378 <td title="{{name}} {{variantname}}"> 5379 <a href="{{link}}" class="u-color-inherit">{{name}}</a> 5380 <div>{{{variantname}}}</div> 5381 <div>{{unitname}}</div> 5382 </td> 5383 {{#if pointsTotal}} 5384 <td class="u-ta-right u-w120px"> 5385 <span class="u-color--loyalty-points">{{pointPrice}}</span> @Translate("points") 5386 </td> 5387 {{else}} 5388 5389 <td class="u-ta-right u-w120px">{{totalprice}}</td> 5390 {{/if}} 5391 </tr> 5392 <tr class="{{hideBomItems}}"> 5393 <td colspan="3" class="u-no-padding"> 5394 <table class="u-no-margin u-color-light-gray--bg"> 5395 <tbody> 5396 {{#BomItems}} 5397 <tr> 5398 <td class="u-w60px">{{quantity}} x</td> 5399 <td title="{{name}} {{variantname}}"> 5400 <a href="{{link}}">{{name}}</a> 5401 <div>{{variantname}}</div> 5402 <div>{{unitname}}</div> 5403 </td> 5404 </tr> 5405 {{/BomItems}} 5406 </tbody> 5407 </table> 5408 </td> 5409 </tr> 5410 {{/unless}} 5411 </script> 5412 <script id="CartOrderlineDiscount" type="text/x-template"> 5413 <tr class="table__row--no-border"> 5414 <td class="u-w60px"> 5415 {{#unless notDiscountImage}} 5416 <img src="{{{image}}}"> 5417 {{/unless}} 5418 </td> 5419 <td>{{name}}</td> 5420 <td class="cart-table__price u-ta-right dw-mod">{{totalprice}}</td> 5421 </tr> 5422 </script> 5423 5424 } 5425 </text> 5426 5427 } 5428 5429 5430 5431 @helper RenderCheckoutForm() 5432 { 5433 List<Block> subBlocks = checkoutPage.GetBlockListById("CheckoutForm").OrderBy(item => item.SortId).ToList(); 5434 string pageId = GetGlobalValue("Global:Page.ID"); 5435 5436 <section class="multiple-paragraphs-container u-color-light-gray--bg paragraph-container--full-width"> 5437 <div class="center-container center-container--with-background-image dw-mod"> 5438 <div class="paragraph-container u-padding"> 5439 <form name="ordersubmit" id="OrderSubmit" method="post" action="/Default.aspx?ID=@pageId" autocomplete="off"> 5440 <div class="grid"> 5441 @RenderBlockList(subBlocks) 5442 </div> 5443 </form> 5444 </div> 5445 </div> 5446 </section> 5447 } 5448 5449 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 5450 @RenderBlockList(checkoutPage.BlocksRoot.BlocksList)
Cookies

This website uses cookies to track your behavior and to improve your experience on the site.