Error executing template "Designs/Rapido/eCom7/CartV2/Step/StepOneCart.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_1a81ae09dd0e4da6a4f6132699f0c7ed.<RenderCartOrderlineTemplateCustom>b__64_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\StepOneCart.cshtml:line 3015
   at RazorEngine.Templating.TemplateWriter.ToString()
   at System.Lazy`1.CreateValue()
   at System.Lazy`1.LazyInitValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_1a81ae09dd0e4da6a4f6132699f0c7ed.<>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\StepOneCart.cshtml:line 189
   at CompiledRazorTemplates.Dynamic.RazorEngine_1a81ae09dd0e4da6a4f6132699f0c7ed.<>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\StepOneCart.cshtml:line 99
   at CompiledRazorTemplates.Dynamic.RazorEngine_1a81ae09dd0e4da6a4f6132699f0c7ed.<>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\StepOneCart.cshtml:line 222
   at CompiledRazorTemplates.Dynamic.RazorEngine_1a81ae09dd0e4da6a4f6132699f0c7ed.<>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\StepOneCart.cshtml:line 99
   at CompiledRazorTemplates.Dynamic.RazorEngine_1a81ae09dd0e4da6a4f6132699f0c7ed.<>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\StepOneCart.cshtml:line 222
   at CompiledRazorTemplates.Dynamic.RazorEngine_1a81ae09dd0e4da6a4f6132699f0c7ed.<>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\StepOneCart.cshtml:line 99
   at CompiledRazorTemplates.Dynamic.RazorEngine_1a81ae09dd0e4da6a4f6132699f0c7ed.Execute() in D:\dynamicweb.net\Solutions\TCOG\pronails.cloud.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\StepOneCart.cshtml:line 4032
   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.Ecommerce.Orders 6 @using Dynamicweb.Core 7 @using System 8 @using System.IO 9 @using Dynamicweb.Rapido.Blocks 10 11 12 @functions{ 13 BlocksPage checkoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 14 string checkoutPageType = "multistep"; 15 } 16 17 @{ 18 string pageId = GetGlobalValue("Global:Page.ID"); 19 int cartOrderlinesFeedPageId = GetPageIdByNavigationTag("CartOrderlinesFeed"); 20 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 21 22 Block checkoutTopSnippets = new Block() 23 { 24 Id = "CheckoutTopSnippets", 25 SortId = 10 26 }; 27 checkoutPage.Add(checkoutTopSnippets); 28 29 Block checkoutForm = new Block 30 { 31 Id = "CheckoutForm", 32 SortId = 20, 33 Template = RenderCheckoutForm(), 34 SkipRenderBlocksList = true, 35 BlocksList = new List<Block> 36 { 37 new Block() 38 { 39 Id = "OrderContainer", 40 SortId = 30, 41 Design = new Design 42 { 43 RenderType = RenderType.Column, 44 Size = "12", 45 HidePadding = true 46 }, 47 BlocksList = new List<Block> { 48 new Block() 49 { 50 Id = "OrderContainerRow", 51 SortId = 10, 52 Design = new Design 53 { 54 RenderType = RenderType.Row 55 } 56 } 57 } 58 } 59 } 60 }; 61 62 checkoutPage.Add(checkoutForm); 63 64 Block checkoutBottomSnippets = new Block() 65 { 66 Id = "CheckoutBottomSnippets", 67 SortId = 40 68 }; 69 checkoutPage.Add(checkoutBottomSnippets); 70 } 71 72 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 73 @using System.Text.RegularExpressions 74 @using System.Collections.Generic 75 @using System.Reflection 76 @using System.Web 77 @using System.Web.UI.HtmlControls 78 @using Dynamicweb.Rapido.Blocks.Components 79 @using Dynamicweb.Rapido.Blocks.Components.Articles 80 @using Dynamicweb.Rapido.Blocks.Components.Documentation 81 @using Dynamicweb.Rapido.Blocks 82 83 84 @*--- START: Base block renderers ---*@ 85 86 @helper RenderBlockList(List<Block> blocks) 87 { 88 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 89 blocks = blocks.OrderBy(item => item.SortId).ToList(); 90 91 foreach (Block item in blocks) 92 { 93 if (debug) { 94 <!-- Block START: @item.Id --> 95 } 96 97 if (item.Design == null) 98 { 99 @RenderBlock(item) 100 } 101 else if (item.Design.RenderType == RenderType.None) { 102 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 103 104 <div class="@cssClass dw-mod"> 105 @RenderBlock(item) 106 </div> 107 } 108 else if (item.Design.RenderType != RenderType.Hide) 109 { 110 string cssClass = item.Design.CssClass != null ? item.Design.CssClass : ""; 111 112 if (!item.SkipRenderBlocksList) { 113 if (item.Design.RenderType == RenderType.Row) 114 { 115 <div class="grid grid--align-content-start @cssClass dw-mod" id="Block__@item.Id"> 116 @RenderBlock(item) 117 </div> 118 } 119 120 if (item.Design.RenderType == RenderType.Column) 121 { 122 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 123 string size = item.Design.Size ?? "12"; 124 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 125 126 <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"> 127 @RenderBlock(item) 128 </div> 129 } 130 131 if (item.Design.RenderType == RenderType.Table) 132 { 133 <table class="table @cssClass dw-mod" id="Block__@item.Id"> 134 @RenderBlock(item) 135 </table> 136 } 137 138 if (item.Design.RenderType == RenderType.TableRow) 139 { 140 <tr class="@cssClass dw-mod" id="Block__@item.Id"> 141 @RenderBlock(item) 142 </tr> 143 } 144 145 if (item.Design.RenderType == RenderType.TableColumn) 146 { 147 <td class="@cssClass dw-mod" id="Block__@item.Id"> 148 @RenderBlock(item) 149 </td> 150 } 151 152 if (item.Design.RenderType == RenderType.CardHeader) 153 { 154 <div class="card-header @cssClass dw-mod"> 155 @RenderBlock(item) 156 </div> 157 } 158 159 if (item.Design.RenderType == RenderType.CardBody) 160 { 161 <div class="card @cssClass dw-mod"> 162 @RenderBlock(item) 163 </div> 164 } 165 166 if (item.Design.RenderType == RenderType.CardFooter) 167 { 168 <div class="card-footer @cssClass dw-mod"> 169 @RenderBlock(item) 170 </div> 171 } 172 } 173 else 174 { 175 @RenderBlock(item) 176 } 177 } 178 179 if (debug) { 180 <!-- Block END: @item.Id --> 181 } 182 } 183 } 184 185 @helper RenderBlock(Block item) 186 { 187 bool debug = !String.IsNullOrEmpty(HttpContext.Current.Request.QueryString.Get("debug")) ? Convert.ToBoolean(HttpContext.Current.Request.QueryString.Get("debug")) : false; 188 189 if (item.Template != null) 190 { 191 @BlocksPage.RenderTemplate(item.Template) 192 } 193 194 if (item.Component != null) 195 { 196 string customSufix = "Custom"; 197 string methodName = item.Component.HelperName; 198 199 ComponentBase[] methodParameters = new ComponentBase[1]; 200 methodParameters[0] = item.Component; 201 Type methodType = this.GetType(); 202 203 MethodInfo customMethod = methodType.GetMethod(methodName + customSufix); 204 MethodInfo generalMethod = methodType.GetMethod(methodName); 205 206 try { 207 if (debug) { 208 <!-- Component: @methodName.Replace("Render", "") --> 209 } 210 @customMethod.Invoke(this, methodParameters).ToString(); 211 } catch { 212 try { 213 @generalMethod.Invoke(this, methodParameters).ToString(); 214 } catch(Exception ex) { 215 throw new Exception(item.Component.GetType().Name + " method '" + methodName +"' could not be invoked", ex); 216 } 217 } 218 } 219 220 if (item.BlocksList.Count > 0 && !item.SkipRenderBlocksList) 221 { 222 @RenderBlockList(item.BlocksList) 223 } 224 } 225 226 @*--- END: Base block renderers ---*@ 227 228 @using Dynamicweb.Rapido.Blocks.Components 229 @using Dynamicweb.Rapido.Blocks.Components.General 230 @using Dynamicweb.Rapido.Blocks 231 @using System.IO 232 233 @* Required *@ 234 @using Dynamicweb.Rapido.Blocks.Components 235 @using Dynamicweb.Rapido.Blocks.Components.General 236 @using Dynamicweb.Rapido.Blocks 237 238 239 @helper Render(ComponentBase component) 240 { 241 if (component != null) 242 { 243 @component.Render(this) 244 } 245 } 246 247 248 @* Components *@ 249 @using System.Reflection 250 @using Dynamicweb.Rapido.Blocks.Components.General 251 252 253 @* Component *@ 254 255 @helper RenderIcon(Icon settings) 256 { 257 if (settings != null) 258 { 259 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 260 261 if (settings.Name != null) 262 { 263 if (string.IsNullOrEmpty(settings.Label)) 264 { 265 <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> 266 } 267 else 268 { 269 if (settings.LabelPosition == IconLabelPosition.Before) 270 { 271 <span>@settings.Label <i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i></span> 272 } 273 else 274 { 275 <span><i class="@settings.Prefix @settings.Name @settings.CssClass" @color></i> @settings.Label</span> 276 } 277 } 278 } 279 else if (!string.IsNullOrEmpty(settings.Label)) 280 { 281 @settings.Label 282 } 283 } 284 } 285 @using System.Reflection 286 @using Dynamicweb.Rapido.Blocks.Components.General 287 @using Dynamicweb.Rapido.Blocks.Components 288 @using Dynamicweb.Core 289 290 @* Component *@ 291 292 @helper RenderButton(Button settings) 293 { 294 if (settings != null && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 295 { 296 Dictionary<string, string> attributes = new Dictionary<string, string>(); 297 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 298 if (settings.Disabled) { 299 attributes.Add("disabled", "true"); 300 classList.Add("disabled"); 301 } 302 303 if (!string.IsNullOrEmpty(settings.ConfirmText) || !string.IsNullOrEmpty(settings.ConfirmTitle)) 304 { 305 settings.Id = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 306 @RenderConfirmDialog(settings); 307 settings.OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = true"; 308 } 309 310 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 311 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 312 if (!string.IsNullOrEmpty(settings.AltText)) 313 { 314 attributes.Add("title", settings.AltText); 315 } 316 else if (!string.IsNullOrEmpty(settings.Title)) 317 { 318 attributes.Add("title", settings.Title); 319 } 320 321 var onClickEvents = new List<string>(); 322 if (!string.IsNullOrEmpty(settings.OnClick)) 323 { 324 onClickEvents.Add(settings.OnClick); 325 } 326 if (!string.IsNullOrEmpty(settings.Href)) 327 { 328 onClickEvents.Add("location.href='" + settings.Href + "'"); 329 } 330 if (onClickEvents.Count > 0) 331 { 332 attributes.Add("onClick", string.Join(";", onClickEvents)); 333 } 334 335 if (settings.ButtonLayout != ButtonLayout.None) 336 { 337 classList.Add("btn"); 338 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 339 if (btnLayout == "linkclean") 340 { 341 btnLayout = "link-clean"; //fix 342 } 343 classList.Add("btn--" + btnLayout); 344 } 345 346 if (settings.Icon == null) 347 { 348 settings.Icon = new Icon(); 349 } 350 settings.Icon.Label = settings.Title; 351 352 attributes.Add("type", Enum.GetName(typeof(ButtonType), settings.ButtonType).ToLower()); 353 354 <button class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</button> 355 } 356 } 357 358 @helper RenderConfirmDialog(Button settings) 359 { 360 Modal confirmDialog = new Modal { 361 Id = settings.Id, 362 Width = ModalWidth.Sm, 363 Heading = new Heading 364 { 365 Level = 2, 366 Title = settings.ConfirmTitle 367 }, 368 BodyText = settings.ConfirmText 369 }; 370 371 confirmDialog.AddAction(new Button { Title = Translate("Cancel"), ButtonLayout = ButtonLayout.Secondary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false"}); 372 confirmDialog.AddAction(new Button { Title = Translate("OK"), ButtonLayout = ButtonLayout.Primary, OnClick = "document.getElementById('" + settings.Id + "ModalTrigger').checked = false;" + settings.OnClick }); 373 374 @Render(confirmDialog) 375 } 376 @using Dynamicweb.Rapido.Blocks.Components.General 377 @using Dynamicweb.Rapido.Blocks.Components 378 @using Dynamicweb.Core 379 380 @helper RenderDashboard(Dashboard settings) 381 { 382 var widgets = settings.GetWidgets(); 383 384 if (!string.IsNullOrEmpty(settings.WidgetsBaseBackgroundColor)) 385 { 386 //set bg color for them 387 388 System.Drawing.Color color = System.Drawing.ColorTranslator.FromHtml(settings.WidgetsBaseBackgroundColor); 389 int r = Convert.ToInt16(color.R); 390 int g = Convert.ToInt16(color.G); 391 int b = Convert.ToInt16(color.B); 392 393 var count = widgets.Length; 394 var max = Math.Max(r, Math.Max(g, b)); 395 double step = 255.0 / (max * count); 396 var i = 0; 397 foreach (var widget in widgets) 398 { 399 i++; 400 401 var shade = "rgb(" + Converter.ToString(r * step * i).Replace(",", ".") + ", " + Converter.ToString(g * step * i).Replace(",", ".") + ", " + Converter.ToString(b * step * i).Replace(",", ".") + ")"; 402 widget.BackgroundColor = shade; 403 } 404 } 405 406 <div class="dashboard @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 407 @foreach (var widget in widgets) 408 { 409 <div class="dashboard__widget"> 410 @Render(widget) 411 </div> 412 } 413 </div> 414 } 415 @using Dynamicweb.Rapido.Blocks.Components.General 416 @using Dynamicweb.Rapido.Blocks.Components 417 418 @helper RenderDashboardWidgetLink(DashboardWidgetLink settings) 419 { 420 if (!string.IsNullOrEmpty(settings.Link)) 421 { 422 var backgroundStyles = ""; 423 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 424 { 425 backgroundStyles = "style=\"background-color:" + settings.BackgroundColor + "\""; 426 } 427 428 <a href="@settings.Link" class="widget widget--link @settings.CssClass dw-mod" @backgroundStyles title="@settings.Title" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 429 <div class="u-center-middle u-color-light"> 430 @if (settings.Icon != null) 431 { 432 settings.Icon.CssClass += "widget__icon"; 433 @Render(settings.Icon) 434 } 435 <div class="widget__title">@settings.Title</div> 436 </div> 437 </a> 438 } 439 } 440 @using Dynamicweb.Rapido.Blocks.Components.General 441 @using Dynamicweb.Rapido.Blocks.Components 442 443 @helper RenderDashboardWidgetCounter(DashboardWidgetCounter settings) 444 { 445 var backgroundStyles = ""; 446 if (!string.IsNullOrEmpty(settings.BackgroundColor)) 447 { 448 backgroundStyles = "style='background-color:" + settings.BackgroundColor + "'"; 449 } 450 451 <div class="widget @settings.CssClass dw-mod" @backgroundStyles @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 452 <div class="u-center-middle u-color-light"> 453 @if (settings.Icon != null) 454 { 455 settings.Icon.CssClass += "widget__icon"; 456 @Render(settings.Icon) 457 } 458 <div class="widget__counter">@settings.Count</div> 459 <div class="widget__title">@settings.Title</div> 460 </div> 461 </div> 462 } 463 @using System.Reflection 464 @using Dynamicweb.Rapido.Blocks.Components.General 465 @using Dynamicweb.Rapido.Blocks.Components 466 @using Dynamicweb.Core 467 468 @* Component *@ 469 470 @helper RenderLink(Link settings) 471 { 472 if (settings != null && !string.IsNullOrEmpty(settings.Href) && (!string.IsNullOrEmpty(settings.Title) || settings.Icon != null)) 473 { 474 Dictionary<string, string> attributes = new Dictionary<string, string>(); 475 List<string> classList = settings.CssClass != null ? settings.CssClass.Split(' ').ToList() : new List<string>(); 476 if (settings.Disabled) 477 { 478 attributes.Add("disabled", "true"); 479 classList.Add("disabled"); 480 } 481 482 if (!string.IsNullOrEmpty(settings.AltText)) 483 { 484 attributes.Add("title", settings.AltText); 485 } 486 else if (!string.IsNullOrEmpty(settings.Title)) 487 { 488 attributes.Add("title", settings.Title); 489 } 490 491 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 492 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 493 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onClick", settings.OnClick); } 494 attributes.Add("href", settings.Href); 495 496 if (settings.ButtonLayout != ButtonLayout.None) 497 { 498 classList.Add("btn"); 499 string btnLayout = Enum.GetName(typeof(ButtonLayout), settings.ButtonLayout).ToLower(); 500 if (btnLayout == "linkclean") 501 { 502 btnLayout = "link-clean"; //fix 503 } 504 classList.Add("btn--" + btnLayout); 505 } 506 507 if (settings.Icon == null) 508 { 509 settings.Icon = new Icon(); 510 } 511 settings.Icon.Label = settings.Title; 512 513 if (settings.Target == LinkTargetType.Blank && settings.Rel == LinkRelType.None) 514 { 515 settings.Rel = LinkRelType.Noopener; 516 } 517 if (settings.Target != LinkTargetType.None) 518 { 519 attributes.Add("target", "_" + Enum.GetName(typeof(LinkTargetType), settings.Target).ToLower()); 520 } 521 if (settings.Download) 522 { 523 attributes.Add("download", "true"); 524 } 525 if (settings.Rel != LinkRelType.None) 526 { 527 attributes.Add("rel", Enum.GetName(typeof(LinkRelType), settings.Rel).ToLower()); 528 } 529 530 <a class="@string.Join(" ", classList) dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@Render(settings.Icon)</a> 531 } 532 } 533 @using System.Reflection 534 @using Dynamicweb.Rapido.Blocks.Components 535 @using Dynamicweb.Rapido.Blocks.Components.General 536 @using Dynamicweb.Rapido.Blocks 537 538 539 @* Component *@ 540 541 @helper RenderRating(Rating settings) 542 { 543 if (settings.Score > 0) 544 { 545 int rating = settings.Score; 546 string iconType = "fa-star"; 547 548 switch (settings.Type.ToString()) { 549 case "Stars": 550 iconType = "fa-star"; 551 break; 552 case "Hearts": 553 iconType = "fa-heart"; 554 break; 555 case "Lemons": 556 iconType = "fa-lemon"; 557 break; 558 case "Bombs": 559 iconType = "fa-bomb"; 560 break; 561 } 562 563 <div class="u-ta-right"> 564 @for (int i = 0; i < settings.OutOf; i++) 565 { 566 <i class="@(rating > i ? "fas" : "far") @iconType"></i> 567 } 568 </div> 569 } 570 } 571 @using System.Reflection 572 @using Dynamicweb.Rapido.Blocks.Components.General 573 @using Dynamicweb.Rapido.Blocks.Components 574 575 576 @* Component *@ 577 578 @helper RenderSelectFieldOption(SelectFieldOption settings) 579 { 580 Dictionary<string, string> attributes = new Dictionary<string, string>(); 581 if (settings.Checked) { attributes.Add("selected", "true"); } 582 if (settings.Disabled) { attributes.Add("disabled", "true"); } 583 if (settings.Value != null) { attributes.Add("value", settings.Value); } 584 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 585 586 <option @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Label</option> 587 } 588 @using System.Reflection 589 @using Dynamicweb.Rapido.Blocks.Components.General 590 @using Dynamicweb.Rapido.Blocks.Components 591 592 593 @* Component *@ 594 595 @helper RenderNavigation(Navigation settings) { 596 @RenderNavigation(new 597 { 598 id = settings.Id, 599 cssclass = settings.CssClass, 600 startLevel = settings.StartLevel, 601 endlevel = settings.EndLevel, 602 expandmode = settings.Expandmode, 603 sitemapmode = settings.SitemapMode, 604 template = settings.Template 605 }) 606 } 607 @using Dynamicweb.Rapido.Blocks.Components.General 608 @using Dynamicweb.Rapido.Blocks.Components 609 610 611 @* Component *@ 612 613 @helper RenderBreadcrumbNavigation(BreadcrumbNavigation settings) { 614 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 615 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 616 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 617 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 618 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 619 settings.SitemapMode = false; 620 621 @RenderNavigation(settings) 622 } 623 @using Dynamicweb.Rapido.Blocks.Components.General 624 @using Dynamicweb.Rapido.Blocks.Components 625 626 627 @* Component *@ 628 629 @helper RenderLeftNavigation(LeftNavigation settings) { 630 settings.Id = String.IsNullOrEmpty(settings.Id) ? "breadcrumb" : settings.Id; 631 settings.Template = String.IsNullOrEmpty(settings.Template) ? "Breadcrumb.xslt" : settings.Template; 632 settings.StartLevel = settings.StartLevel == 0 ? 1 : settings.StartLevel; 633 settings.EndLevel = settings.EndLevel == 10 ? 1 : settings.EndLevel; 634 settings.Expandmode = String.IsNullOrEmpty(settings.Expandmode) ? "all" : settings.Expandmode; 635 636 <div class="grid__cell"> 637 @RenderNavigation(settings) 638 </div> 639 } 640 @using System.Reflection 641 @using Dynamicweb.Rapido.Blocks.Components.General 642 @using Dynamicweb.Core 643 644 @* Component *@ 645 646 @helper RenderHeading(Heading settings) 647 { 648 if (settings != null && !string.IsNullOrEmpty(settings.Title)) 649 { 650 string color = settings.Color != null ? "style=\"color: " + settings.Color + "\"" : ""; 651 string tagName = settings.Level != 0 ? "h" + settings.Level.ToString() : "div"; 652 653 @("<" + tagName + " class=\"" + settings.CssClass + " dw-mod\" " + color + ">") 654 if (!string.IsNullOrEmpty(settings.Link)) 655 { 656 @Render(new Link { Href = settings.Link, Icon = settings.Icon, Title = settings.Title, ButtonLayout = ButtonLayout.None }) 657 } 658 else 659 { 660 if (settings.Icon == null) 661 { 662 settings.Icon = new Icon(); 663 } 664 settings.Icon.Label = settings.Title; 665 @Render(settings.Icon) 666 } 667 @("</" + tagName + ">"); 668 } 669 } 670 @using Dynamicweb.Rapido.Blocks.Components 671 @using Dynamicweb.Rapido.Blocks.Components.General 672 @using Dynamicweb.Rapido.Blocks 673 674 675 @* Component *@ 676 677 @helper RenderImage(Image settings) 678 { 679 if (settings.FilterPrimary != ImageFilter.None || settings.FilterSecondary != ImageFilter.None) 680 { 681 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 682 if (!string.IsNullOrEmpty(settings.FilterColor)) { optionalAttributes.Add("style", "background-color: " + settings.FilterColor); } 683 684 if (settings.Caption != null) 685 { 686 @:<div> 687 } 688 689 var primaryFilterClass = settings.FilterPrimary.ToString().ToLower(); 690 var secondaryFilterClass = settings.FilterSecondary.ToString().ToLower(); 691 692 <div class="image-filter image-filter--@primaryFilterClass u-position-relative dw-mod" @ComponentMethods.AddAttributes(optionalAttributes)> 693 <div class="image-filter image-filter--@secondaryFilterClass dw-mod"> 694 @if (settings.Link != null) 695 { 696 <a href="@settings.Link"> 697 @RenderTheImage(settings) 698 </a> 699 } 700 else 701 { 702 @RenderTheImage(settings) 703 } 704 </div> 705 </div> 706 707 if (settings.Caption != null) 708 { 709 <span class="image-caption dw-mod">@settings.Caption</span> 710 @:</div> 711 } 712 } 713 else 714 { 715 if (settings.Caption != null) 716 { 717 @:<div> 718 } 719 if (!string.IsNullOrEmpty(settings.Link)) 720 { 721 <a href="@settings.Link"> 722 @RenderTheImage(settings) 723 </a> 724 } 725 else 726 { 727 @RenderTheImage(settings) 728 } 729 730 if (settings.Caption != null) 731 { 732 <span class="image-caption dw-mod">@settings.Caption</span> 733 @:</div> 734 } 735 } 736 } 737 738 @helper RenderTheImage(Image settings) 739 { 740 if (settings != null) 741 { 742 string placeholderImage = "/Files/Images/placeholder.gif"; 743 string imageEngine = "/Admin/Public/GetImage.ashx?"; 744 745 string imageStyle = ""; 746 747 switch (settings.Style) 748 { 749 case ImageStyle.Ball: 750 imageStyle = "grid__cell-img--ball"; 751 break; 752 } 753 754 if (settings.Style == ImageStyle.Ball || settings.Style == ImageStyle.Circle) 755 { 756 if (settings.ImageDefault != null) 757 { 758 settings.ImageDefault.Height = settings.ImageDefault.Width; 759 } 760 if (settings.ImageMedium != null) 761 { 762 settings.ImageMedium.Height = settings.ImageMedium.Width; 763 } 764 if (settings.ImageSmall != null) 765 { 766 settings.ImageSmall.Height = settings.ImageSmall.Width; 767 } 768 } 769 770 string defaultImage = imageEngine; 771 string imageSmall = ""; 772 string imageMedium = ""; 773 774 if (settings.DisableImageEngine) 775 { 776 defaultImage = settings.Path; 777 } 778 else 779 { 780 if (settings.ImageDefault != null) 781 { 782 defaultImage += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageDefault); 783 784 if (settings.Path.GetType() != typeof(string)) 785 { 786 defaultImage += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 787 defaultImage += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 788 } 789 else 790 { 791 defaultImage += settings.Path != null ? "Image=" + settings.Path : ""; 792 } 793 } 794 795 if (settings.ImageSmall != null) 796 { 797 imageSmall = "data-src-small=\"" + imageEngine; 798 imageSmall += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageSmall); 799 800 if (settings.Path.GetType() != typeof(string)) 801 { 802 imageSmall += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 803 imageSmall += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 804 } 805 else 806 { 807 imageSmall += settings.Path != null ? "Image=" + settings.Path : ""; 808 } 809 810 imageSmall += "\""; 811 } 812 813 if (settings.ImageMedium != null) 814 { 815 imageMedium = "data-src-medium=\"" + imageEngine; 816 imageMedium += Dynamicweb.Rapido.Services.Images.GetImagePathFromSettings(settings.ImageMedium); 817 818 if (settings.Path.GetType() != typeof(string)) 819 { 820 imageMedium += settings.Path != null ? "Image=" + settings.Path.PathUrlEncoded : ""; 821 imageMedium += settings.Path != null ? "&" + settings.Path.GetFocalPointParameters() : ""; 822 } 823 else 824 { 825 imageMedium += settings.Path != null ? "Image=" + settings.Path : ""; 826 } 827 828 imageMedium += "\""; 829 } 830 } 831 832 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 833 if (!string.IsNullOrEmpty(settings.OnClick)) { optionalAttributes.Add("onclick", settings.OnClick); } 834 if (!string.IsNullOrEmpty(settings.Title)) 835 { 836 optionalAttributes.Add("alt", settings.Title); 837 optionalAttributes.Add("title", settings.Title); 838 } 839 840 if (settings.DisableLazyLoad) 841 { 842 <img id="@settings.Id" class="@imageStyle @settings.CssClass dw-mod" src="@defaultImage" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes) /> 843 } 844 else 845 { 846 <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) /> 847 } 848 } 849 } 850 @using System.Reflection 851 @using Dynamicweb.Rapido.Blocks.Components.General 852 @using Dynamicweb.Rapido.Blocks.Components 853 854 @* Component *@ 855 856 @helper RenderFileField(FileField settings) 857 { 858 var attributes = new Dictionary<string, string>(); 859 if (string.IsNullOrEmpty(settings.Id)) 860 { 861 settings.Id = Guid.NewGuid().ToString("N"); 862 } 863 864 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 865 if (settings.Disabled) { attributes.Add("disabled", "true"); } 866 if (settings.Required) { attributes.Add("required", "true"); } 867 if (settings.Multiple) { attributes.Add("multiple", "true"); } 868 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 869 if (string.IsNullOrEmpty(settings.ChooseFileText)) 870 { 871 settings.ChooseFileText = Translate("Choose file"); 872 } 873 if (string.IsNullOrEmpty(settings.NoFilesChosenText)) 874 { 875 settings.NoFilesChosenText = Translate("No files chosen..."); 876 } 877 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 878 879 string setValueToFakeInput = "FileUpload.setValueToFakeInput(this)"; 880 attributes.Add("onchange", setValueToFakeInput + (!string.IsNullOrEmpty(settings.OnChange) ? settings.OnChange : "")); 881 882 attributes.Add("type", "file"); 883 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 884 settings.CssClass = "u-full-width " + settings.CssClass; 885 886 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 887 888 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 889 @if (!string.IsNullOrEmpty(settings.Label)) 890 { 891 <label for="@settings.Id">@settings.Label</label> 892 } 893 @if (!string.IsNullOrEmpty(settings.HelpText)) 894 { 895 <small class="form__help-text">@settings.HelpText</small> 896 } 897 898 <div class="form__field-combi file-input u-no-margin dw-mod"> 899 <input @ComponentMethods.AddAttributes(resultAttributes) class="file-input__real-input" data-no-files-text="@settings.NoFilesChosenText" data-many-files-text="@Translate("files")" /> 900 <label for="@settings.Id" class="file-input__btn btn--secondary btn dw-mod">@settings.ChooseFileText</label> 901 <label for="@settings.Id" class="@settings.CssClass file-input__fake-input js-fake-input dw-mod">@settings.NoFilesChosenText</label> 902 @if (settings.UploadButton != null) 903 { 904 settings.UploadButton.CssClass += " btn--condensed u-no-margin"; 905 @Render(settings.UploadButton) 906 } 907 </div> 908 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 909 </div> 910 } 911 @using System.Reflection 912 @using Dynamicweb.Rapido.Blocks.Components.General 913 @using Dynamicweb.Rapido.Blocks.Components 914 @using Dynamicweb.Core 915 @using System.Linq 916 917 @* Component *@ 918 919 @helper RenderDateTimeField(DateTimeField settings) 920 { 921 if (string.IsNullOrEmpty(settings.Id)) 922 { 923 settings.Id = Guid.NewGuid().ToString("N"); 924 } 925 926 var textField = new TextField { 927 Name = settings.Name, 928 Id = settings.Id, 929 Label = settings.Label, 930 HelpText = settings.HelpText, 931 Value = settings.Value, 932 Disabled = settings.Disabled, 933 Required = settings.Required, 934 ErrorMessage = settings.ErrorMessage, 935 CssClass = settings.CssClass, 936 WrapperCssClass = settings.WrapperCssClass, 937 OnChange = settings.OnChange, 938 OnClick = settings.OnClick, 939 ExtraAttributes = settings.ExtraAttributes, 940 // 941 Placeholder = settings.Placeholder 942 }; 943 944 @Render(textField) 945 946 List<string> jsAttributes = new List<string>(); 947 948 jsAttributes.Add("mode: '" + Enum.GetName(typeof(DateTimeFieldMode), settings.Mode).ToLower() + "'"); 949 950 if (!string.IsNullOrEmpty(settings.DateFormat)) 951 { 952 jsAttributes.Add("dateFormat: '" + settings.DateFormat + "'"); 953 } 954 if (!string.IsNullOrEmpty(settings.MinDate)) 955 { 956 jsAttributes.Add("minDate: '" + settings.MinDate + "'"); 957 } 958 if (!string.IsNullOrEmpty(settings.MaxDate)) 959 { 960 jsAttributes.Add("maxDate: '" + settings.MaxDate + "'"); 961 } 962 if (settings.IsInline) 963 { 964 jsAttributes.Add("inline: " + Converter.ToString(settings.IsInline).ToLower()); 965 } 966 if (settings.EnableTime) 967 { 968 jsAttributes.Add("enableTime: " + Converter.ToString(settings.EnableTime).ToLower()); 969 } 970 if (settings.EnableWeekNumbers) 971 { 972 jsAttributes.Add("weekNumbers: " + Converter.ToString(settings.EnableWeekNumbers).ToLower()); 973 } 974 975 jsAttributes.AddRange(settings.GetFlatPickrOptions().Select(x => x.Key + ": " + x.Value)); 976 977 <script> 978 document.addEventListener("DOMContentLoaded", function () { 979 flatpickr("#@textField.Id", { 980 @string.Join(",", jsAttributes) 981 }); 982 }); 983 </script> 984 } 985 @using System.Reflection 986 @using Dynamicweb.Rapido.Blocks.Components.General 987 @using Dynamicweb.Rapido.Blocks.Components 988 989 @* Component *@ 990 991 @helper RenderTextField(TextField settings) 992 { 993 var attributes = new Dictionary<string, string>(); 994 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 995 { 996 settings.Id = Guid.NewGuid().ToString("N"); 997 } 998 999 /*base settings*/ 1000 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1001 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1002 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1003 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1004 if (settings.Required) { attributes.Add("required", "true"); } 1005 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1006 /*end*/ 1007 1008 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1009 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1010 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1011 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1012 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1013 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1014 attributes.Add("type", Enum.GetName(typeof(TextFieldType), settings.Type).ToLower()); 1015 if (settings.Type == TextFieldType.Password) { attributes.Add("autocomplete", "off"); }; 1016 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1017 settings.CssClass = "u-full-width " + settings.CssClass; 1018 1019 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1020 1021 string noMargin = "u-no-margin"; 1022 if (!settings.ReadOnly) { 1023 noMargin = ""; 1024 } 1025 1026 <div class="form__field-group u-full-width @noMargin @settings.WrapperCssClass dw-mod"> 1027 @if (!string.IsNullOrEmpty(settings.Label)) 1028 { 1029 <label for="@settings.Id" id="label_@settings.Id">@settings.Label</label> 1030 } 1031 @if (!string.IsNullOrEmpty(settings.HelpText)) 1032 { 1033 <small class="form__help-text">@settings.HelpText</small> 1034 } 1035 1036 @if (settings.ActionButton != null) 1037 { 1038 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1039 <div class="form__field-combi u-no-margin dw-mod"> 1040 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1041 @Render(settings.ActionButton) 1042 </div> 1043 } 1044 else 1045 { 1046 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1047 } 1048 1049 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1050 </div> 1051 } 1052 @using System.Reflection 1053 @using Dynamicweb.Rapido.Blocks.Components.General 1054 @using Dynamicweb.Rapido.Blocks.Components 1055 1056 @* Component *@ 1057 1058 @helper RenderNumberField(NumberField settings) 1059 { 1060 var attributes = new Dictionary<string, string>(); 1061 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1062 { 1063 settings.Id = Guid.NewGuid().ToString("N"); 1064 } 1065 1066 /*base settings*/ 1067 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1068 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1069 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1070 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1071 if (settings.Required) { attributes.Add("required", "true"); } 1072 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1073 /*end*/ 1074 1075 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1076 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1077 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1078 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1079 if (settings.Max != null) { attributes.Add("max", settings.Max.ToString()); } 1080 if (settings.Min != null) { attributes.Add("min", settings.Min.ToString()); } 1081 if (settings.Step != 0) { attributes.Add("step", settings.Step.ToString()); } 1082 if (settings.Value != null && !string.IsNullOrEmpty(settings.Value.ToString())) { attributes.Add("value", settings.Value.ToString()); } 1083 attributes.Add("type", "number"); 1084 1085 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1086 1087 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1088 @if (!string.IsNullOrEmpty(settings.Label)) 1089 { 1090 <label for="@settings.Id">@settings.Label</label> 1091 } 1092 @if (!string.IsNullOrEmpty(settings.HelpText)) 1093 { 1094 <small class="form__help-text">@settings.HelpText</small> 1095 } 1096 1097 @if (settings.ActionButton != null) 1098 { 1099 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1100 <div class="form__field-combi u-no-margin dw-mod"> 1101 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1102 @Render(settings.ActionButton) 1103 </div> 1104 } 1105 else 1106 { 1107 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1108 } 1109 1110 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1111 </div> 1112 } 1113 @using System.Reflection 1114 @using Dynamicweb.Rapido.Blocks.Components.General 1115 @using Dynamicweb.Rapido.Blocks.Components 1116 1117 1118 @* Component *@ 1119 1120 @helper RenderTextareaField(TextareaField settings) 1121 { 1122 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1123 string id = settings.Id; 1124 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(id)) 1125 { 1126 id = Guid.NewGuid().ToString("N"); 1127 } 1128 1129 if (!string.IsNullOrEmpty(id)) { attributes.Add("id", id); } 1130 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1131 if (!string.IsNullOrEmpty(settings.OnKeyUp)) { attributes.Add("onkeyup", settings.OnKeyUp); } 1132 if (!string.IsNullOrEmpty(settings.OnInput)) { attributes.Add("oninput", settings.OnInput); } 1133 if (!string.IsNullOrEmpty(settings.OnFocus)) { attributes.Add("onfocus", settings.OnFocus); } 1134 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1135 if (!string.IsNullOrEmpty(settings.Placeholder)) { attributes.Add("placeholder", settings.Placeholder); } 1136 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1137 if (settings.Required) { attributes.Add("required", "true"); } 1138 if (settings.ReadOnly) { attributes.Add("readonly", "true"); } 1139 if (settings.MaxLength != 0) { attributes.Add("maxlength", settings.MaxLength.ToString()); } 1140 if (settings.Rows != 0) { attributes.Add("rows", settings.Rows.ToString()); } 1141 attributes.Add("name", settings.Name); 1142 1143 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1144 @if (!string.IsNullOrEmpty(settings.Label)) 1145 { 1146 <label for="@id">@settings.Label</label> 1147 } 1148 @if (!string.IsNullOrEmpty(settings.HelpText)) 1149 { 1150 <small class="form__help-text">@settings.HelpText</small> 1151 } 1152 1153 <textarea class="u-full-width @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Value</textarea> 1154 1155 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1156 </div> 1157 } 1158 @using System.Reflection 1159 @using Dynamicweb.Rapido.Blocks.Components.General 1160 @using Dynamicweb.Rapido.Blocks.Components 1161 1162 1163 @* Component *@ 1164 1165 @helper RenderHiddenField(HiddenField settings) { 1166 var attributes = new Dictionary<string, string>(); 1167 attributes.Add("type", "hidden"); 1168 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1169 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1170 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1171 1172 <input @ComponentMethods.AddAttributes(attributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)/> 1173 } 1174 @using System.Reflection 1175 @using Dynamicweb.Rapido.Blocks.Components.General 1176 @using Dynamicweb.Rapido.Blocks.Components 1177 1178 @* Component *@ 1179 1180 @helper RenderCheckboxField(CheckboxField settings) 1181 { 1182 var attributes = new Dictionary<string, string>(); 1183 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1184 { 1185 settings.Id = Guid.NewGuid().ToString("N"); 1186 } 1187 1188 /*base settings*/ 1189 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1190 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1191 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1192 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1193 if (settings.Required) { attributes.Add("required", "true"); } 1194 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1195 /*end*/ 1196 1197 attributes.Add("type", "checkbox"); 1198 if (settings.Checked) { attributes.Add("checked", "true"); } 1199 settings.CssClass = "form__control " + settings.CssClass; 1200 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1201 1202 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1203 1204 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1205 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1206 @if (!string.IsNullOrEmpty(settings.Label)) 1207 { 1208 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1209 } 1210 @if (!string.IsNullOrEmpty(settings.HelpText)) 1211 { 1212 <small class="form__help-text">@settings.HelpText</small> 1213 } 1214 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1215 </div> 1216 } 1217 @using System.Reflection 1218 @using Dynamicweb.Rapido.Blocks.Components.General 1219 @using Dynamicweb.Rapido.Blocks.Components 1220 1221 1222 @* Component *@ 1223 1224 @helper RenderCheckboxListField(CheckboxListField settings) 1225 { 1226 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1227 @if (!string.IsNullOrEmpty(settings.Label)) 1228 { 1229 <label>@settings.Label</label> 1230 } 1231 @if (!string.IsNullOrEmpty(settings.HelpText)) 1232 { 1233 <small class="form__help-text">@settings.HelpText</small> 1234 } 1235 1236 @foreach (var item in settings.Options) 1237 { 1238 if (settings.Required) 1239 { 1240 item.Required = true; 1241 } 1242 if (settings.Disabled) 1243 { 1244 item.Disabled = true; 1245 } 1246 if (!string.IsNullOrEmpty(settings.Name)) 1247 { 1248 item.Name = settings.Name; 1249 } 1250 if (!string.IsNullOrEmpty(settings.CssClass)) 1251 { 1252 item.CssClass += settings.CssClass; 1253 } 1254 1255 /* value is not supported */ 1256 1257 if (!string.IsNullOrEmpty(settings.OnClick)) 1258 { 1259 item.OnClick += settings.OnClick; 1260 } 1261 if (!string.IsNullOrEmpty(settings.OnChange)) 1262 { 1263 item.OnChange += settings.OnChange; 1264 } 1265 @Render(item) 1266 } 1267 1268 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1269 </div> 1270 } 1271 @using System.Reflection 1272 @using Dynamicweb.Rapido.Blocks.Components.General 1273 @using Dynamicweb.Rapido.Blocks.Components 1274 1275 1276 @* Component *@ 1277 1278 @helper RenderSelectField(SelectField settings) 1279 { 1280 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1281 { 1282 settings.Id = Guid.NewGuid().ToString("N"); 1283 } 1284 1285 <div class="form__field-group u-full-width @settings.WrapperCssClass dw-mod"> 1286 @if (!string.IsNullOrEmpty(settings.Label)) 1287 { 1288 <label for="@settings.Id">@settings.Label</label> 1289 } 1290 @if (!string.IsNullOrEmpty(settings.HelpText)) 1291 { 1292 <small class="form__help-text">@settings.HelpText</small> 1293 } 1294 1295 @if (settings.ActionButton != null) 1296 { 1297 settings.ActionButton.CssClass += " btn--condensed u-no-margin"; 1298 <div class="form__field-combi u-no-margin dw-mod"> 1299 @RenderSelectBase(settings) 1300 @Render(settings.ActionButton) 1301 </div> 1302 } 1303 else 1304 { 1305 @RenderSelectBase(settings) 1306 } 1307 1308 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1309 </div> 1310 } 1311 1312 @helper RenderSelectBase(SelectField settings) 1313 { 1314 var attributes = new Dictionary<string, string>(); 1315 1316 /*base settings*/ 1317 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1318 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1319 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1320 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1321 if (settings.Required) { attributes.Add("required", "true"); } 1322 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1323 /*end*/ 1324 1325 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1326 1327 <select @ComponentMethods.AddAttributes(resultAttributes) class="u-full-width @settings.CssClass dw-mod"> 1328 @if (settings.Default != null) 1329 { 1330 @Render(settings.Default) 1331 } 1332 1333 @foreach (var item in settings.Options) 1334 { 1335 if (!string.IsNullOrEmpty(settings.Value)) { 1336 item.Checked = item.Value == settings.Value; 1337 } 1338 @Render(item) 1339 } 1340 </select> 1341 } 1342 @using System.Reflection 1343 @using Dynamicweb.Rapido.Blocks.Components.General 1344 @using Dynamicweb.Rapido.Blocks.Components 1345 1346 @* Component *@ 1347 1348 @helper RenderRadioButtonField(RadioButtonField settings) 1349 { 1350 var attributes = new Dictionary<string, string>(); 1351 if (!string.IsNullOrEmpty(settings.Label) && string.IsNullOrEmpty(settings.Id)) 1352 { 1353 settings.Id = Guid.NewGuid().ToString("N"); 1354 } 1355 1356 /*base settings*/ 1357 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1358 if (!string.IsNullOrEmpty(settings.OnClick)) { attributes.Add("onclick", settings.OnClick); } 1359 if (!string.IsNullOrEmpty(settings.OnChange)) { attributes.Add("onchange", settings.OnChange); } 1360 if (settings.Disabled) { attributes.Add("disabled", "true"); } 1361 if (settings.Required) { attributes.Add("required", "true"); } 1362 if (!string.IsNullOrEmpty(settings.Name)) { attributes.Add("name", settings.Name); } 1363 /*end*/ 1364 1365 attributes.Add("type", "radio"); 1366 if (settings.Checked) { attributes.Add("checked", "true"); } 1367 settings.CssClass = "form__control " + settings.CssClass; 1368 if (!string.IsNullOrEmpty(settings.Value)) { attributes.Add("value", settings.Value); } 1369 1370 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary (d => d.Key, d => d.Last().Value); 1371 1372 <div class="form__field-group @settings.WrapperCssClass dw-mod"> 1373 <input @ComponentMethods.AddAttributes(resultAttributes) class="@settings.CssClass dw-mod" /> 1374 @if (!string.IsNullOrEmpty(settings.Label)) 1375 { 1376 <label for="@settings.Id" class="dw-mod">@settings.Label</label> 1377 } 1378 @if (!string.IsNullOrEmpty(settings.HelpText)) 1379 { 1380 <small class="form__help-text">@settings.HelpText</small> 1381 } 1382 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1383 </div> 1384 } 1385 @using System.Reflection 1386 @using Dynamicweb.Rapido.Blocks.Components.General 1387 @using Dynamicweb.Rapido.Blocks.Components 1388 1389 1390 @* Component *@ 1391 1392 @helper RenderRadioButtonListField(RadioButtonListField settings) 1393 { 1394 <div class="form__field-group @settings.WrapperCssClass u-margin-bottom dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1395 @if (!string.IsNullOrEmpty(settings.Label)) 1396 { 1397 <label>@settings.Label</label> 1398 } 1399 @if (!string.IsNullOrEmpty(settings.HelpText)) 1400 { 1401 <small class="form__help-text">@settings.HelpText</small> 1402 } 1403 1404 @foreach (var item in settings.Options) 1405 { 1406 if (settings.Required) 1407 { 1408 item.Required = true; 1409 } 1410 if (settings.Disabled) 1411 { 1412 item.Disabled = true; 1413 } 1414 if (!string.IsNullOrEmpty(settings.Name)) 1415 { 1416 item.Name = settings.Name; 1417 } 1418 if (!string.IsNullOrEmpty(settings.Value) && settings.Value == item.Value) 1419 { 1420 item.Checked = true; 1421 } 1422 if (!string.IsNullOrEmpty(settings.OnClick)) 1423 { 1424 item.OnClick += settings.OnClick; 1425 } 1426 if (!string.IsNullOrEmpty(settings.OnChange)) 1427 { 1428 item.OnChange += settings.OnChange; 1429 } 1430 if (!string.IsNullOrEmpty(settings.CssClass)) 1431 { 1432 item.CssClass += settings.CssClass; 1433 } 1434 @Render(item) 1435 } 1436 1437 @Render(new NotificationMessage { Message = settings.ErrorMessage }) 1438 </div> 1439 } 1440 @using System.Reflection 1441 @using Dynamicweb.Rapido.Blocks.Components.General 1442 @using Dynamicweb.Rapido.Blocks.Components 1443 1444 1445 @* Component *@ 1446 1447 @helper RenderNotificationMessage(NotificationMessage settings) 1448 { 1449 if (!string.IsNullOrEmpty(settings.Message)) 1450 { 1451 var attributes = new Dictionary<string, string>(); 1452 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1453 1454 string messageTypeClass = Enum.GetName(typeof(NotificationMessageType), settings.MessageType).ToLower(); 1455 <div class="field-@messageTypeClass @settings.CssClass u-full-width dw-mod" @ComponentMethods.AddAttributes(attributes)>@settings.Message</div> 1456 } 1457 } 1458 @using Dynamicweb.Rapido.Blocks.Components.General 1459 1460 1461 @* Component *@ 1462 1463 @helper RenderHandlebarsRoot(HandlebarsRoot settings) { 1464 string preRender = !String.IsNullOrEmpty(settings.PreRenderScriptTemplate) ? "data-pre-render-template=\"" + settings.PreRenderScriptTemplate + "\"" : ""; 1465 1466 <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> 1467 @if (settings.SubBlocks != null) { 1468 @RenderBlockList(settings.SubBlocks) 1469 } 1470 </div> 1471 } 1472 @using System.Reflection 1473 @using Dynamicweb.Rapido.Blocks.Components.General 1474 @using Dynamicweb.Rapido.Blocks.Components 1475 @using System.Text.RegularExpressions 1476 1477 1478 @* Component *@ 1479 1480 @helper RenderSticker(Sticker settings) { 1481 if (!String.IsNullOrEmpty(settings.Title)) { 1482 string size = settings.Size.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Size.ToString().ToLower() : ""; 1483 string style = settings.Style.ToString() != "None" ? "" + "stickers-container__tag--" + settings.Style.ToString().ToLower() : ""; 1484 1485 Dictionary<String, String> optionalAttributes = new Dictionary<string, string>(); 1486 if (!String.IsNullOrEmpty(settings.Color) || !String.IsNullOrEmpty(settings.BackgroundColor)) { 1487 string styleTag = !String.IsNullOrEmpty(settings.Color) ? "color: " + settings.Color + "; " : ""; 1488 styleTag += !String.IsNullOrEmpty(settings.BackgroundColor) ? "background-color: " + settings.BackgroundColor + "; " : ""; 1489 optionalAttributes.Add("style", styleTag); 1490 } 1491 1492 <div class="stickers-container__tag @size @style @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)>@settings.Title</div> 1493 } 1494 } 1495 1496 @using System.Reflection 1497 @using Dynamicweb.Rapido.Blocks.Components.General 1498 @using Dynamicweb.Rapido.Blocks.Components 1499 1500 1501 @* Component *@ 1502 1503 @helper RenderStickersCollection(StickersCollection settings) 1504 { 1505 if (settings.Stickers.Count > 0) 1506 { 1507 string position = "stickers-container--" + Regex.Replace(settings.Position.ToString(), "([a-z])([A-Z])", "$1-$2").ToLower(); 1508 1509 <div class="stickers-container @position @settings.CssClass dw-mod" @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1510 @foreach (Sticker sticker in settings.Stickers) 1511 { 1512 @Render(sticker) 1513 } 1514 </div> 1515 } 1516 } 1517 1518 @using Dynamicweb.Rapido.Blocks.Components.General 1519 1520 1521 @* Component *@ 1522 1523 @helper RenderForm(Form settings) { 1524 if (settings != null) 1525 { 1526 Dictionary<string, string> optionalAttributes = new Dictionary<string, string>(); 1527 if (!string.IsNullOrEmpty(settings.Action)) { optionalAttributes.Add("action", settings.Action); }; 1528 if (!string.IsNullOrEmpty(settings.Name)) { optionalAttributes.Add("name", settings.Name); }; 1529 if (!string.IsNullOrEmpty(settings.OnSubmit)) { optionalAttributes.Add("onsubmit", settings.OnSubmit); }; 1530 var enctypes = new Dictionary<string, string> 1531 { 1532 { "multipart", "multipart/form-data" }, 1533 { "text", "text/plain" }, 1534 { "application", "application/x-www-form-urlencoded" } 1535 }; 1536 if (settings.Enctype != FormEnctype.none) { optionalAttributes.Add("enctype", enctypes[Enum.GetName(typeof(FormEnctype), settings.Enctype).ToLower()]); }; 1537 optionalAttributes.Add("method", settings.Method.ToString()); 1538 1539 if (!string.IsNullOrEmpty(settings.FormStartMarkup)) 1540 { 1541 @settings.FormStartMarkup 1542 } 1543 else 1544 { 1545 @:<form class="@settings.CssClass u-no-margin dw-mod" @ComponentMethods.AddAttributes(optionalAttributes) @ComponentMethods.AddAttributes(settings.ExtraAttributes)> 1546 } 1547 1548 foreach (var field in settings.GetFields()) 1549 { 1550 @Render(field) 1551 } 1552 1553 @:</form> 1554 } 1555 } 1556 @using System.Reflection 1557 @using Dynamicweb.Rapido.Blocks.Components.General 1558 @using Dynamicweb.Rapido.Blocks.Components 1559 1560 1561 @* Component *@ 1562 1563 @helper RenderText(Text settings) 1564 { 1565 @settings.Content 1566 } 1567 @using System.Reflection 1568 @using Dynamicweb.Rapido.Blocks.Components.General 1569 @using Dynamicweb.Rapido.Blocks.Components 1570 1571 1572 @* Component *@ 1573 1574 @helper RenderContentModule(ContentModule settings) { 1575 if (!string.IsNullOrEmpty(settings.Content)) 1576 { 1577 @settings.Content 1578 } 1579 } 1580 @using System.Reflection 1581 @using Dynamicweb.Rapido.Blocks.Components.General 1582 @using Dynamicweb.Rapido.Blocks.Components 1583 1584 1585 @* Component *@ 1586 1587 @helper RenderModal(Modal settings) { 1588 if (settings != null) 1589 { 1590 string modalId = !string.IsNullOrEmpty(settings.Id) ? settings.Id : Guid.NewGuid().ToString("N"); 1591 1592 string onchange = !string.IsNullOrEmpty(settings.OnClose) ? "onchange=\"if(!this.checked){" + settings.OnClose + "}\"" : ""; 1593 1594 <input type="checkbox" id="@(modalId)ModalTrigger" class="modal-trigger" @onchange /> 1595 1596 <div class="modal-container"> 1597 @if (!settings.DisableDarkOverlay) 1598 { 1599 <label for="@(modalId)ModalTrigger" id="@(modalId)ModalOverlay" class="modal-overlay"></label> 1600 } 1601 <div class="modal modal--@settings.Width.ToString().ToLower() modal-height--@settings.Height.ToString().ToLower()" id="@(modalId)Modal"> 1602 @if (settings.Heading != null) 1603 { 1604 if (!string.IsNullOrEmpty(settings.Heading.Title)) 1605 { 1606 <div class="modal__header"> 1607 @Render(settings.Heading) 1608 </div> 1609 } 1610 } 1611 <div class="modal__body @(settings.Width.ToString().ToLower() == "full" ? "modal__body--full" : "")"> 1612 @if (!string.IsNullOrEmpty(settings.BodyText)) 1613 { 1614 @settings.BodyText 1615 } 1616 @if (settings.BodyTemplate != null) 1617 { 1618 @settings.BodyTemplate 1619 } 1620 @{ 1621 var actions = settings.GetActions(); 1622 } 1623 </div> 1624 @if (actions.Length > 0) 1625 { 1626 <div class="modal__footer"> 1627 @foreach (var action in actions) 1628 { 1629 action.CssClass += " u-no-margin"; 1630 @Render(action) 1631 } 1632 </div> 1633 } 1634 <label class="modal__close-btn" for="@(modalId)ModalTrigger"></label> 1635 </div> 1636 </div> 1637 } 1638 } 1639 @using Dynamicweb.Rapido.Blocks.Components.General 1640 1641 @* Component *@ 1642 1643 @helper RenderMediaListItem(MediaListItem settings) 1644 { 1645 <div class="media-list-item @settings.CssClass dw-mod" @(!string.IsNullOrEmpty(settings.Id) ? "id=\"" + settings.Id + "\"" : "")> 1646 @if (!string.IsNullOrEmpty(settings.Label)) 1647 { 1648 if (!string.IsNullOrEmpty(settings.Link)) 1649 { 1650 @Render(new Link 1651 { 1652 Href = settings.Link, 1653 CssClass = "media-list-item__sticker dw-mod", 1654 ButtonLayout = ButtonLayout.None, 1655 Title = settings.Label, 1656 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1657 }) 1658 } 1659 else if (!string.IsNullOrEmpty(settings.OnClick)) 1660 { 1661 <span class="media-list-item__sticker dw-mod" onclick="@(settings.OnClick)"> 1662 <span class="u-uppercase">@settings.Label</span> 1663 </span> 1664 } 1665 else 1666 { 1667 <span class="media-list-item__sticker media-list-item__sticker--no-link dw-mod"> 1668 <span class="u-uppercase">@settings.Label</span> 1669 </span> 1670 } 1671 } 1672 <div class="media-list-item__wrap"> 1673 <div class="media-list-item__info dw-mod"> 1674 <div class="media-list-item__header dw-mod"> 1675 @if (!string.IsNullOrEmpty(settings.Title)) 1676 { 1677 if (!string.IsNullOrEmpty(settings.Link)) 1678 { 1679 @Render(new Link 1680 { 1681 Href = settings.Link, 1682 CssClass = "media-list-item__name dw-mod", 1683 ButtonLayout = ButtonLayout.None, 1684 Title = settings.Title, 1685 OnClick = !string.IsNullOrEmpty(settings.OnClick) ? settings.OnClick : "" 1686 }) 1687 } 1688 else if (!string.IsNullOrEmpty(settings.OnClick)) 1689 { 1690 <span class="media-list-item__name dw-mod" onclick="@(settings.OnClick)">@settings.Title</span> 1691 } 1692 else 1693 { 1694 <span class="media-list-item__name media-list-item__name--no-link dw-mod">@settings.Title</span> 1695 } 1696 } 1697 1698 @if (!string.IsNullOrEmpty(settings.Status)) 1699 { 1700 <div class="media-list-item__state dw-mod">@settings.Status</div> 1701 } 1702 </div> 1703 @{ 1704 settings.InfoTable.CssClass += " media-list-item__parameters-table"; 1705 } 1706 1707 @Render(settings.InfoTable) 1708 </div> 1709 <div class="media-list-item__actions dw-mod"> 1710 <div class="media-list-item__actions-list dw-mod"> 1711 @{ 1712 var actions = settings.GetActions(); 1713 1714 foreach (ButtonBase action in actions) 1715 { 1716 action.ButtonLayout = ButtonLayout.None; 1717 action.CssClass += " media-list-item__action link"; 1718 1719 @Render(action) 1720 } 1721 } 1722 </div> 1723 1724 @if (settings.SelectButton != null && !string.IsNullOrEmpty(settings.SelectButton.Title)) 1725 { 1726 settings.SelectButton.CssClass += " u-no-margin"; 1727 1728 <div class="media-list-item__action-button"> 1729 @Render(settings.SelectButton) 1730 </div> 1731 } 1732 </div> 1733 </div> 1734 </div> 1735 } 1736 @using Dynamicweb.Rapido.Blocks.Components.General 1737 @using Dynamicweb.Rapido.Blocks.Components 1738 1739 @helper RenderTable(Table settings) 1740 { 1741 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1742 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1743 1744 var enumToClasses = new Dictionary<TableDesign, string> 1745 { 1746 { TableDesign.Clean, "table--clean" }, 1747 { TableDesign.Bordered, "table--bordered" }, 1748 { TableDesign.Striped, "table--striped" }, 1749 { TableDesign.Hover, "table--hover" }, 1750 { TableDesign.Compact, "table--compact" }, 1751 { TableDesign.Condensed, "table--condensed" }, 1752 { TableDesign.NoTopBorder, "table--no-top-border" } 1753 }; 1754 string tableDesignClass = ""; 1755 if (settings.Design != TableDesign.None) 1756 { 1757 tableDesignClass = enumToClasses[settings.Design]; 1758 } 1759 1760 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableDesign.None) { attributes.Add("class", "table " + tableDesignClass + " " + settings.CssClass + " dw-mod"); } 1761 1762 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1763 1764 <table @ComponentMethods.AddAttributes(resultAttributes)> 1765 @if (settings.Header != null) 1766 { 1767 <thead> 1768 @Render(settings.Header) 1769 </thead> 1770 } 1771 <tbody> 1772 @foreach (var row in settings.Rows) 1773 { 1774 @Render(row) 1775 } 1776 </tbody> 1777 @if (settings.Footer != null) 1778 { 1779 <tfoot> 1780 @Render(settings.Footer) 1781 </tfoot> 1782 } 1783 </table> 1784 } 1785 @using Dynamicweb.Rapido.Blocks.Components.General 1786 @using Dynamicweb.Rapido.Blocks.Components 1787 1788 @helper RenderTableRow(TableRow settings) 1789 { 1790 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1791 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1792 1793 var enumToClasses = new Dictionary<TableRowDesign, string> 1794 { 1795 { TableRowDesign.NoBorder, "table__row--no-border" }, 1796 { TableRowDesign.Border, "table__row--border" }, 1797 { TableRowDesign.TopBorder, "table__row--top-line" }, 1798 { TableRowDesign.BottomBorder, "table__row--bottom-line" }, 1799 { TableRowDesign.Solid, "table__row--solid" } 1800 }; 1801 1802 string tableRowDesignClass = ""; 1803 if (settings.Design != TableRowDesign.None) 1804 { 1805 tableRowDesignClass = enumToClasses[settings.Design]; 1806 } 1807 1808 if (!string.IsNullOrEmpty(settings.CssClass) || settings.Design != TableRowDesign.None) { attributes.Add("class", "table__row " + tableRowDesignClass + " " + settings.CssClass + " dw-mod"); } 1809 1810 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1811 1812 <tr @ComponentMethods.AddAttributes(resultAttributes)> 1813 @foreach (var cell in settings.Cells) 1814 { 1815 if (settings.IsHeaderRow) 1816 { 1817 cell.IsHeader = true; 1818 } 1819 @Render(cell) 1820 } 1821 </tr> 1822 } 1823 @using Dynamicweb.Rapido.Blocks.Components.General 1824 @using Dynamicweb.Rapido.Blocks.Components 1825 @using Dynamicweb.Core 1826 1827 @helper RenderTableCell(TableCell settings) 1828 { 1829 Dictionary<string, string> attributes = new Dictionary<string, string>(); 1830 if (!string.IsNullOrEmpty(settings.Id)) { attributes.Add("id", settings.Id); } 1831 if (settings.Colspan != 0) { attributes.Add("colspan", Converter.ToString(settings.Colspan)); } 1832 if (settings.Rowspan != 0) { attributes.Add("rowspan", Converter.ToString(settings.Rowspan)); } 1833 if (!string.IsNullOrEmpty(settings.CssClass)) { attributes.Add("class", settings.CssClass + " dw-mod"); } 1834 1835 var resultAttributes = attributes.Concat(settings.ExtraAttributes).GroupBy(d => d.Key).ToDictionary(d => d.Key, d => d.Last().Value); 1836 1837 string tagName = settings.IsHeader ? "th" : "td"; 1838 1839 @("<" + tagName + " " + ComponentMethods.AddAttributes(resultAttributes) + " title="+ settings.Content.Replace(" ", "&nbsp;") + ">") 1840 1841 @settings.Content 1842 @("</" + tagName + ">"); 1843 } 1844 @using System.Linq 1845 @using Dynamicweb.Rapido.Blocks.Components.General 1846 1847 @* Component *@ 1848 1849 @helper RenderPagination(Dynamicweb.Rapido.Blocks.Components.General.Pagination settings) 1850 { 1851 var pageNumberQueryStringName = Dynamicweb.Rapido.Services.Pagination.GetPageNumberQueryStringName(settings); // Get the proper 'page number' query string parameter 1852 var queryParameters = Dynamicweb.Rapido.Services.Url.GetQueryParameters(pageNumberQueryStringName); // Get the NameValueCollection from the querystring 1853 1854 if (settings.NumberOfPages > 1) 1855 { 1856 string url = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + "/Default.aspx"; 1857 string ariaLabel = !string.IsNullOrWhiteSpace(settings.AriaLabel) ? settings.AriaLabel : Translate("Page navigation"); 1858 Dictionary<string, int> startAndEndPageNumber = Dynamicweb.Rapido.Services.Pagination.GetStartAndEndPageNumber(settings); 1859 1860 <div class="pager u-margin-top dw-mod @settings.CssClass" aria-label="@ariaLabel"> 1861 @if (settings.ShowPagingInfo) 1862 { 1863 <div class="pager__info dw-mod"> 1864 @Translate("Page") @settings.CurrentPageNumber @Translate("of") @settings.NumberOfPages 1865 </div> 1866 } 1867 <ul class="pager__list dw-mod"> 1868 @if (!string.IsNullOrWhiteSpace(settings.FirstPageUrl) && settings.ShowFirstAndLastControls) 1869 { 1870 @Render(new PaginationItem { Link = settings.FirstPageUrl, Icon = settings.FirstIcon }) 1871 } 1872 @if (!string.IsNullOrWhiteSpace(settings.PreviousPageUrl) && settings.ShowNextAndPrevControls) 1873 { 1874 @Render(new PaginationItem { Link = settings.PreviousPageUrl, Icon = settings.PrevIcon }) 1875 } 1876 @if (settings.GetPages().Any()) 1877 { 1878 foreach (var page in settings.GetPages()) 1879 { 1880 @Render(page) 1881 } 1882 } 1883 else 1884 { 1885 for (var page = startAndEndPageNumber["StartPage"]; page <= startAndEndPageNumber["EndPage"]; page++) 1886 { 1887 queryParameters = Dynamicweb.Rapido.Services.Url.UpdateQueryStringParameter(queryParameters, pageNumberQueryStringName, page.ToString()); 1888 @Render(new PaginationItem { Label = page.ToString(), Link = Dynamicweb.Rapido.Services.Url.BuildUri(url, queryParameters).PathAndQuery, IsActive = (settings.CurrentPageNumber == page) }); 1889 } 1890 } 1891 @if (!string.IsNullOrWhiteSpace(settings.NextPageUrl) && settings.ShowNextAndPrevControls) 1892 { 1893 @Render(new PaginationItem { Link = settings.NextPageUrl, Icon = settings.NextIcon }) 1894 } 1895 @if (!string.IsNullOrWhiteSpace(settings.LastPageUrl) && settings.ShowFirstAndLastControls) 1896 { 1897 @Render(new PaginationItem { Link = settings.LastPageUrl, Icon = settings.LastIcon }) 1898 } 1899 </ul> 1900 </div> 1901 } 1902 } 1903 1904 @helper RenderPaginationItem(PaginationItem settings) 1905 { 1906 if (settings.Icon == null) 1907 { 1908 settings.Icon = new Icon(); 1909 } 1910 1911 settings.Icon.Label = settings.Label; 1912 <li class="pager__btn dw-mod"> 1913 @if (settings.IsActive) 1914 { 1915 <span class="pager__num pager__num--current dw-mod"> 1916 @Render(settings.Icon) 1917 </span> 1918 } 1919 else 1920 { 1921 <a href="@settings.Link" class="pager__num dw-mod"> 1922 @Render(settings.Icon) 1923 </a> 1924 } 1925 </li> 1926 } 1927 1928 1929 @using Dynamicweb.Rapido.Blocks.Components.General 1930 @using Dynamicweb.Rapido.Blocks.Components.Ecommerce 1931 1932 1933 1934 @* Include the Blocks for the page *@ 1935 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 1936 @using Dynamicweb.Core 1937 @using System 1938 @using System.Web 1939 @using System.Collections.Generic 1940 @using Dynamicweb.Rapido.Blocks 1941 1942 @{ 1943 BlocksPage stepBarCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 1944 1945 Block checkoutSteps = new Block() 1946 { 1947 Id = "StepBar", 1948 SortId = 10, 1949 Template = RenderStepBar(), 1950 Design = new Design { 1951 RenderType = RenderType.Column, 1952 Size = "12" 1953 } 1954 }; 1955 stepBarCheckoutPage.Add("CheckoutForm", checkoutSteps); 1956 } 1957 1958 @helper RenderStepBar() 1959 { 1960 string stepNumber = ""; 1961 1962 <div class="step-bar dw-mod"> 1963 @foreach (LoopItem step in GetLoop("StepButtons")) 1964 { 1965 if (step.GetString("Step.Name").ToLower() != "checkout") 1966 { 1967 string activeStep = step.GetBoolean("Step.Current") ? "step-bar__step--active" : ""; 1968 1969 if (GetLoop("StepButtons").Count > 2) 1970 { 1971 stepNumber = step.GetString("Step.Number") + "."; 1972 } 1973 1974 <div class="step-bar__step @activeStep dw-mod"> 1975 @stepNumber @Translate(step.GetString("Step.Name")) 1976 </div> 1977 } 1978 } 1979 </div> 1980 } 1981 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 1982 @using Dynamicweb 1983 @using Dynamicweb.Core 1984 @using System 1985 @using System.Web 1986 @using System.Collections.Generic 1987 @using Dynamicweb.Rapido.Blocks 1988 @using Dynamicweb.Rapido.Blocks.Components 1989 @using Dynamicweb.Rapido.Blocks.Components.General 1990 1991 @functions{ 1992 BlocksPage reviewOrderCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 1993 string cartFeedPageId; 1994 bool canCompleteOrder = true; 1995 } 1996 1997 @{ 1998 string reviewOrderType = checkoutPageType ?? "onestep"; //The "checkoutPageType" comes from the main template for the cart page 1999 2000 cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 2001 2002 if (!String.IsNullOrWhiteSpace(GetString("Ecom:OrderContext.ID"))) 2003 { 2004 cartFeedPageId += "&OrderContext=" + GetString("Ecom:OrderContext.ID"); 2005 } 2006 2007 2008 var paymentCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 2009 var shippingCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 2010 var paymentCountryIsSupported = string.IsNullOrEmpty(paymentCountryCode) || GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == paymentCountryCode)); 2011 var shippingCountryIsSupported = string.IsNullOrEmpty(shippingCountryCode) ? paymentCountryIsSupported : GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == shippingCountryCode)); 2012 2013 canCompleteOrder = paymentCountryIsSupported && shippingCountryIsSupported; 2014 2015 Block reviewOrderBlock = new Block() 2016 { 2017 Id = "ReviewOrder", 2018 SortId = 50, 2019 SkipRenderBlocksList = true, 2020 Template = RenderReviewOrder() 2021 }; 2022 reviewOrderCheckoutPage.Add("OrderContainerRow", reviewOrderBlock); 2023 2024 if (reviewOrderType == "onestep") 2025 { 2026 Block inlineAcceptanceBlock = new Block() 2027 { 2028 Id = "Acceptance", 2029 SortId = 10, 2030 Template = RenderInlineAcceptance() 2031 }; 2032 reviewOrderCheckoutPage.Add("ReviewOrder", inlineAcceptanceBlock); 2033 2034 Block reviewOrderFooterBlock = new Block() 2035 { 2036 Id = "ReviewOrderFooter", 2037 SortId = 20, 2038 Template = RenderReviewOrderFooter() 2039 }; 2040 reviewOrderCheckoutPage.Add("ReviewOrder", reviewOrderFooterBlock); 2041 } 2042 2043 if (reviewOrderType == "quote") 2044 { 2045 Block reviewOrderFooterBlock = new Block() 2046 { 2047 Id = "ReviewOrderFooter", 2048 SortId = 20, 2049 Template = RenderReviewOrderFooterQuote() 2050 }; 2051 reviewOrderCheckoutPage.Add("ReviewOrder", reviewOrderFooterBlock); 2052 } 2053 2054 Block reviewOrderScriptTemplates = new Block() 2055 { 2056 Id = "ReviewOrderScriptTempaltes", 2057 SortId = 30, 2058 BlocksList = new List<Block> { 2059 new Block { 2060 Id = "CartContentTemplate", 2061 SortId = 10, 2062 Template = RenderCartContentTemplate() 2063 }, 2064 new Block { 2065 Id = "CartOrderlineTemplate", 2066 SortId = 20, 2067 Template = RenderCartOrderlineTemplate() 2068 }, 2069 new Block { 2070 Id = "CartOrderlineMobileTemplate", 2071 SortId = 30, 2072 Template = RenderCartOrderlineMobileTemplate() 2073 }, 2074 new Block { 2075 Id = "CartOrderlineDiscountTemplate", 2076 SortId = 40, 2077 Template = RenderCartOrderlineDiscountTemplate() 2078 }, 2079 new Block { 2080 Id = "EmptyCartTemplate", 2081 SortId = 50, 2082 Template = RenderEmptyCartTemplate() 2083 }, 2084 new Block 2085 { 2086 Id = "EmptyCartObserver", 2087 SortId = 60, 2088 Template = RenderEmptyCartObserver() 2089 } 2090 } 2091 }; 2092 reviewOrderCheckoutPage.Add("CheckoutBottomSnippets", reviewOrderScriptTemplates); 2093 2094 Block reviewOrderScripts = new Block() 2095 { 2096 Id = "ReviewOrderScripts", 2097 SortId = 40, 2098 Template = RenderOrderScripts() 2099 }; 2100 reviewOrderCheckoutPage.Add("CheckoutBottomSnippets", reviewOrderScripts); 2101 } 2102 2103 @helper RenderReviewOrder() 2104 { 2105 <div class="grid__col-12"> 2106 <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> 2107 </div> 2108 } 2109 2110 @helper RenderCartContentTemplate() 2111 { 2112 List<Block> subBlocks = reviewOrderCheckoutPage.GetBlockListById("ReviewOrder").OrderBy(item => item.SortId).ToList(); 2113 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 2114 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 2115 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(GetString("Ecom:Order.ID")); 2116 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 2117 2118 <script id="CartContent" type="text/x-template"> 2119 {{#.}} 2120 @if (useGoogleTagManager) 2121 { 2122 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text> 2123 } 2124 <div class="card-header u-color-light--bg dw-mod"> 2125 @Render(new Heading { Title = Translate("Review order") + "({{numberofproducts}})", Level = 3, Icon = new Icon { Prefix = "fas", Name = "fa-list-ul", LabelPosition = IconLabelPosition.After } }) 2126 </div> 2127 <div class="card u-color-light--bg u-no-padding--xs dw-mod"> 2128 {{#unless isEmpty}} 2129 <table class="table cart-table dw-mod"> 2130 <tbody id="OrderLines"> 2131 {{#OrderLines}} 2132 {{> (lookup . 'template') }} 2133 {{/OrderLines}} 2134 </tbody> 2135 </table> 2136 {{/unless}} 2137 <div class="grid u-border-top"> 2138 <div class="grid__col-sm-6"> 2139 @if (Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 2140 { 2141 <text> 2142 {{#if userPoints}} 2143 <div class="u-border u-border-color--loyalty-points u-padding--lg u-full-height"> 2144 @Render(new Heading { Title = Translate("Your point balance"), Level = 3 }) 2145 <div class="u-font-size--lg u-margin-bottom"> 2146 <span class="u-color--loyalty-points">{{userPoints}}</span> @Translate("points") 2147 </div> 2148 <div>@Translate("On this order you will use"): <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")</div> 2149 </div> 2150 {{/if}} 2151 </text> 2152 } 2153 </div> 2154 2155 <div class="grid__col-sm-6"> 2156 @if (!pointShop) 2157 { 2158 <text> 2159 {{#unless hideSubTotal}} 2160 <div> 2161 <div class="cart-summary__subtotals dw-mod">@Translate("Subtotal")</div> 2162 <div class="cart-summary__subtotals u-pull--right dw-mod"> 2163 @if (hasTaxSettings) 2164 { 2165 <text>{{subtotalpricewithouttaxes}}</text> 2166 } 2167 else 2168 { 2169 <text>{{subtotalprice}}</text> 2170 } 2171 </div> 2172 </div> 2173 {{/unless}} 2174 </text> 2175 <text> 2176 {{#unless hidePaymentfee}} 2177 <div> 2178 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-credit-card", Label = "{{paymentmethod}}", LabelPosition = IconLabelPosition.After })</div> 2179 <div class="cart-summary__info u-pull--right dw-mod">{{paymentfee}}</div> 2180 </div> 2181 {{/unless}} 2182 </text> 2183 } 2184 {{#unless hideShippingfee}} 2185 <div> 2186 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-truck", Label = "{{shippingmethod}}", LabelPosition = IconLabelPosition.After })</div> 2187 <div class="cart-summary__info u-pull--right dw-mod">{{shippingfee}}</div> 2188 </div> 2189 {{/unless}} 2190 {{#if hasTaxSettings}} 2191 <div> 2192 <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> 2193 <div class="cart-summary__info u-pull--right dw-mod">{{totaltaxes}}</div> 2194 </div> 2195 {{/if}} 2196 @if (Pageview.User != null && Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints")) 2197 { 2198 <text> 2199 {{#if earnings}} 2200 <div> 2201 <div class="cart-summary__info dw-mod">@Translate("Earnings")</div> 2202 <div class="cart-summary__info u-pull--right dw-mod"><span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")</div> 2203 </div> 2204 {{/if}} 2205 </text> 2206 } 2207 <div class="cart-summary__totals-container dw-mod"> 2208 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 2209 <div class="cart-summary__totals u-pull--right dw-mod"> 2210 @if (pointShop) 2211 { 2212 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points") 2213 } 2214 else 2215 { 2216 <text>{{totalprice}}</text> 2217 } 2218 </div> 2219 </div> 2220 @if (!pointShop && !hasTaxSettings) 2221 { 2222 <div class="u-ta-right"> 2223 <small class="cart-summary__info dw-mod">@Translate("VAT"):</small> 2224 <small class="cart-summary__info dw-mod">{{totalvat}}</small> 2225 </div> 2226 2227 if (isPricesWithVATEnabled) 2228 { 2229 <div class="u-ta-right"> 2230 <small class="cart-summary__info dw-mod">@Translate("Total price without VAT"):</small> 2231 <small class="cart-summary__info dw-mod">{{totalPriceWithoutVat}}</small> 2232 </div> 2233 } 2234 else 2235 { 2236 <div class="u-ta-right"> 2237 <small class="cart-summary__info dw-mod">@Translate("Total price with VAT"):</small> 2238 <small class="cart-summary__info dw-mod">{{totalPriceWithVat}}</small> 2239 </div> 2240 } 2241 } 2242 {{#if showCheckoutDisclaimer}} 2243 <div class="u-ta-right"> 2244 <small>{{checkoutDisclaimer}}</small> 2245 </div> 2246 {{/if}} 2247 </div> 2248 </div> 2249 2250 <div class="grid"> 2251 <div class="grid__col-12 grid__col--line-top"></div> 2252 </div> 2253 2254 {{#unless hideComment}} 2255 <div class="grid__cell u-padding--xs"> 2256 @Render(new TextareaField { Rows = 3, Placeholder = Translate("Enter comment"), Name = "EcomOrderCustomerComment", Id = "EcomOrderCustomerComment", Value = "{{comment}}" }) 2257 </div> 2258 {{/unless}} 2259 <div class="u-margin-bottom--lg"> 2260 @foreach (LoopItem error in GetLoop("ValidationErrors")) 2261 { 2262 @Render(new NotificationMessage { Message = error.GetString("Ecom:Cart.ValidationError.ErrorMessage"), MessageType = NotificationMessageType.Error }) 2263 } 2264 </div> 2265 2266 @RenderBlockList(subBlocks) 2267 </div> 2268 {{/.}} 2269 </script> 2270 } 2271 2272 @helper RenderCartOrderlineTemplate() 2273 { 2274 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 2275 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 2276 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 2277 2278 @* Template for the orderlines *@ 2279 <script id="CartOrderline" type="text/x-template"> 2280 {{#unless isEmpty}} 2281 <tr id="Orderline{{id}}" class="cart-orderline"> 2282 <td class="cart-orderline__cell cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 2283 <div class="cart-orderline__cell__block {{hideimage}} dw-mod"> 2284 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 2285 </div> 2286 </td> 2287 <td class="cart-orderline__cell u-va-middle dw-mod" title="{{name}} {{variantname}}"> 2288 <a href="{{link}}" class="u-color-inherit cart-orderline__name">{{name}}</a> 2289 {{#if productnumber}} 2290 <div class="cart-orderline__cell__block item-number dw-mod">#{{productnumber}}</div> 2291 {{/if}} 2292 {{#if variantname}} 2293 <div class="cart-orderline__cell__block item-number dw-mod">{{variantname}}</div> 2294 {{/if}} 2295 {{#if unitname}} 2296 <div class="cart-orderline__cell__block item-number dw-mod">{{unitname}}</div> 2297 {{/if}} 2298 </td> 2299 <td class="cart-orderline__cell u-ta-right u-hidden-xs u-hidden-xxs dw-mod" width="120"> 2300 {{#if pointsTotal}} 2301 <span class="u-color--loyalty-points">{{pointPrice}}</span> @Translate("points") 2302 {{else}} 2303 {{unitprice}} 2304 {{/if}} 2305 </td> 2306 2307 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 2308 { 2309 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 2310 @Render(new NumberField 2311 { 2312 Id = "Quantity_{{orderLineId}}", 2313 Min = 1, 2314 OnChange = "Cart.ChangeQuantity('" + cartFeedPageId + "', '{{orderLineId}}', this.value)", 2315 Name = "QuantityOrderLine{{orderLineId}}", 2316 Value = "{{quantity}}", 2317 CssClass = "u-w80px", 2318 ActionButton = new Button 2319 { 2320 ButtonType = ButtonType.Button, 2321 ButtonLayout = ButtonLayout.Clean, 2322 OnClick = "{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}} Cart.UpdateCart(null, '/Default.aspx?ID=" + cartFeedPageId + "', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);", 2323 Icon = new Icon { Prefix = "fas", Name = "fa-times", LabelPosition = IconLabelPosition.After } 2324 } 2325 }) 2326 </td> 2327 } 2328 else 2329 { 2330 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 2331 @Render(new HiddenField { Id = "Quantity_{{orderLineId}}", Name = "QuantityOrderLine{{orderLineId}}", Value = "{{quantity}}" }) 2332 <div class="u-w80px u-no-margin">{{quantity}}</div> 2333 </td> 2334 } 2335 2336 <td class="cart-orderline__cell u-ta-right dw-mod"> 2337 {{#if pointsTotal}} 2338 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 2339 {{else}} 2340 <div>{{totalprice}}</div> 2341 {{/if}} 2342 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 2343 { 2344 <text> 2345 {{#if canBePurchasedWithPoints}} 2346 @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 } }) 2347 {{/if}} 2348 </text> 2349 } 2350 </td> 2351 </tr> 2352 {{/unless}} 2353 <tr class="{{hideBomItems}}"> 2354 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"><div class="{{hideimage}}"></div></td> 2355 <td colspan="5" class="u-no-padding"> 2356 <table class="u-no-margin u-color-light-gray--bg"> 2357 <tbody> 2358 {{#BomItems}} 2359 <tr> 2360 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 2361 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 2362 </td> 2363 <td title="{{name}} {{variantname}}"> 2364 <a href="{{link}}" class="u-color-inherit dw-mod">{{name}}</a> 2365 {{#if productnumber}} 2366 <div class="item-number dw-mod">#{{productnumber}}</div> 2367 {{/if}} 2368 {{#if variantname}} 2369 <div class="item-number dw-mod">{{variantname}}</div> 2370 {{/if}} 2371 {{#if unitname}} 2372 <div class="item-number dw-mod">{{unitname}}</div> 2373 {{/if}} 2374 </td> 2375 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 2376 <td>{{quantity}}</td> 2377 <td>&nbsp;</td> 2378 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 2379 </tr> 2380 {{/BomItems}} 2381 </tbody> 2382 </table> 2383 </td> 2384 </tr> 2385 </script> 2386 } 2387 2388 @helper RenderCartOrderlineMobileTemplate() 2389 { 2390 <script id="CartOrderlineMobile" type="text/x-template"> 2391 {{#unless isEmpty}} 2392 <tr id="Orderline{{id}}"> 2393 <td class="cart-table__image dw-mod"> 2394 <div class="{{hideimage}}"> 2395 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 2396 </div> 2397 </td> 2398 <td title="{{name}} {{variantname}}" colspan="4"> 2399 <a href="{{link}}" class="u-color-inherit">{{name}}</a> 2400 {{#if productnumber}} 2401 <div>#{{productnumber}}</div> 2402 {{/if}} 2403 {{#if variantname}} 2404 <div>{{variantname}}</div> 2405 {{/if}} 2406 {{#if unitname}} 2407 <div>{{unitname}}</div> 2408 {{/if}} 2409 </td> 2410 </tr> 2411 <tr class="table__row--no-border"> 2412 <td class="cart-table__image dw-mod"></td> 2413 <td colspan="4"> 2414 <div class="u-pull--left"> 2415 @Render(new NumberField 2416 { 2417 Id = "Quantity_{{orderLineId}}", 2418 Min = 1, 2419 OnChange = "Cart.ChangeQuantity('" + cartFeedPageId + "', '{{orderLineId}}', this.value)", 2420 Name = "QuantityOrderLine{{orderLineId}}", 2421 Value = "{{quantity}}", 2422 CssClass = "u-w80px", 2423 ActionButton = new Button 2424 { 2425 ButtonType = ButtonType.Button, 2426 ButtonLayout = ButtonLayout.Clean, 2427 OnClick = "{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}} Cart.UpdateCart(null, '/Default.aspx?ID=" + cartFeedPageId + "', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);", 2428 Icon = new Icon { Prefix = "fas", Name = "fa-times", LabelPosition = IconLabelPosition.After } 2429 } 2430 }) 2431 </div> 2432 <div class="u-pull--right u-ta-right"> 2433 {{#if pointsTotal}} 2434 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 2435 {{else}} 2436 <div>{{totalprice}}</div> 2437 {{/if}} 2438 {{#if canBePurchasedWithPoints}} 2439 @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 } }) 2440 {{/if}} 2441 </div> 2442 </td> 2443 </tr> 2444 {{/unless}} 2445 <tr class="{{hideBomItems}}"> 2446 <td colspan="6" class="u-no-padding"> 2447 <table class="u-no-margin u-color-light-gray--bg"> 2448 <tbody> 2449 {{#BomItems}} 2450 <tr> 2451 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 2452 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 2453 </td> 2454 <td title="{{name}} {{variantname}}"> 2455 <a href="{{link}}" title="{{name}} {{variantname}}">{{name}}</a> 2456 {{#if productnumber}} 2457 <div>#{{productnumber}}</div> 2458 {{/if}} 2459 {{#if variantname}} 2460 <div>{{variantname}}</div> 2461 {{/if}} 2462 {{#if unitname}} 2463 <div>{{unitname}}</div> 2464 {{/if}} 2465 </td> 2466 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 2467 <td>{{quantity}}</td> 2468 <td>&nbsp;</td> 2469 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 2470 </tr> 2471 {{/BomItems}} 2472 </tbody> 2473 </table> 2474 </td> 2475 </tr> 2476 </script> 2477 } 2478 2479 @helper RenderCartOrderlineDiscountTemplate() 2480 { 2481 <script id="CartOrderlineDiscount" type="text/x-template"> 2482 <tr class="table__row--no-border"> 2483 <td class="cart-table__image dw-mod">&nbsp;</td> 2484 <td colspan="3">{{name}}</td> 2485 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 2486 <td class="cart-table__price u-ta-right dw-mod">{{totalprice}}</td> 2487 </tr> 2488 </script> 2489 } 2490 2491 @helper RenderEmptyCartTemplate() 2492 { 2493 <script id="EmptyCart" type="text/x-template"> 2494 @Translate("You have no items in the cart") 2495 </script> 2496 } 2497 2498 @helper RenderInlineAcceptance() 2499 { 2500 <div class="grid__cell u-padding--xs"> 2501 @if (GetBoolean("Ecom:Cart.UseNewsletterSubscription")) 2502 { 2503 @Render(new HiddenField { Name = "EcomOrderSubscribeToNewsletter" }) 2504 @Render(new CheckboxField { Name = "EcomOrderSubscribeToNewsletter", Id = "EcomOrderSubscribeToNewsletter", Label = Translate("Subscribe to newsletter") }) 2505 } 2506 2507 @if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions")) 2508 { 2509 @Render(new HiddenField { Name = "EcomOrderCustomerAccepted", Id = "EcomOrderCustomerAccepted", Value = "1" }) 2510 } 2511 else 2512 { 2513 string termsPageIt = GetPageIdByNavigationTag("TermsAndConditions").ToString(); 2514 @Render(new CheckboxField 2515 { 2516 Name = "EcomOrderCustomerAccepted", 2517 Id = "EcomOrderCustomerAccepted", 2518 OnChange = canCompleteOrder ? "Cart.EnableCheckoutButton()" : "", 2519 Label = Translate("I accept the") + " <a href=\"/Default.aspx?ID=" + termsPageIt + "\">" + Translate("terms and conditions") + "</a>", 2520 ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerAccepted.ErrorMessage") 2521 }) 2522 } 2523 </div> 2524 } 2525 2526 @helper RenderReviewOrderFooter() 2527 { 2528 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 2529 2530 <div class="grid"> 2531 <div class="grid__col-12 grid__col--line-top"></div> 2532 </div> 2533 2534 <div class="grid__cell-footer"> 2535 <div class="grid__cell u-padding--xs"> 2536 <div class="u-pull--right"> 2537 @Render(new Button 2538 { 2539 ButtonType = ButtonType.Submit, 2540 ButtonLayout = ButtonLayout.Primary, 2541 CssClass = "btn--condensed u-pull--right u-no-margin", 2542 Title = Translate("Go to checkout"), 2543 Id = GetString("CartV2.NextStepButtonName"), 2544 OnClick = "Buttons.LockButton(event, true)", 2545 Disabled = !canCompleteOrder || !Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions"), 2546 Name = GetString("CartV2.NextStepButtonName") 2547 }) 2548 </div> 2549 <div class="u-pull--left"> 2550 @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);" }) 2551 </div> 2552 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 2553 { 2554 <div class="u-pull--right"> 2555 @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") }) 2556 </div> 2557 } 2558 </div> 2559 </div> 2560 } 2561 2562 @helper RenderReviewOrderFooterQuote() 2563 { 2564 string submitButtonTitle = Pageview.Device.ToString() == "Mobile" ? Translate("Submit") : Translate("Submit quote request"); 2565 2566 <div class="grid"> 2567 <div class="grid__col-12 grid__col--line-top"></div> 2568 </div> 2569 2570 <div class="grid__cell-footer"> 2571 <div class="grid__cell u-padding--xs"> 2572 <div class="u-pull--right"> 2573 @Render(new Button 2574 { 2575 ButtonType = ButtonType.Submit, 2576 ButtonLayout = ButtonLayout.Primary, 2577 CssClass = "btn--condensed u-pull--right u-no-margin", 2578 Title = submitButtonTitle, 2579 Id = GetString("CartV2.NextStepButtonName"), 2580 OnClick = "Buttons.LockButton(event, true)", 2581 Name = GetString("CartV2.NextStepButtonName") 2582 }) 2583 </div> 2584 <div class="u-pull--left"> 2585 @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") }) 2586 </div> 2587 </div> 2588 </div> 2589 2590 } 2591 <script> 2592 EmptyCartQuote = function (e) { 2593 e.preventDefault(); 2594 2595 var url = "/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed").ToString()"; 2596 Cart.UpdateCart('miniCart', url, "cartcmd=emptycart&OrderContext=RESTOCK&redirect=false", true); 2597 RememberState.SetCookie("useAnotherAddress", false); 2598 var event = new CustomEvent('emptyCart'); 2599 document.dispatchEvent(event); 2600 } 2601 </script> 2602 @helper RenderOrderScripts() 2603 { 2604 if (!string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID"))) 2605 { 2606 <script> 2607 fbq('track', 'InitiateCheckout', { 2608 currency: '@GetString("Ecom:Order.Price.Currency.Code")', 2609 value: @GetDouble("Ecom:Order.Price.Price"), 2610 num_items: "@GetInteger("Ecom:Order.OrderLines.TotalProductQuantity")" 2611 }); 2612 </script> 2613 } 2614 } 2615 2616 @helper RenderEmptyCartObserver() 2617 { 2618 <script> 2619 document.addEventListener("cartUpdated", function(event) { 2620 let data = event.detail.data[0]; 2621 if (data.numberofproducts == 0) { 2622 location.reload(); 2623 } else { 2624 HandlebarsBolt.CreateItemsFromJson(data, "Cart"); 2625 } 2626 }); 2627 </script> 2628 } 2629 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2630 @using Dynamicweb.Core 2631 @using System 2632 @using System.Web 2633 @using System.Collections.Generic 2634 @using Dynamicweb.Rapido.Blocks 2635 2636 @{ 2637 BlocksPage stepNavigationCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 2638 2639 Block checkoutStepNavigation = new Block() 2640 { 2641 Id = "StepNavigation", 2642 SortId = 50, 2643 Template = RenderStepNavigation(), 2644 Design = new Design { 2645 RenderType = RenderType.Column, 2646 Size = "12" 2647 } 2648 }; 2649 stepNavigationCheckoutPage.Add("CheckoutForm", checkoutStepNavigation); 2650 } 2651 2652 @helper RenderStepNavigation() 2653 { 2654 var paymentCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 2655 var shippingCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 2656 var paymentCountryIsSupported = string.IsNullOrEmpty(paymentCountryCode) || GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == paymentCountryCode)); 2657 var shippingCountryIsSupported = string.IsNullOrEmpty(shippingCountryCode) ? paymentCountryIsSupported : GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == shippingCountryCode)); 2658 2659 var canCompleteOrder = paymentCountryIsSupported && shippingCountryIsSupported; 2660 2661 2662 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 2663 int currentStep = 1; 2664 string disableNextButton = ""; 2665 string nextButtonName = Translate("Next"); 2666 2667 foreach (LoopItem step in GetLoop("StepButtons")) 2668 { 2669 if (step.GetBoolean("Step.Current")) 2670 { 2671 currentStep = step.GetInteger("Step.Number"); 2672 } 2673 2674 if (step.GetInteger("Step.Number") == currentStep + 1) 2675 { 2676 if (Pageview.Device.ToString() != "Mobile" ) { 2677 nextButtonName = Translate("Go to") + " " + step.GetString("Step.Name"); 2678 } else { 2679 nextButtonName = step.GetString("Step.Name"); 2680 } 2681 } 2682 } 2683 2684 if (currentStep == GetLoop("StepButtons").Count - 1) 2685 { 2686 disableNextButton = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions") ? "" : "disabled"; //not disable button if terms are hidden 2687 nextButtonName = Translate("Confirm order"); 2688 } 2689 2690 if (currentStep > 1 && !canCompleteOrder) 2691 { 2692 disableNextButton = "disabled"; 2693 } 2694 2695 <div class="card u-color-light--bg dw-mod"> 2696 @if (currentStep == 1) 2697 { 2698 <div class="u-pull--left"> 2699 <button type="button" class="btn btn--secondary btn--condensed dw-mod u-pull--left u-no-margin" onclick="googleEnchantImpressionEmptyCart(); Cart.EmptyCart(event);">@Translate("Empty cart")</button> 2700 </div> 2701 } 2702 else 2703 { 2704 <div class="u-pull--left"> 2705 <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> 2706 </div> 2707 } 2708 2709 <div class="u-pull--right"> 2710 <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> 2711 </div> 2712 2713 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 2714 { 2715 <div class="u-pull--right"> 2716 <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> 2717 </div> 2718 } 2719 </div> 2720 } 2721 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2722 @using Dynamicweb.Core 2723 @using System 2724 @using System.Web 2725 @using System.Collections.Generic 2726 @using Dynamicweb.Rapido.Blocks 2727 2728 @{ 2729 BlocksPage snippetsCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 2730 2731 snippetsCheckoutPage.Add("CheckoutBottomSnippets", new Block 2732 { 2733 Id = "CartAddressesJavascript", 2734 SortId = 50, 2735 Template = RenderCartAddressesJavascript() 2736 }); 2737 } 2738 2739 @helper RenderCartAddressesJavascript() 2740 { 2741 <script> 2742 function resetStateField(stateFieldId) { 2743 let stateField = document.getElementById(stateFieldId); 2744 if (stateField) { 2745 stateField.value = ""; 2746 let disabledOption = stateField.querySelector("option:checked"); 2747 if (disabledOption) { 2748 disabledOption.disabled = false; 2749 disabledOption.removeAttribute("disabled"); 2750 } 2751 } 2752 } 2753 2754 document.addEventListener("DOMContentLoaded", function () { 2755 regionLabels.InitDictionary({ 2756 "CA": "@Translate("Province")", 2757 "US": "@Translate("State")" 2758 }); 2759 regionLabels.LocalizeRegionLabels("EcomOrderCustomerRegion", "EcomOrderCustomerCountry"); 2760 regionLabels.LocalizeRegionLabels("EcomOrderDeliveryRegion", "EcomOrderDeliveryCountry"); 2761 }); 2762 </script> 2763 } 2764 2765 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2766 @using Dynamicweb.Core 2767 @using System 2768 @using System.Web 2769 @using System.Collections.Generic 2770 @using Dynamicweb.Rapido.Blocks 2771 @using Dynamicweb.Ecommerce.Orders 2772 2773 @{ 2774 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 2775 2776 BlocksPage googleImpressionsPage = BlocksPage.GetBlockPage("CheckoutPage"); 2777 2778 Block googleImpressionsBlock = new Block() 2779 { 2780 Id = "GoogleImpressionsBlock", 2781 SortId = 10, 2782 Template = RenderScript() 2783 }; 2784 2785 if (useGoogleTagManager) 2786 { 2787 googleImpressionsPage.Add("CheckoutBottomSnippets", googleImpressionsBlock); 2788 } 2789 } 2790 2791 @helper RenderScript() 2792 { 2793 var currentStep = 1; 2794 2795 foreach (LoopItem step in GetLoop("StepButtons")) 2796 { 2797 if (step.GetBoolean("Step.Current")) 2798 { 2799 currentStep = step.GetInteger("Step.Number"); 2800 break; 2801 } 2802 } 2803 <script> 2804 dataLayer.push({ 2805 "event": "checkout", 2806 "ecommerce": { 2807 "currencyCode": "@Dynamicweb.Ecommerce.Services.Currencies.GetDefaultCurrency().Code", 2808 "checkout": { 2809 "actionField": {"step": @currentStep}, 2810 "products": [ 2811 @foreach (LoopItem orderline in GetLoop("OrderLines").Where(o => o.GetBoolean("Ecom:Order:OrderLine.IsProduct") == true).ToList()) 2812 { 2813 var groupObject = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(orderline.GetString("Ecom:Product.PrimaryOrFirstGroupID")); 2814 <text> 2815 { 2816 "name": "@orderline.GetString("Ecom:Order:OrderLine.ProductName")", 2817 "id": "@orderline.GetString("Ecom:Product.ID")", 2818 "price": "@orderline.GetDouble("Ecom:Order:OrderLine.UnitPrice.Price")", 2819 "brand": "@orderline.GetString("Ecom:Product:Field.brand.Value")", 2820 "category": "@(groupObject != null ? groupObject.Name : "")", 2821 "variant": "@orderline.GetString("Ecom:Order:OrderLine.ProductVariantID")", 2822 "quantity": @orderline.GetInteger("Ecom:Order:OrderLine.Quantity") 2823 }, 2824 </text> 2825 } 2826 ] 2827 } 2828 } 2829 }); 2830 </script> 2831 } 2832 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2833 @using Dynamicweb.Core 2834 @using System 2835 @using System.Web 2836 @using System.Collections.Generic 2837 @using Dynamicweb.Rapido.Blocks 2838 2839 @{ 2840 var DistributorOrderRouter = GetString("DistributorOrderRouter"); 2841 } 2842 2843 @{ 2844 BlocksPage customBlocksPage = BlocksPage.GetBlockPage("CheckoutPage"); 2845 Block CustomOrderline = new Block() 2846 { 2847 Id = "CartOrderlineTemplate", 2848 SortId = 20, 2849 Template = RenderCartOrderlineTemplateCustom() 2850 }; 2851 customBlocksPage.ReplaceBlock(CustomOrderline); 2852 2853 var ShippingAddressBody = customBlocksPage.GetBlockById("ShippingAddressBody"); 2854 if (ShippingAddressBody != null) 2855 { 2856 if (checkoutPageType != "multistep") 2857 { 2858 2859 Block CommentCustom = new Block() 2860 { 2861 Id = "CommentTemplate", 2862 SortId = 50, 2863 Template = RenderCartComment() 2864 }; 2865 2866 2867 customBlocksPage.Add("ShippingAddressBody", CommentCustom); 2868 } 2869 if (checkoutPageType == "multistep") 2870 { 2871 if (GetString("CartV2.CurrentStepButtonName") == "CartV2.GotoStep1") 2872 { 2873 Block CommentCustom = new Block() 2874 { 2875 Id = "CommentTemplate", 2876 SortId = 50, 2877 Template = RenderCartComment() 2878 }; 2879 customBlocksPage.Add("ShippingAddressBody", CommentCustom); 2880 } 2881 2882 } 2883 2884 } 2885 2886 2887 Block CustomContent = new Block() 2888 { 2889 Id = "CartContentTemplate", 2890 SortId = 20, 2891 Template = RenderCartContentTemplateCustom() 2892 }; 2893 customBlocksPage.ReplaceBlock(CustomContent); 2894 2895 2896 2897 2898 Block CustomDiscount = new Block() 2899 { 2900 Id = "CartOrderlineDiscountTemplate", 2901 SortId = 20, 2902 Template = RenderCartOrderlineDiscountTemplateCustom() 2903 }; 2904 customBlocksPage.ReplaceBlock(CustomDiscount); 2905 2906 Block acceptanceBlockCustom = new Block() 2907 { 2908 Id = "Acceptance", 2909 SortId = 10, 2910 Design = new Design 2911 { 2912 RenderType = RenderType.Column, 2913 Size = "12" 2914 }, 2915 BlocksList = new List<Block> 2916 { 2917 new Block { 2918 Id = "AcceptanceBody", 2919 SortId = 10, 2920 Template = RenderAcceptanceCustom() 2921 } 2922 } 2923 }; 2924 customBlocksPage.ReplaceBlock(acceptanceBlockCustom); 2925 2926 Block reviewOrderFooterBlockCustom = new Block() 2927 { 2928 Id = "ReviewOrderFooter", 2929 SortId = 20, 2930 Template = RenderReviewOrderFooterCustom() 2931 }; 2932 customBlocksPage.ReplaceBlock(reviewOrderFooterBlockCustom); 2933 if (checkoutPageType == "quote") 2934 { 2935 Block reviewOrderFooterBlockCustomQuote = new Block() 2936 { 2937 Id = "ReviewOrderFooter", 2938 SortId = 20, 2939 Template = RenderReviewOrderFooterQuoteCustom() 2940 }; 2941 customBlocksPage.ReplaceBlock(reviewOrderFooterBlockCustomQuote); 2942 } 2943 2944 2945 } 2946 2947 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2948 @using Dynamicweb 2949 @using Dynamicweb.Core 2950 @using System.Collections; 2951 @using System 2952 @using System.Web 2953 @using System.Linq; 2954 @using System.Collections.Generic 2955 @using Dynamicweb.Rapido.Blocks 2956 @using Dynamicweb.Rapido.Blocks.Components 2957 @using Dynamicweb.Rapido.Blocks.Components.General 2958 2959 @helper RenderCartOrderlineTemplateCustom() 2960 { 2961 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 2962 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 2963 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 2964 string pageUrlN = GetPageIdByNavigationTag("GetUserInfo").ToString(); 2965 string feedFullUrlN = "Default.aspx?ID=" + pageUrlN; 2966 var userCode = GetString("UserManagement:User.Item.Code"); 2967 var errorLoopCount = GetLoop("ValidationErrors").Where(x => x.GetString("Ecom:Cart.ValidationError.FieldName") == "OrderlineError").Count(); 2968 DateTime userExpireDate = GetDate("UserManagement:User.Item.CodeExpire"); 2969 var exDate = userExpireDate.ToString("yyyy-MM-dd"); 2970 var date = GetGlobalValue("Global:Server.Date.GeneralDate"); 2971 DateTime dt = Convert.ToDateTime(date); 2972 var currentday = dt.ToString("yyyy-MM-dd"); 2973 var currentUser = GetInteger("UserManagement:User.ID").ToString(); 2974 string cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 2975 if (!string.IsNullOrWhiteSpace(GetString("Ecom:OrderContext.ID"))) 2976 { 2977 cartFeedPageIdCustom += "&OrderContext=" + GetString("Ecom:OrderContext.ID"); 2978 } 2979 2980 @* Template for the orderlines *@ 2981 2982 <script id="CartOrderline" type="text/x-template"> 2983 2984 {{#unless isEmpty}} 2985 <tr id="Orderline{{id}}" class="cart-orderline"> 2986 <td class="cart-orderline__cell cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 2987 <div class="cart-orderline__cell__block {{hideimage}} dw-mod"> 2988 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 2989 </div> 2990 </td> 2991 <td class="cart-orderline__cell u-va-middle dw-mod" title="{{name}} {{variantname}}"> 2992 <a href="{{link}}" class="u-color-inherit cart-orderline__name">{{name}}</a> 2993 {{#if productnumber}} 2994 <div class="cart-orderline__cell__block item-number dw-mod">#{{productnumber}}</div> 2995 {{/if}} 2996 {{#if variantname}} 2997 <div class="cart-orderline__cell__block item-number dw-mod">{{variantname}}</div> 2998 {{/if}} 2999 {{#if unitname}} 3000 <div class="cart-orderline__cell__block item-number dw-mod">{{unitname}}</div> 3001 {{/if}} 3002 {{#if trainingInfo}} 3003 <div class="cart-orderline__cell__block item-number dw-mod">{{trainingInfo}} @Translate("hr")</div> 3004 {{/if}} 3005 3006 </td> 3007 <td class="cart-orderline__cell u-ta-right u-hidden-xs u-hidden-xxs dw-mod" width="120"> 3008 {{#if pointsTotal}} 3009 <span class="u-color--loyalty-points">{{pointPrice}}</span> @Translate("points") 3010 {{else}} 3011 {{unitprice}} 3012 {{/if}} 3013 </td> 3014 3015 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 3016 { 3017 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 3018 @Render(new NumberField 3019 { 3020 Id = "Quantity_{{orderLineId}}", 3021 Min = 1, 3022 OnChange = "Cart.ChangeQuantity('" + cartFeedPageIdCustom + "', '{{orderLineId}}', this.value)", 3023 Name = "QuantityOrderLine{{orderLineId}}", 3024 Value = "{{quantity}}", 3025 CssClass = "u-w80px", 3026 ActionButton = new Button 3027 { 3028 ButtonType = ButtonType.Button, 3029 ButtonLayout = ButtonLayout.Clean, 3030 OnClick = "{{#if googleImpression}}googleImpressionRemoveFromCart({{googleImpression}});{{/if}} Cart.UpdateCart(null, '/Default.aspx?ID=" + cartFeedPageIdCustom + "', 'CartCmd=DelOrderLine&key={{orderLineId}}&redirect=false', true);", 3031 Icon = new Icon { Prefix = "fas", Name = "fa-times", LabelPosition = IconLabelPosition.After } 3032 } 3033 }) 3034 </td> 3035 } 3036 else 3037 { 3038 <td class="cart-orderline__cell u-ta-right dw-mod" colspan="2"> 3039 @Render(new HiddenField { Id = "Quantity_{{orderLineId}}", Name = "QuantityOrderLine{{orderLineId}}", Value = "{{quantity}}" }) 3040 <div class="u-w80px u-no-margin">{{quantity}}</div> 3041 </td> 3042 } 3043 3044 <td class="cart-orderline__cell u-ta-right dw-mod"> 3045 {{#if pointsTotal}} 3046 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 3047 {{else}} 3048 <div>{{totalprice}}</div> 3049 {{/if}} 3050 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 3051 { 3052 <text> 3053 {{#if canBePurchasedWithPoints}} 3054 @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 } }) 3055 {{/if}} 3056 </text> 3057 } 3058 </td> 3059 </tr> 3060 {{/unless}} 3061 <tr class="{{hideBomItems}}"> 3062 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"><div class="{{hideimage}}"></div></td> 3063 <td colspan="5" class="u-no-padding"> 3064 <table class="u-no-margin u-color-light-gray--bg"> 3065 <tbody> 3066 {{#BomItems}} 3067 <tr> 3068 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"> 3069 @Render(new Image { Path = "{{image}}", Title = "{{name}} {{variantname}}", ImageDefault = new ImageSettings { Width = 60, Height = 60, Crop = 5 } }) 3070 </td> 3071 <td title="{{name}} {{variantname}}"> 3072 <a href="{{link}}" class="u-color-inherit dw-mod">{{name}}</a> 3073 {{#if productnumber}} 3074 <div class="item-number dw-mod">#{{productnumber}}</div> 3075 {{/if}} 3076 {{#if variantname}} 3077 <div class="item-number dw-mod">{{variantname}}</div> 3078 {{/if}} 3079 {{#if unitname}} 3080 <div class="item-number dw-mod">{{unitname}}</div> 3081 {{/if}} 3082 </td> 3083 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 3084 <td>{{quantity}}</td> 3085 <td>&nbsp;</td> 3086 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 3087 </tr> 3088 {{/BomItems}} 3089 </tbody> 3090 </table> 3091 </td> 3092 </tr> 3093 </script> 3094 3095 } 3096 @helper RenderCartContentTemplateCustom() 3097 { 3098 BlocksPage customBlocksPageOrder = BlocksPage.GetBlockPage("CheckoutPage"); 3099 List<Block> subBlocksCustom = customBlocksPageOrder.GetBlockListById("ReviewOrder").OrderBy(item => item.SortId).ToList(); 3100 3101 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3102 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 3103 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(GetString("Ecom:Order.ID")); 3104 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 3105 int cartFeedPageIdCustom; 3106 cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed"); 3107 3108 <script id="CartContent" type="text/x-template"> 3109 3110 {{#.}} 3111 @if (useGoogleTagManager) 3112 { 3113 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text> 3114 } 3115 3116 <div class="card-header u-color-light--bg dw-mod"> 3117 @Render(new Heading { Title = Translate("Review order") + "({{numberofproducts}})", Level = 3, Icon = new Icon { Prefix = "fas", Name = "fa-list-ul", LabelPosition = IconLabelPosition.After } }) 3118 </div> 3119 3120 <div class="card u-color-light--bg u-no-padding--xs dw-mod"> 3121 3122 {{#unless orderIsAuthenticatedClean}} 3123 <input type="text" id="OrderIsAuthenticated" name="OrderIsAuthenticated" value="no" style="display:none"> 3124 <input type="checkbox" id="isAuthenticated" name="OrderIsAuthenticated" style="display:none"> 3125 {{else}} 3126 <input type="text" id="OrderIsAuthenticated" name="OrderIsAuthenticated" value="yes" style="display:none"> 3127 <input type="checkbox" id="isAuthenticated" checked="checked" name="OrderIsAuthenticated" style="display:none"> 3128 {{/unless}} 3129 {{#unless isEmpty}} 3130 {{#unless notRequireAuthorization}} 3131 {{#unless orderIsAuthenticatedClean}} 3132 <div class="grid "> 3133 <div class="grid__col-xs-12 grid__col-sm-6 autorization-code"> 3134 <div class="alert-box u-color-danger txt-small u-margin-bottom">{{orderIsAuthenticatedError}}</div> 3135 <input id="{{AuthorizationCodeName}}" name="{{AuthorizationCodeName}}" class="u-full-width dw-mod" value="{{AuthorizationCode}}" placeholder=" @Translate("Enter your code")"/> 3136 </div> 3137 </div> 3138 {{/unless}} 3139 {{/unless}} 3140 <table class="table cart-table dw-mod"> 3141 <tbody id="OrderLines"> 3142 {{#OrderLines}} 3143 {{> (lookup . 'template') }} 3144 {{/OrderLines}} 3145 </tbody> 3146 </table> 3147 {{/unless}} 3148 <div class="grid u-border-top"> 3149 <div class="grid__col-sm-6"> 3150 @if (Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 3151 { 3152 <text> 3153 {{#if userPoints}} 3154 <div class="u-border u-border-color--loyalty-points u-padding--lg u-full-height"> 3155 @Render(new Heading { Title = Translate("Your point balance"), Level = 3 }) 3156 <div class="u-font-size--lg u-margin-bottom"> 3157 <span class="u-color--loyalty-points">{{userPoints}}</span> @Translate("points") 3158 </div> 3159 <div>@Translate("On this order you will use"): <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")</div> 3160 </div> 3161 {{/if}} 3162 </text> 3163 } 3164 </div> 3165 3166 <div class="grid__col-sm-6"> 3167 @if (GetLoop("DWExtranetSecondaryUsers").Count > 0 || !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.SecondaryUser.UserID"))) 3168 { 3169 <div class="grid"> 3170 <div class="grid__col-xs-12 alert-box u-color-danger txt-small u-hidden" id="error-discount">@Translate("Allowing only decimals numbers")</div> 3171 <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="" /> 3172 <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)"> 3173 <option value="OrderDiscountPercentage">@Translate("Percentage")</option> 3174 <option value="OrderDiscount">@Translate("Fixed Price")</option> 3175 <select> 3176 <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> 3177 </div> 3178 3179 } 3180 3181 @if (!pointShop) 3182 { 3183 <text> 3184 {{#unless hideSubTotal}} 3185 <div> 3186 <div class="cart-summary__subtotals dw-mod">@Translate("Subtotal")</div> 3187 <div class="cart-summary__subtotals u-pull--right dw-mod"> 3188 @if (hasTaxSettings) 3189 { 3190 <text>{{subtotalpricewithouttaxes}}</text> 3191 } 3192 else 3193 { 3194 <text>{{subtotalprice}}</text> 3195 } 3196 </div> 3197 </div> 3198 {{/unless}} 3199 </text> 3200 <text> 3201 {{#unless hidePaymentfee}} 3202 <div> 3203 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-credit-card", Label = "{{paymentmethod}}", LabelPosition = IconLabelPosition.After })</div> 3204 <div class="cart-summary__info u-pull--right dw-mod">{{paymentfee}}</div> 3205 </div> 3206 {{/unless}} 3207 </text> 3208 } 3209 {{#unless hideShippingfee}} 3210 <div> 3211 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-truck", Label = "{{shippingmethod}}", LabelPosition = IconLabelPosition.After })</div> 3212 <div class="cart-summary__info u-pull--right dw-mod">{{shippingfee}}</div> 3213 </div> 3214 {{#unless notTxtForShippingFree}} 3215 <div> 3216 <div class="cart-summary__info dw-mod"><span class="txt-small">@Translate("Free shipping - Buy for additional") {{aditionalPriceForFreeShipping}}</span> </div> 3217 <div class="cart-summary__info u-pull--right dw-mod"></div> 3218 </div> 3219 {{/unless}} 3220 {{/unless}} 3221 {{#if hasTaxSettings}} 3222 <div> 3223 <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> 3224 <div class="cart-summary__info u-pull--right dw-mod">{{totaltaxes}}</div> 3225 </div> 3226 {{/if}} 3227 @if (Pageview.User != null && Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints")) 3228 { 3229 <text> 3230 {{#if earnings}} 3231 <div> 3232 <div class="cart-summary__info dw-mod">@Translate("Earnings")</div> 3233 <div class="cart-summary__info u-pull--right dw-mod"><span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")</div> 3234 </div> 3235 {{/if}} 3236 </text> 3237 } 3238 <div class="cart-summary__totals-container dw-mod"> 3239 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 3240 <div class="cart-summary__totals u-pull--right dw-mod"> 3241 @if (pointShop) 3242 { 3243 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points") 3244 } 3245 else 3246 { 3247 <text>{{totalprice}}</text> 3248 } 3249 </div> 3250 </div> 3251 @if (!pointShop && !hasTaxSettings) 3252 { 3253 <div class="u-ta-right"> 3254 <small class="cart-summary__info dw-mod">@Translate("VAT"):</small> 3255 <small class="cart-summary__info dw-mod">{{totalvat}}</small> 3256 </div> 3257 3258 if (isPricesWithVATEnabled) 3259 { 3260 <div class="u-ta-right"> 3261 <small class="cart-summary__info dw-mod">@Translate("Total price without VAT"):</small> 3262 <small class="cart-summary__info dw-mod">{{totalPriceWithoutVat}}</small> 3263 </div> 3264 } 3265 else 3266 { 3267 <div class="u-ta-right"> 3268 <small class="cart-summary__info dw-mod">@Translate("Total price with VAT"):</small> 3269 <small class="cart-summary__info dw-mod">{{totalPriceWithVat}}</small> 3270 </div> 3271 } 3272 } 3273 {{#if showCheckoutDisclaimer}} 3274 <div class="u-ta-right"> 3275 <small>{{checkoutDisclaimer}}</small> 3276 </div> 3277 {{/if}} 3278 </div> 3279 </div> 3280 3281 <div class="u-margin-bottom--lg"> 3282 <div id="errorCode"> 3283 3284 </div> 3285 @foreach (LoopItem error in GetLoop("ValidationErrors")) 3286 { 3287 @Render(new NotificationMessage { Message = error.GetString("Ecom:Cart.ValidationError.ErrorMessage"), MessageType = NotificationMessageType.Error }) 3288 } 3289 </div> 3290 </div> 3291 {{/.}} 3292 </script> 3293 3294 } 3295 @helper RenderCartOrderlineDiscountTemplateCustom() 3296 { 3297 <script id="CartOrderlineDiscount" type="text/x-template"> 3298 <tr class="table__row--no-border discount-row"> 3299 <td class="cart-table__image dw-mod"> 3300 {{#unless notDiscountImage}} 3301 <img src="{{{image}}}"> 3302 {{/unless}} 3303 </td> 3304 <td colspan="3">{{name}}</td> 3305 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 3306 <td class="cart-table__price u-ta-right dw-mod">{{totalprice}}</td> 3307 </tr> 3308 </script> 3309 } 3310 @helper RenderCartComment() 3311 { 3312 var cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed"); 3313 <div class="grid__col-12"> 3314 <div class="js-handlebars-root" id="CartComment" data-template="CartCommentCustom" data-json-feed="/Default.aspx?ID=@cartFeedPageIdCustom"></div> 3315 </div> 3316 3317 <script id="CartCommentCustom" type="text/x-template"> 3318 {{#.}} 3319 <div class=""> 3320 <div class="grid"> 3321 <div class="grid__col-12 grid__col--line-top"></div> 3322 </div> 3323 {{#unless hideComment}} 3324 <div class="grid__cell u-padding--xs"> 3325 @Render(new TextareaField { Rows = 3, Placeholder = Translate("Enter comment"), Name = "EcomOrderCustomerComment", Id = "EcomOrderCustomerComment", Value = "{{comment}}" }) 3326 </div> 3327 {{/unless}} 3328 </div> 3329 {{/.}} 3330 </script> 3331 } 3332 @helper RenderReviewOrderFooterCustom() 3333 { 3334 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 3335 var emptyOrContinueBtn = Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage") != null ? Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage").SelectedValue : "empty"; 3336 string reviewOrderType = checkoutPageType ?? "onestep"; //The "checkoutPageType" comes from the main template for the cart page 3337 int cartFeedPageIdCustom = GetPageIdByNavigationTag("MiniCartFeed"); 3338 var paymentCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 3339 var shippingCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 3340 var paymentCountryIsSupported = string.IsNullOrEmpty(paymentCountryCode) || GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == paymentCountryCode)); 3341 var shippingCountryIsSupported = string.IsNullOrEmpty(shippingCountryCode) ? paymentCountryIsSupported : GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == shippingCountryCode)); 3342 3343 bool canCompleteOrderCustom = paymentCountryIsSupported && shippingCountryIsSupported; 3344 <div class="grid"> 3345 <div class="grid__col-12 grid__col--line-top"></div> 3346 </div> 3347 3348 <div class="grid__cell-footer"> 3349 <div class="grid__cell u-padding--xs"> 3350 <div class="u-pull--right"> 3351 @Render(new Button 3352 { 3353 ButtonType = ButtonType.Submit, 3354 ButtonLayout = ButtonLayout.Primary, 3355 CssClass = "btn--condensed u-pull--right u-no-margin", 3356 Title = Translate("Go to checkout"), 3357 Id = GetString("CartV2.NextStepButtonName"), 3358 OnClick = "Buttons.LockButton(event, true)", 3359 Disabled = !canCompleteOrderCustom || !Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions"), 3360 Name = GetString("CartV2.NextStepButtonName") 3361 }) 3362 </div> 3363 <div class="u-pull--left"> 3364 @if (emptyOrContinueBtn == "empty") 3365 { 3366 @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);" }) 3367 3368 } 3369 else 3370 { 3371 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", Title = Translate("Continue shopping"), OnClick = "GoToProductPage();" }) 3372 3373 } 3374 </div> 3375 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 3376 { 3377 <div class="u-pull--right"> 3378 @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") }) 3379 </div> 3380 } 3381 </div> 3382 </div> 3383 3384 3385 3386 } 3387 3388 @helper RenderReviewOrderFooterQuoteCustom() 3389 { 3390 string submitButtonTitle = Pageview.Device.ToString() == "Mobile" ? Translate("Submit") : Translate("Submit quote request"); 3391 3392 <div class="grid"> 3393 <div class="grid__col-12 grid__col--line-top"></div> 3394 </div> 3395 3396 <div class="grid__cell-footer"> 3397 <div class="grid__cell u-padding--xs"> 3398 <div class="u-pull--right"> 3399 @Render(new Button 3400 { 3401 ButtonType = ButtonType.Submit, 3402 ButtonLayout = ButtonLayout.Primary, 3403 CssClass = "btn--condensed u-pull--right u-no-margin", 3404 Title = submitButtonTitle, 3405 Id = GetString("CartV2.NextStepButtonName"), 3406 OnClick = "Buttons.LockButton(event, true)", 3407 Name = GetString("CartV2.NextStepButtonName") 3408 }) 3409 </div> 3410 <div class="u-pull--left"> 3411 @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") }) 3412 </div> 3413 </div> 3414 </div> 3415 } 3416 <script type="text/javascript"> 3417 function getCook(cookiename) { 3418 // Get name followed by anything except a semicolon 3419 var cookiestring = RegExp(cookiename + "=[^;]+").exec(document.cookie); 3420 // Return everything after the equal sign, or an empty string if the cookie name not found 3421 return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, "") : ""); 3422 } 3423 function GoToProductPage() { 3424 var cookieValue = getCook('ProductLink'); 3425 if (document.cookie.indexOf("ProductLink=") >= 0) { 3426 location.href = cookieValue; 3427 3428 } 3429 else{ 3430 location.href = "/Default.aspx?ID=@GetPageIdByNavigationTag("ProductsPage")"; 3431 } 3432 3433 } 3434 </script> 3435 <script type="text/javascript"> 3436 isDecimalsThis=function(input){ 3437 let str = input.value 3438 const regExp = /^\d*(\.)?(\d{0,2})?$/ 3439 status = regExp.test(str) ? 'valid' : 'invalid' 3440 if (status === "valid") { 3441 document.getElementById("discountBtn").classList.remove("disabled") 3442 document.getElementById("error-discount").classList.add("u-hidden"); 3443 } 3444 else { 3445 document.getElementById("discountBtn").classList.add("disabled"); 3446 document.getElementById("error-discount").classList.remove("u-hidden"); 3447 } 3448 3449 console.log(status + ' : ' + input.value) 3450 3451 } 3452 changeDiscount = function (l) { 3453 let discoutnBtn = document.getElementById("discountBtn"); 3454 let selectElement = l.value; 3455 let inputElement = document.getElementsByClassName("orderDiscount")[0]; 3456 inputElement.setAttribute("id", selectElement); 3457 inputElement.setAttribute("name", selectElement); 3458 discoutnBtn.setAttribute("onclick", "HandlebarsBolt.UpdateContent('Cart', '/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")&CartCmd=setdiscount&" + selectElement + "='+ document.getElementById('" + selectElement+"').value);return false;") 3459 3460 } 3461 var getJSON = function (url, callback) { 3462 var xhr = new XMLHttpRequest(); 3463 xhr.open('GET', url, true); 3464 xhr.responseType = 'json'; 3465 xhr.onload = function () { 3466 var status = xhr.status; 3467 if (status === 200) { 3468 callback(null, xhr.response); 3469 } else { 3470 callback(status, xhr.response); 3471 } 3472 }; 3473 xhr.send(); 3474 }; 3475 3476 ValidationCode = function (l, e, id) { 3477 l.preventDefault() 3478 var selectForm = document.getElementById("OrderSubmit"); // Select the form by ID. 3479 3480 let elementname = e; 3481 let elementvalue = id; 3482 clearTimeout(updateDelay); 3483 3484 updateDelay = setTimeout(function () { 3485 const XHR = new XMLHttpRequest(), 3486 FD = new FormData(); 3487 FD.append(elementname, elementvalue); 3488 XHR.addEventListener('load', function (event) { 3489 //Success 3490 }); 3491 // Define what happens in case of error 3492 XHR.addEventListener(' error', function (event) { 3493 //Error 3494 }); 3495 XHR.open('POST', 'Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")'); 3496 XHR.send(FD); 3497 3498 getJSON('/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")', 3499 function (err, data) { 3500 if (err !== null) { 3501 console.log('Something went wrong: ' + err); 3502 } else { 3503 3504 if (data[0].orderIsAuthenticatedClean === false) { 3505 HandlebarsBolt.UpdateContent('Cart', 3506 '/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")' + '&redirect=false', 3507 '/Default.aspx?ID=@GetPageIdByNavigationTag("MiniCartFeed")' + '&redirect=false', 3508 'CartContent', 'minimal'); 3509 } 3510 else { 3511 document.getElementById('OrderSubmit').dispatchEvent(new Event('submit')); 3512 document.getElementById('OrderSubmit').submit(); 3513 } 3514 } 3515 }) 3516 3517 3518 }, 100); 3519 3520 }; 3521 3522 3523 </script> 3524 3525 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3526 @using Dynamicweb 3527 @using Dynamicweb.Core 3528 @using System.Collections; 3529 @using System 3530 @using System.Web 3531 @using System.Linq; 3532 @using System.Collections.Generic 3533 @using Dynamicweb.Rapido.Blocks 3534 @using Dynamicweb.Rapido.Blocks.Components 3535 @using Dynamicweb.Rapido.Blocks.Components.General 3536 3537 3538 @helper RenderAcceptanceCustom() 3539 { 3540 if (GetBoolean("Ecom:Cart.UseNewsletterSubscription")) 3541 { 3542 @Render(new HiddenField { Name = "EcomOrderSubscribeToNewsletter" }) 3543 @Render(new CheckboxField { Name = "EcomOrderSubscribeToNewsletter", Id = "EcomOrderSubscribeToNewsletter", Label = Translate("Subscribe to newsletter") }) 3544 } 3545 3546 if (Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions")) 3547 { 3548 @Render(new HiddenField { Name = "EcomOrderCustomerAccepted", Id = "EcomOrderCustomerAccepted", Value = "1" }) 3549 } 3550 else 3551 { 3552 string termsPageIt = GetPageIdByNavigationTag("TermsAndConditions").ToString(); 3553 @Render(new CheckboxField { Name = "EcomOrderCustomerAccepted", Id = "EcomOrderCustomerAccepted", OnChange = "EnableCheckoutButton()", Label = Translate("I accept") + " <a href=\"/Default.aspx?ID=" + termsPageIt + "\">" + Translate("the terms and conditions") + "</a>", ErrorMessage = GetString("Ecom:Cart.ValidationError.EcomOrderCustomerAccepted.ErrorMessage") }) 3554 } 3555 <script type="text/javascript"> 3556 function EnableCheckoutButton() { 3557 var stepButtonId = document.getElementById("CartV2.GotoStep3") ? "CartV2.GotoStep3" : "CartV2.GotoStep1"; 3558 var stepButton = document.getElementById(stepButtonId); 3559 let isValid = true; 3560 3561 if (isValid) { 3562 if (document.getElementById("EcomOrderCustomerAccepted").checked) { 3563 3564 var elements = document.getElementsByClassName('error-input'); 3565 var i; 3566 for (i = 0; i < elements.length; i++) { 3567 var error = elements[i].dataset.error; 3568 var value = elements[i].value; 3569 if (value != "ok" || value == "") { 3570 isValid = false; 3571 console.log(elements[i].dataset.error) 3572 document.getElementById("errorCode").innerHTML += "<div class='field-error u-full-width dw-mod'>" + error + "</div>"; 3573 document.getElementById("EcomOrderCustomerAccepted").checked = true 3574 3575 } 3576 3577 3578 } 3579 3580 3581 if (isValid) { 3582 stepButton.disabled = false; 3583 stepButton.classList.remove('disabled'); 3584 } 3585 3586 } 3587 else { 3588 if (document.getElementById("errorCode")) { 3589 document.getElementById("errorCode").innerHTML = ""; 3590 } 3591 3592 stepButton.disabled = true; 3593 stepButton.classList.add('disabled'); 3594 } 3595 } 3596 3597 3598 3599 } 3600 3601 </script> 3602 } 3603 @if (checkoutPageType == "multistep") 3604 { 3605 3606 <text>@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3607 @using Dynamicweb.Core 3608 @using System 3609 @using System.Web 3610 @using System.Collections.Generic 3611 @using Dynamicweb.Rapido.Blocks 3612 3613 @{ 3614 BlocksPage stepNavigationCheckoutPageCustom = BlocksPage.GetBlockPage("CheckoutPage"); 3615 3616 Block checkoutStepNavigationCustom = new Block() 3617 { 3618 Id = "StepNavigation", 3619 SortId = 50, 3620 Template = RenderStepNavigationCustom(), 3621 Design = new Design 3622 { 3623 RenderType = RenderType.Column, 3624 Size = "12" 3625 } 3626 3627 }; 3628 stepNavigationCheckoutPageCustom.ReplaceBlock(checkoutStepNavigationCustom); 3629 } 3630 3631 @helper RenderStepNavigationCustom() 3632 { 3633 var paymentCountryCode = GetString("Ecom:Order.Customer.Country.Code"); 3634 var shippingCountryCode = GetString("Ecom:Order.Delivery.Country.Code"); 3635 var paymentCountryIsSupported = string.IsNullOrEmpty(paymentCountryCode) || GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == paymentCountryCode)); 3636 var shippingCountryIsSupported = string.IsNullOrEmpty(shippingCountryCode) ? paymentCountryIsSupported : GetLoop("Countries").Any(country => (country.GetString("Ecom:Country.Code2") == shippingCountryCode)); 3637 var emptyOrContinueBtn = Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage") != null ? Pageview.AreaSettings.GetItem("Custom").GetItem("CustomSettings").GetList("CheckoutPage").SelectedValue : "empty"; 3638 3639 var canCompleteOrder = paymentCountryIsSupported && shippingCountryIsSupported; 3640 3641 3642 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 3643 int currentStep = 1; 3644 string disableNextButton = ""; 3645 string nextButtonName = Translate("Next"); 3646 3647 foreach (LoopItem step in GetLoop("StepButtons")) 3648 { 3649 if (step.GetBoolean("Step.Current")) 3650 { 3651 currentStep = step.GetInteger("Step.Number"); 3652 } 3653 3654 if (step.GetInteger("Step.Number") == currentStep + 1) 3655 { 3656 if (Pageview.Device.ToString() != "Mobile") 3657 { 3658 nextButtonName = Translate("Go to") + " " + step.GetString("Step.Name"); 3659 } 3660 else 3661 { 3662 nextButtonName = step.GetString("Step.Name"); 3663 } 3664 } 3665 } 3666 3667 if (currentStep == GetLoop("StepButtons").Count - 1) 3668 { 3669 disableNextButton = Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideTermsAndConditions") ? "" : "disabled"; //not disable button if terms are hidden 3670 nextButtonName = Translate("Confirm order"); 3671 } 3672 3673 if (currentStep > 1 && !canCompleteOrder) 3674 { 3675 disableNextButton = "disabled"; 3676 } 3677 bool RequireAuthorization = GetLoop("OrderLines").Any(x => x.GetBoolean("Ecom:Product:Field.RequireAuthorization")); 3678 <div class="card u-color-light--bg dw-mod"> 3679 @if (currentStep == 1) 3680 { 3681 <div class="u-pull--left"> 3682 @if (emptyOrContinueBtn == "empty") 3683 { 3684 @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);" }) 3685 3686 } 3687 else 3688 { 3689 @Render(new Button { ButtonType = ButtonType.Button, ButtonLayout = ButtonLayout.Secondary, CssClass = "btn--condensed u-pull--left u-no-margin", Title = Translate("Continue shopping"), OnClick = "GoToProductPage();" }) 3690 3691 } 3692 </div> 3693 3694 } 3695 else 3696 { 3697 <div class="u-pull--left"> 3698 3699 <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> 3700 </div> 3701 } 3702 3703 <div class="u-pull--right"> 3704 @if (RequireAuthorization) 3705 { 3706 <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> 3707 } 3708 else 3709 { 3710 <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> 3711 3712 } 3713 </div> 3714 3715 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 3716 { 3717 <div class="u-pull--right"> 3718 <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> 3719 </div> 3720 } 3721 </div> 3722 } 3723 <script type="text/javascript"> 3724 function getCook(cookiename) { 3725 // Get name followed by anything except a semicolon 3726 var cookiestring = RegExp(cookiename + "=[^;]+").exec(document.cookie); 3727 // Return everything after the equal sign, or an empty string if the cookie name not found 3728 return decodeURIComponent(!!cookiestring ? cookiestring.toString().replace(/^[^=]+./, "") : ""); 3729 } 3730 function GoToProductPage() { 3731 var cookieValue = getCook('ProductLink'); 3732 if (document.cookie.indexOf("ProductLink=") >= 0) { 3733 location.href = cookieValue; 3734 3735 } 3736 else{ 3737 location.href = "/Default.aspx?ID=@GetPageIdByNavigationTag("ProductsPage")"; 3738 } 3739 3740 } 3741 </script></text> 3742 <text>@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 3743 @using Dynamicweb.Core 3744 @using System 3745 @using System.Web 3746 @using System.Linq 3747 @using System.Collections.Generic 3748 @using System.Text.RegularExpressions 3749 @using Dynamicweb.Extensibility 3750 @using Dynamicweb.Content 3751 @using Dynamicweb.Core 3752 @using Dynamicweb.Ecommerce.Orders 3753 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 3754 @using Dynamicweb.Rapido.Blocks 3755 @using Dynamicweb.Rapido.Blocks.Components 3756 @using Dynamicweb.Rapido.Blocks.Components.General 3757 3758 @{ 3759 BlocksPage staticSummaryCheckoutPageCustom = BlocksPage.GetBlockPage("CheckoutPage"); 3760 3761 Block staticSummaryCustom = new Block() 3762 { 3763 Id = "StaticSummary", 3764 SortId = 20, 3765 Design = new Design 3766 { 3767 RenderType = RenderType.Column, 3768 Size = "12" 3769 }, 3770 BlocksList = new List<Block> { 3771 new Block { 3772 Id = "StaticSummaryHeader", 3773 SortId = 10, 3774 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 } }, 3775 Design = new Design { 3776 RenderType = RenderType.CardHeader, 3777 CssClass = "u-color-light--bg" 3778 } 3779 }, 3780 new Block { 3781 Id = "StaticSummaryBody", 3782 SortId = 20, 3783 Template = RenderStaticSummaryCustom(), 3784 Design = new Design { 3785 RenderType = RenderType.CardBody, 3786 CssClass = "u-color-light--bg u-no-padding--xs" 3787 } 3788 } 3789 } 3790 }; 3791 staticSummaryCheckoutPageCustom.ReplaceBlock(staticSummaryCustom); 3792 } 3793 3794 3795 @helper RenderStaticSummaryCustom() 3796 { 3797 int productCatalog = GetPageIdByNavigationTag("ProductsPage"); 3798 bool hasTaxSettings = Dynamicweb.Rapido.Services.Countries.HasTaxSettings(GetString("Ecom:Order.ID")); 3799 bool pointShop = Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly"); 3800 bool isPricesWithVATEnabled = Converter.ToBoolean(Pageview.Area.EcomPricesWithVat); 3801 double shippingFeePrice = GetDouble("Ecom:Order.ShippingFee.Price"); 3802 double minPriceForFree = 0; 3803 double minPriceForFreeShip = 0; 3804 double aditionalPriceForFreeShipping = 0; 3805 double totalPriceWithoutFormated = GetDouble("Ecom:Order.Price.Price"); 3806 var shippingMethods = GetLoop("Shippingmethods"); 3807 var currency = Dynamicweb.Ecommerce.Services.Currencies.GetDefaultCurrency(); 3808 foreach (LoopItem shipping in shippingMethods) 3809 { 3810 3811 if (shipping.GetString("Ecom:Cart.Shippingmethod.Name") == GetString("Ecom:Order.ShippingMethod")) 3812 { 3813 minPriceForFree = shipping.GetDouble("Ecom:Cart.Shippingmethod.MinimumPriceForFreeFee.Price"); 3814 minPriceForFreeShip = minPriceForFree; 3815 if (shipping.GetDouble("Ecom:Cart.Shippingmethod.MinimumPriceForFreeFee.Price") > (totalPriceWithoutFormated - shippingFeePrice)) 3816 { 3817 aditionalPriceForFreeShipping = minPriceForFree - (totalPriceWithoutFormated - shippingFeePrice); 3818 3819 } 3820 3821 } 3822 } 3823 string cartFeedPageId = GetPageIdByNavigationTag("MiniCartFeed").ToString(); 3824 if (!String.IsNullOrWhiteSpace(GetString("Ecom:OrderContext.ID"))) 3825 { 3826 cartFeedPageId += "&OrderContext=" + GetString("Ecom:OrderContext.ID"); 3827 } 3828 <div class="js-handlebars-root" id="SummaryCart" data-template="CartOrderlineSummary" data-cart-id="@cartFeedPageId" data-json-feed="/Default.aspx?ID=@cartFeedPageId" data-preloader="minimal"> 3829 3830 3831 </div> 3832 <script id="CartOrderlineSummary" type="text/x-template"> 3833 {{#.}} 3834 <table class="table cart-table u-margin-bottom u-border-bottom dw-mod"> 3835 <tbody> 3836 {{#OrderLines}} 3837 {{> (lookup . 'template') }} 3838 {{/OrderLines}} 3839 3840 3841 </tbody> 3842 3843 </table> 3844 @if (!pointShop) 3845 { 3846 <text> 3847 {{#unless hideSubTotal}} 3848 <div class="u-padding-bottom u-padding-x"> 3849 <div class="cart-summary__subtotals dw-mod">@Translate("Subtotal") </div> 3850 <div class="cart-summary__subtotals u-pull--right dw-mod"> 3851 @if (hasTaxSettings) 3852 { 3853 <text> 3854 {{subtotalpricewithouttaxes}} 3855 </text> 3856 3857 } 3858 else 3859 { 3860 <text> 3861 {{subtotalprice}} 3862 </text> 3863 3864 } 3865 </div> 3866 </div> 3867 {{/unless}} 3868 </text> 3869 <text> 3870 {{#unless hidePaymentfee}} 3871 <div class="u-padding-bottom u-padding-x"> 3872 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-credit-card", Label = "{{paymentmethod}}", LabelPosition = IconLabelPosition.After })</div> 3873 <div class="cart-summary__info u-pull--right dw-mod">{{paymentfee}}</div> 3874 </div> 3875 {{/unless}} 3876 </text> 3877 } 3878 3879 {{#unless hideShippingfee}} 3880 <div class="u-padding-bottom u-padding-x"> 3881 <div class="cart-summary__info dw-mod">@Render(new Icon { Prefix = "fas", Name = "fa-truck", Label = "{{shippingmethod}}", LabelPosition = IconLabelPosition.After })</div> 3882 <div class="cart-summary__info u-pull--right dw-mod">{{shippingfee}}</div> 3883 </div> 3884 {{#unless notTxtForShippingFree}} 3885 <div class="u-padding-bottom u-padding-x"> 3886 <div class="cart-summary__info dw-mod"><span class="txt-small">@Translate("Free shipping - Buy for additional") {{aditionalPriceForFreeShipping}}</span> </div> 3887 <div class="cart-summary__info u-pull--right dw-mod"></div> 3888 </div> 3889 {{/unless}} 3890 {{/unless}} 3891 3892 3893 3894 {{#if hasTaxSettings}} 3895 <div class="u-padding-bottom u-padding-x"> 3896 <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> 3897 <div class="cart-summary__info u-pull--right dw-mod">{{totaltaxes}}</div> 3898 </div> 3899 3900 3901 {{/if}} 3902 3903 @if (Pageview.User != null && Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints") && GetDouble("Ecom:Order.RewardTotalPoints") > 0) 3904 { 3905 <text> 3906 {{#if earnings}} 3907 <div class="u-padding-bottom u-padding-x"> 3908 <div class="cart-summary__info dw-mod">@Translate("Earnings")</div> 3909 <div class="cart-summary__info u-pull--right dw-mod"><span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")</div> 3910 </div> 3911 {{/if}} 3912 </text> 3913 3914 } 3915 3916 <div class="u-padding u-border-top"> 3917 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 3918 <div class="cart-summary__totals u-pull--right dw-mod">{{totalprice}}</div> 3919 </div> 3920 3921 @if (!pointShop && !hasTaxSettings) 3922 { 3923 <div class="u-ta-right u-padding-x"> 3924 <small class="cart-summary__info dw-mod">@Translate("VAT"):</small> 3925 <small class="cart-summary__info dw-mod">{{totalvat}}</small> 3926 </div> 3927 3928 if (isPricesWithVATEnabled) 3929 { 3930 <div class="u-ta-right u-padding-x"> 3931 <small class="cart-summary__info dw-mod">@Translate("Total price without VAT"):</small> 3932 <small class="cart-summary__info dw-mod">{{totalPriceWithoutVat}}</small> 3933 </div> 3934 } 3935 else 3936 { 3937 <div class="u-ta-right u-padding-x"> 3938 <small class="cart-summary__info dw-mod">@Translate("Total price with VAT"):</small> 3939 <small class="cart-summary__info dw-mod">{{totalPriceWithVat}}</small> 3940 </div> 3941 } 3942 } 3943 3944 {{#if showCheckoutDisclaimer}} 3945 <div class="u-ta-right"> 3946 <small class="u-full-width">{{checkoutDisclaimer}}</small> 3947 </div> 3948 {{/if}} 3949 3950 {{/.}} 3951 </script> 3952 <script id="CartOrderline" type="text/x-template"> 3953 {{#unless isEmpty}} 3954 <tr> 3955 <td class="u-w60px"> 3956 {{quantity}} x 3957 </td> 3958 <td title="{{name}} {{variantname}}"> 3959 <a href="{{link}}" class="u-color-inherit">{{name}}</a> 3960 <div>{{{variantname}}}</div> 3961 <div>{{unitname}}</div> 3962 @*{{#if trainingInfo}} 3963 <div class="cart-orderline__cell__block item-number dw-mod"><small>{{trainingInfo}} </small></div> 3964 {{/if}}*@ 3965 </td> 3966 {{#if pointsTotal}} 3967 <td class="u-ta-right u-w120px"> 3968 <span class="u-color--loyalty-points">{{pointPrice}}</span> @Translate("points") 3969 </td> 3970 {{else}} 3971 3972 <td class="u-ta-right u-w120px">{{totalprice}}</td> 3973 {{/if}} 3974 </tr> 3975 <tr class="{{hideBomItems}}"> 3976 <td colspan="3" class="u-no-padding"> 3977 <table class="u-no-margin u-color-light-gray--bg"> 3978 <tbody> 3979 {{#BomItems}} 3980 <tr> 3981 <td class="u-w60px">{{quantity}} x</td> 3982 <td title="{{name}} {{variantname}}"> 3983 <a href="{{link}}">{{name}}</a> 3984 <div>{{variantname}}</div> 3985 <div>{{unitname}}</div> 3986 </td> 3987 </tr> 3988 {{/BomItems}} 3989 </tbody> 3990 </table> 3991 </td> 3992 </tr> 3993 {{/unless}} 3994 </script> 3995 <script id="CartOrderlineDiscount" type="text/x-template"> 3996 <tr class="table__row--no-border"> 3997 <td class="u-w60px"> 3998 {{#unless notDiscountImage}} 3999 <img src="{{{image}}}"> 4000 {{/unless}} 4001 </td> 4002 <td>{{name}}</td> 4003 <td class="cart-table__price u-ta-right dw-mod">{{totalprice}}</td> 4004 </tr> 4005 </script> 4006 4007 } 4008 </text> 4009 4010 } 4011 4012 4013 @helper RenderCheckoutForm() 4014 { 4015 List<Block> subBlocks = checkoutPage.GetBlockListById("CheckoutForm").OrderBy(item => item.SortId).ToList(); 4016 string pageId = GetGlobalValue("Global:Page.ID"); 4017 4018 <section class="multiple-paragraphs-container u-color-light-gray--bg paragraph-container--full-width"> 4019 <div class="center-container center-container--with-background-image dw-mod"> 4020 <div class="paragraph-container u-padding"> 4021 <form name="ordersubmit" id="OrderSubmit" method="post" action="/Default.aspx?ID=@pageId" autocomplete="off"> 4022 <div class="grid grid--external-bleed-x"> 4023 @RenderBlockList(subBlocks) 4024 </div> 4025 </form> 4026 </div> 4027 </div> 4028 </section> 4029 } 4030 4031 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 4032 @RenderBlockList(checkoutPage.BlocksRoot.BlocksList)