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