KURV TEST

Error executing template "Designs/Rapido/eCom7/CartV2/Step/CartDWTESTER.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_c660c3a907a843b49de779aed5544dbf.b__17_0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\scangrip.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\CartDWTESTER.cshtml:line 1259
   at CompiledRazorTemplates.Dynamic.RazorEngine_c660c3a907a843b49de779aed5544dbf.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\scangrip.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\CartDWTESTER.cshtml:line 137
   at CompiledRazorTemplates.Dynamic.RazorEngine_c660c3a907a843b49de779aed5544dbf.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\scangrip.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\CartDWTESTER.cshtml:line 101
   at CompiledRazorTemplates.Dynamic.RazorEngine_c660c3a907a843b49de779aed5544dbf.<>c__DisplayClass3_0.b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\scangrip.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\CartDWTESTER.cshtml:line 142
   at CompiledRazorTemplates.Dynamic.RazorEngine_c660c3a907a843b49de779aed5544dbf.<>c__DisplayClass2_0.b__0(TextWriter __razor_helper_writer) in D:\dynamicweb.net\Solutions\scangrip.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\CartDWTESTER.cshtml:line 101
   at CompiledRazorTemplates.Dynamic.RazorEngine_c660c3a907a843b49de779aed5544dbf.Execute() in D:\dynamicweb.net\Solutions\scangrip.dw9.dynamicweb-cms.com\Files\Templates\Designs\Rapido\eCom7\CartV2\Step\CartDWTESTER.cshtml:line 1687
   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.b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 3 @using Dynamicweb.Extensibility 4 @using Dynamicweb.Content 5 @using Dynamicweb.Core 6 @using Dynamicweb.Ecommerce.Orders 7 @using Dynamicweb.Ecommerce.Orders.SalesDiscounts 8 @using System 9 @using Dynamicweb.Rapido.Blocks 10 11 12 @functions{ 13 BlocksPage checkoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 14 string checkoutPageType = "onestep"; 15 } 16 17 @{ 18 string pageId = GetGlobalValue("Global:Page.ID"); 19 20 Block checkoutTopSnippets = new Block() 21 { 22 Id = "CheckoutTopSnippets", 23 SortId = 10 24 }; 25 checkoutPage.Add(checkoutTopSnippets); 26 27 Block addressContainer = new Block() 28 { 29 Id = "AddressContainer", 30 SortId = 20, 31 Design = new Design 32 { 33 RenderType = RenderType.Column, 34 Size = "4", 35 HidePadding = true 36 }, 37 BlocksList = new List<Block> { 38 new Block() 39 { 40 Id = "AddressContainerRow", 41 SortId = 10, 42 Design = new Design 43 { 44 RenderType = RenderType.Row 45 } 46 } 47 } 48 }; 49 checkoutPage.Add(addressContainer); 50 51 Block orderContainer = new Block() 52 { 53 Id = "OrderContainer", 54 SortId = 30, 55 Design = new Design 56 { 57 RenderType = RenderType.Column, 58 Size = "auto", 59 HidePadding = true 60 }, 61 BlocksList = new List<Block> { 62 new Block() 63 { 64 Id = "OrderContainerRow", 65 SortId = 10, 66 Design = new Design 67 { 68 RenderType = RenderType.Row 69 } 70 } 71 } 72 }; 73 checkoutPage.Add(orderContainer); 74 75 Block checkoutBottomSnippets = new Block() 76 { 77 Id = "CheckoutBottomSnippets", 78 SortId = 50 79 }; 80 checkoutPage.Add(checkoutBottomSnippets); 81 } 82 83 @* Include the required Grid builder (Contains the methods @RenderBlockList and @RenderBlock) *@ 84 @using System.Text.RegularExpressions 85 @using System.Collections.Generic 86 @using Dynamicweb.Rapido.Blocks 87 88 89 @*--- START: Base block renderers ---*@ 90 91 @helper RenderBlockList(List<Block> blocks) 92 { 93 blocks = blocks.OrderBy(item => item.SortId).ToList(); 94 95 foreach (Block item in blocks) 96 { 97 <!-- START: @item.Id --> 98 99 if (item.Design == null) 100 { 101 @RenderBlock(item) 102 } 103 else if (item.Design.RenderType != RenderType.Hide) 104 { 105 if (item.Design.RenderType == RenderType.Row) 106 { 107 <div class="grid grid--align-content-start"> 108 @RenderBlock(item) 109 </div> 110 } 111 112 if (item.Design.RenderType == RenderType.Column) 113 { 114 string hidePadding = item.Design.HidePadding ? "u-no-padding" : ""; 115 string size = item.Design.Size != null ? item.Design.Size : "12"; 116 size = Regex.IsMatch(size, @"\d") ? "md-" + item.Design.Size : item.Design.Size; 117 118 <div class="grid__col-lg-@item.Design.Size grid__col-md-@item.Design.Size grid__col-sm-12 grid__col-xs-12 @hidePadding" id="Block__@item.Id"> 119 @RenderBlock(item) 120 </div> 121 } 122 123 if (item.SkipRenderBlocksList == true) 124 { 125 @RenderBlock(item) 126 } 127 } 128 129 <!-- END: @item.Id --> 130 } 131 } 132 133 @helper RenderBlock(Block item) 134 { 135 if (item.Template != null) 136 { 137 @BlocksPage.RenderTemplate(item.Template) 138 } 139 140 if (item.BlocksList.Count > 0 && item.SkipRenderBlocksList == false) 141 { 142 @RenderBlockList(item.BlocksList) 143 } 144 } 145 146 @*--- END: Base block renderers ---*@ 147 148 149 @* Include the Blocks for the page *@ 150 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 151 @using Dynamicweb.Core 152 @using System 153 @using System.Web 154 @using System.Collections.Generic 155 @using Dynamicweb.Rapido.Blocks 156 157 @{ 158 BlocksPage billingAddressCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 159 160 Block billingAddressBlock = new Block() 161 { 162 Id = "BillingAddress", 163 SortId = 10, 164 Template = RenderCustomerAddress(), 165 Design = new Design 166 { 167 RenderType = RenderType.Column, 168 Size = "12" 169 } 170 }; 171 billingAddressCheckoutPage.Add("AddressContainerRow", billingAddressBlock); 172 173 Block addressScriptTemplates = new Block() 174 { 175 Id = "AddressTemplates", 176 SortId = 10, 177 Template = RenderAddressScriptTemplates() 178 }; 179 billingAddressCheckoutPage.Add("CheckoutBottomSnippets", addressScriptTemplates); 180 } 181 182 @helper RenderCustomerAddress() { 183 string editProfileLink = "/Default.aspx?ID=" + GetPageIdByNavigationTag("CustomerProfile").ToString(); 184 185 <div class="card-header u-color-light--bg dw-mod"> 186 <h3><i class="fas fa-home"></i> @Translate("Billing address")</h3> 187 </div> 188 189 <div class="card u-color-light--bg dw-mod"> 190 @if (!Dynamicweb.Core.Converter.ToBoolean(GetGlobalValue("Global:Extranet.UserName")) || GetLoop("ValidationErrors").Count > 0) 191 { 192 //When the user is not signed in, or there are form errors, give the possibility to either sign in or create address 193 if (!Dynamicweb.Core.Converter.ToBoolean(GetGlobalValue("Global:Extranet.UserName"))) 194 { 195 @*<label class="btn btn--secondary btn--full dw-mod more" for="SignInModalTrigger">@Translate("Already a customer?")</label>*@ 196 } 197 198 <div class="form__field-group dw-mod"> 199 <label for="EcomOrderCustomerCompany">@Translate("Company")</label> 200 <input type="text" class="u-full-width" name="EcomOrderCustomerCompany" id="EcomOrderCustomerCompany" value="@GetString("Ecom:Order.Customer.Company")" /> 201 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerCompany.ErrorMessage")</div> 202 </div> 203 204 <div class="form__field-group dw-mod"> 205 <label for="EcomOrderCustomerName">@Translate("Name")</label> 206 <input type="text" class="u-full-width" name="EcomOrderCustomerName" id="EcomOrderCustomerName" value="@GetString("Ecom:Order.Customer.Name")" required /> 207 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerName.ErrorMessage")</div> 208 </div> 209 210 <div class="form__fields-collection form__fields-collection--2-3"> 211 <div class="form__field-group dw-mod"> 212 <label for="EcomOrderCustomerPhone">@Translate("Phone")</label> 213 <input type="tel" class="u-full-width" name="EcomOrderCustomerPhone" id="EcomOrderCustomerPhone" value="@GetString("Ecom:Order.Customer.Phone")" required /> 214 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerPhone.ErrorMessage")</div> 215 </div> 216 217 <div class="form__field-group dw-mod"> 218 <label for="EcomOrderCustomerEmail">@Translate("Email")</label> 219 @if (GetBoolean("Ecom:Cart.CreateUserInCheckout") && string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 220 { 221 <input type="email" class="u-full-width" name="EcomOrderCustomerEmail" id="EcomOrderCustomerEmail" value="@GetString("Ecom:Order.Customer.Email")" onchange="document.getElementById('EcomUserCreateUserName').value = this.value;" required /> 222 <input type="hidden" name="EcomUserCreateUserName" id="EcomUserCreateUserName" value="@GetString("Ecom:Order.Customer.Email")" /> 223 <input type="hidden" name="EcomUserCreateNew" value="True" /> 224 string pass = Guid.NewGuid().ToString(); 225 <input type="hidden" name="EcomUserCreatePassword" value="@pass" /> 226 <input type="hidden" name="EcomUserCreateConfirmPassword" value="@pass" /> 227 } 228 else 229 { 230 <input type="email" class="u-full-width" name="EcomOrderCustomerEmail" id="EcomOrderCustomerEmail" value="@GetString("Ecom:Order.Customer.Email")" required /> 231 } 232 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerEmail.ErrorMessage")</div> 233 </div> 234 </div> 235 <div class="form__field-group dw-mod"> 236 <label for="EcomOrderCustomerAddress">@Translate("Address")</label> 237 <input type="text" class="u-full-width" name="EcomOrderCustomerAddress" id="EcomOrderCustomerAddress" value="@GetString("Ecom:Order.Customer.Address")" required /> 238 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerAddress.ErrorMessage")</div> 239 </div> 240 241 <div class="form__fields-collection form__fields-collection--2-3"> 242 <div class="form__field-group dw-mod"> 243 <label for="EcomOrderCustomerZip">@Translate("Zip code")</label> 244 <input type="text" class="u-full-width" name="EcomOrderCustomerZip" id="EcomOrderCustomerZip" value="@GetString("Ecom:Order.Customer.Zip")" required /> 245 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerZip.ErrorMessage")</div> 246 </div> 247 248 <div class="form__field-group dw-mod"> 249 <label for="EcomOrderCustomerCity">@Translate("City")</label> 250 <input type="text" class="u-full-width" name="EcomOrderCustomerCity" id="EcomOrderCustomerCity" value="@GetString("Ecom:Order.Customer.City")" required /> 251 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerCity.ErrorMessage")</div> 252 </div> 253 </div> 254 255 if (GetLoop("CustomerRegions").Count > 0) 256 { 257 <div class="form__field-group dw-mod"> 258 <label for="EcomOrderCustomerState">@Translate("State/Region")</label> 259 <select class="u-full-width" name="EcomOrderCustomerRegion" id="EcomOrderCustomerRegion" onchange="Cart.SubmitCart()"> 260 @foreach (LoopItem state in GetLoop("CustomerRegions")) 261 { 262 string selected = GetString("Ecom:Order.Customer.Region") == state.GetString("Ecom:CustomerRegion.Name") ? "selected" : ""; 263 <option value="@state.GetString("Ecom:CustomerRegion.Name")" @selected>@state.GetString("Ecom:CustomerRegion.Name")</option> 264 } 265 </select> 266 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerState.ErrorMessage")</div> 267 </div> 268 } 269 270 <div class="form__field-group dw-mod"> 271 <label for="EcomOrderCustomerCountry">@Translate("Country")</label> 272 <select class="u-full-width" name="EcomOrderCustomerCountry" id="EcomOrderCustomerCountry" onchange="Cart.SubmitCart()"> 273 @{ 274 string customerCountry = GetString("Ecom:Order.Customer.Country.Code"); 275 foreach (LoopItem country2 in GetLoop("Countries")) 276 { 277 string selected = GetString("Ecom:Order.Customer.Country.Code") == country2.GetString("Ecom:Country.Code2") ? "selected" : ""; 278 279 if (string.IsNullOrEmpty(customerCountry) && string.IsNullOrEmpty(selected)) 280 { 281 selected = country2.GetString("Ecom:Country.Code2") == GetGlobalValue("Global:Area.Culture.CountryCode").ToString() ? "selected" : ""; 282 } 283 284 <option value="@country2.GetString("Ecom:Country.Code2")" @selected>@country2.GetString("Ecom:Country.Name")</option> 285 } 286 } 287 </select> 288 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerCountry.ErrorMessage")</div> 289 </div> 290 } 291 else 292 { 293 //When the user is signed in, show static address fields 294 <table class="table table--clean table--condensed"> 295 @if (!String.IsNullOrEmpty(GetString("Ecom:Order.Customer.Company"))) 296 { 297 <tr> 298 <td class="u-bold">@Translate("Company")</td> 299 <td><input type="text" class="u-full-width u-truncate-text" name="EcomOrderCustomerCompany" id="EcomOrderCustomerCompany" value="@GetString("Ecom:Order.Customer.Company")" readonly /></td> 300 </tr> 301 } 302 <tr> 303 <td class="u-bold">@Translate("Name")</td> 304 <td><input type="text" class="u-full-width u-truncate-text" name="EcomOrderCustomerName" id="EcomOrderCustomerName" value="@GetString("Ecom:Order.Customer.Name")" readonly /></td> 305 </tr> 306 <tr> 307 <td class="u-bold">@Translate("Phone")</td> 308 <td><input type="text" class="u-full-width u-truncate-text" name="EcomOrderCustomerPhone" id="EcomOrderCustomerPhone" value="@GetString("Ecom:Order.Customer.Phone")" readonly /></td> 309 </tr> 310 <tr> 311 <td class="u-bold">@Translate("Email")</td> 312 <td><input type="text" class="u-full-width u-truncate-text" name="EcomOrderCustomerEmail" id="EcomOrderCustomerEmail" value="@GetString("Ecom:Order.Customer.Email")" readonly /></td> 313 </tr> 314 <tr> 315 <td class="u-bold">@Translate("Address")</td> 316 <td><input type="text" class="u-full-width u-truncate-text" name="EcomOrderCustomerAddress" id="EcomOrderCustomerAddress" value="@GetString("Ecom:Order.Customer.Address")" readonly /></td> 317 </tr> 318 <tr> 319 <td class="u-bold">@Translate("Zip code")</td> 320 <td><input type="text" class="u-full-width u-truncate-text" name="EcomOrderCustomerZip" id="EcomOrderCustomerZip" value="@GetString("Ecom:Order.Customer.Zip")" readonly /></td> 321 </tr> 322 <tr> 323 <td class="u-bold">@Translate("City")</td> 324 <td><input type="text" class="u-full-width u-truncate-text" name="EcomOrderCustomerCity" id="EcomOrderCustomerCity" value="@GetString("Ecom:Order.Customer.City")" readonly /></td> 325 </tr> 326 @if (GetLoop("CustomerRegions").Count > 0) 327 { 328 string selectedStateName = ""; 329 foreach (LoopItem state in GetLoop("CustomerRegions")) 330 { 331 if (GetString("Ecom:Order.Customer.Region") == state.GetString("Ecom:CustomerRegion.Name")) { 332 selectedStateName = state.GetString("Ecom:CustomerRegion.Name"); 333 } 334 } 335 <tr> 336 <td class="u-bold">@Translate("State/Region")</td> 337 <td><input type="text" class="u-full-width u-truncate-text" name="EcomOrderCustomerRegion" id="EcomOrderCustomerRegion" value="@selectedStateName" readonly /></td> 338 </tr> 339 } 340 <tr> 341 <td class="u-bold">@Translate("Country")</td> 342 <td> 343 @foreach (LoopItem country in GetLoop("Countries")) 344 { 345 if (GetString("Ecom:Order.Customer.Country") == country.GetString("Ecom:Country.Code2") || GetString("Ecom:Order.Customer.Country.Code") == country.GetString("Ecom:Country.Code2")) 346 { 347 <input type="hidden" name="EcomOrderCustomerCountry" id="EcomOrderCustomerCountry" value="@country.GetString("Ecom:Country.Code2")" /> 348 <input type="text" class="u-full-width u-truncate-text" value="@country.GetString("Ecom:Country.Name")" readonly /> 349 } 350 } 351 @if (GetLoop("Countries").Count == 0) 352 { 353 <input type="hidden" name="EcomOrderCustomerCountry" id="EcomOrderCustomerCountry" value="" /> 354 <input type="text" class="u-full-width u-truncate-text" value="" readonly /> 355 } 356 </td> 357 </tr> 358 <tr> 359 <td colspan="2">&nbsp;</td> 360 </tr> 361 </table> 362 363 <a href="@editProfileLink" class="btn btn--secondary btn--full u-no-margin dw-mod">@Translate("Edit profile")</a> 364 } 365 </div> 366 } 367 368 @helper RenderAddressScriptTemplates() { 369 @* Templates for addresses *@ 370 <script id="DeliveryAddressFieldsTemplate" type="text/x-template"> 371 {{#.}} 372 <div class="form__field-group dw-mod"> 373 <label for="EcomOrderDeliveryCompany">@Translate("Company")</label> 374 <input type="text" class="u-full-width" name="EcomOrderDeliveryCompany" id="EcomOrderDeliveryCompany" value="{{company}}" /> 375 <div class="field-error dw-mod {{isSavedAddress}}">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCompany.ErrorMessage")</div> 376 </div> 377 378 <div class="form__field-group dw-mod"> 379 <label for="EcomOrderDeliveryName">@Translate("Name")</label> 380 <input type="text" class="u-full-width" name="EcomOrderDeliveryName" id="EcomOrderDeliveryName" value="{{name}}" /> 381 <div class="field-error dw-mod {{isSavedAddress}}">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryName.ErrorMessage")</div> 382 </div> 383 384 <div class="form__fields-collection form__fields-collection--2-3"> 385 <div class="form__field-group dw-mod"> 386 <label for="EcomOrderDeliveryPhone">@Translate("Phone")</label> 387 <input type="tel" class="u-full-width" name="EcomOrderDeliveryPhone" id="EcomOrderDeliveryPhone" value="{{phone}}" /> 388 <div class="field-error dw-mod {{isSavedAddress}}">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryPhone.ErrorMessage")</div> 389 </div> 390 391 <div class="form__field-group dw-mod"> 392 <label for="EcomOrderDeliveryEmail">@Translate("Email")</label> 393 <input type="email" class="u-full-width" name="EcomOrderDeliveryEmail" id="EcomOrderDeliveryEmail" value="{{email}}" /> 394 <div class="field-error dw-mod {{isSavedAddress}}">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryEmail.ErrorMessage")</div> 395 </div> 396 </div> 397 <div class="form__field-group dw-mod"> 398 <label for="EcomOrderDeliveryAddress">@Translate("Address")</label> 399 <input type="text" class="u-full-width" name="EcomOrderDeliveryAddress" id="EcomOrderDeliveryAddress" value="{{address}}" /> 400 <div class="field-error dw-mod {{isSavedAddress}}">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryAddress.ErrorMessage")</div> 401 </div> 402 403 <div class="form__fields-collection form__fields-collection--2-3"> 404 <div class="form__field-group dw-mod"> 405 <label for="EcomOrderDeliveryZip">@Translate("Zip")</label> 406 <input type="text" class="u-full-width" name="EcomOrderDeliveryZip" id="EcomOrderDeliveryZip" value="{{zip}}" /> 407 <div class="field-error dw-mod {{isSavedAddress}}">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryZip.ErrorMessage")</div> 408 </div> 409 410 <div class="form__field-group dw-mod"> 411 <label for="EcomOrderDeliveryCity">@Translate("City")</label> 412 <input type="text" class="u-full-width" name="EcomOrderDeliveryCity" id="EcomOrderDeliveryCity" value="{{city}}" /> 413 <div class="field-error dw-mod {{isSavedAddress}}">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCity.ErrorMessage")</div> 414 </div> 415 </div> 416 417 <div class="form__field-group dw-mod"> 418 <label for="Country">@Translate("Country")</label> 419 <select class="u-full-width" name="EcomOrderDeliveryCountry" id="Country" onchange="Cart.SubmitCart()" data-countryCode="{{countryCode}}"> 420 {{#Country}} 421 <option value="{{id}}" {{selected}}>{{name}}</option> 422 {{/Country}} 423 </select> 424 </div> 425 {{/.}} 426 427 {{^.}} 428 @Translate("No address found") 429 {{/.}} 430 </script> 431 } 432 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 433 @using Dynamicweb.Core 434 @using System 435 @using System.Web 436 @using System.Collections.Generic 437 @using Dynamicweb.Rapido.Blocks 438 439 @functions { 440 string Truncate(string str, int count) 441 { 442 return str.Substring(0, Math.Min(str.Length, count)); 443 } 444 } 445 446 @{ 447 BlocksPage shippingAddressCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 448 449 Block shippingAddressBlock = new Block() 450 { 451 Id = "ShippingAddress", 452 SortId = 20, 453 Template = RenderShippingAddress(), 454 Design = new Design 455 { 456 RenderType = RenderType.Column, 457 Size = "12" 458 } 459 }; 460 shippingAddressCheckoutPage.Add("AddressContainerRow", shippingAddressBlock); 461 } 462 463 @helper RenderShippingAddress() { 464 string manageAddresses = "/Default.aspx?ID=" + GetPageIdByNavigationTag("CustomerProfile").ToString() + "&Action=ManageAddresses"; 465 int cartAddressesFeedPageId = GetPageIdByNavigationTag("CartAddressesFeed"); 466 467 <div class="card-header u-color-light--bg dw-mod"> 468 <h3><i class="fas fa-map-marker"></i> @Translate("Shipping address")</h3> 469 </div> 470 471 <div class="card u-color-light--bg dw-mod"> 472 <div class="form__field-group u-margin-bottom--lg"> 473 <input type="checkbox" id="AlternateAddressBlock" class="js-remember-state form__control" data-expand="AlternateAddressBlock" /> 474 <label for="AlternateAddressBlock">@Translate("Add alternative adr.")</label> 475 </div> 476 <div class="expandable--collapsed" data-trigger="AlternateAddressBlock"> 477 @if (GetLoop("UserManagement:User.UserAddresses").Count > 0) 478 { 479 <div class="form__field-combi"> 480 <select id="DeliveryAddressSelector" class="u-full-width" onchange="HandlebarsBolt.UpdateContent('DeliveryAddressFields', '/Default.aspx?ID=@cartAddressesFeedPageId&AddressId=' + this.value);"> 481 <option value="-1">@Translate("Select saved address")</option> 482 483 @foreach (LoopItem address in GetLoop("UserManagement:User.UserAddresses")) 484 { 485 string description = Truncate(address.GetString("UserManagement:User.UserAddress.Description"), 25); 486 string userAddress = Truncate(address.GetString("UserManagement:User.UserAddress.Address"), 20); 487 488 <option value="@address.GetString("UserManagement:User.UserAddress.ID")">@description (@userAddress)</option> 489 } 490 </select> 491 <a href="@manageAddresses" id="ManageAddressButton" class="btn btn--primary dw-mod btn--condensed u-no-margin" title="@Translate("Add new address", "Add new address")"><i class="fas fa-plus"></i></a> 492 </div> 493 } 494 495 @if (Dynamicweb.Core.Converter.ToBoolean(GetGlobalValue("Global:Extranet.UserName")) && GetLoop("UserManagement:User.UserAddresses").Count > 0) 496 { 497 <div class="js-handlebars-root" id="DeliveryAddressFields" data-template="DeliveryAddressFieldsTemplate" data-json-feed="/Default.aspx?ID=@cartAddressesFeedPageId&AddressId=0" data-preloader="minimal"></div> 498 } 499 else 500 { 501 <div class="form__field-group dw-mod"> 502 <label for="EcomOrderDeliveryCompany">@Translate("Company")</label> 503 <input type="text" class="u-full-width" name="EcomOrderDeliveryCompany" id="EcomOrderDeliveryCompany" value="@GetString("Ecom:Order.Delivery.Company")" /> 504 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCompany.ErrorMessage")</div> 505 </div> 506 507 <div class="form__field-group dw-mod"> 508 <label for="EcomOrderDeliveryName">@Translate("Name")</label> 509 <input type="text" class="u-full-width" name="EcomOrderDeliveryName" id="EcomOrderDeliveryName" value="@GetString("Ecom:Order.Delivery.Name")" /> 510 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryName.ErrorMessage")</div> 511 </div> 512 513 <div class="form__fields-collection form__fields-collection--2-3"> 514 <div class="form__field-group dw-mod"> 515 <label for="EcomOrderDeliveryPhone">@Translate("Phone")</label> 516 <input type="tel" class="u-full-width" name="EcomOrderDeliveryPhone" id="EcomOrderDeliveryPhone" value="@GetString("Ecom:Order.Delivery.Phone")" /> 517 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryPhone.ErrorMessage")</div> 518 </div> 519 520 <div class="form__field-group dw-mod"> 521 <label for="EcomOrderDeliveryEmail">@Translate("Email")</label> 522 <input type="email" class="u-full-width" name="EcomOrderDeliveryEmail" id="EcomOrderDeliveryEmail" value="@GetString("Ecom:Order.Delivery.Email")" /> 523 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryEmail.ErrorMessage")</div> 524 </div> 525 </div> 526 527 <div class="form__field-group dw-mod"> 528 <label for="EcomOrderDeliveryAddress">@Translate("Address")</label> 529 <input type="text" class="u-full-width" name="EcomOrderDeliveryAddress" id="EcomOrderDeliveryAddress" value="@GetString("Ecom:Order.Delivery.Address")" /> 530 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryAddress.ErrorMessage")</div> 531 </div> 532 533 <div class="form__fields-collection form__fields-collection--2-3"> 534 <div class="form__field-group dw-mod"> 535 <label for="EcomOrderDeliveryZip">@Translate("Zip")</label> 536 <input type="text" class="u-full-width" name="EcomOrderDeliveryZip" id="EcomOrderDeliveryZip" value="@GetString("Ecom:Order.Delivery.Zip")" /> 537 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryZip.ErrorMessage")</div> 538 </div> 539 540 <div class="form__field-group dw-mod"> 541 <label for="EcomOrderDeliveryCity">@Translate("City")</label> 542 <input type="text" class="u-full-width" name="EcomOrderDeliveryCity" id="EcomOrderDeliveryCity" value="@GetString("Ecom:Order.Delivery.City")" /> 543 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryCity.ErrorMessage")</div> 544 </div> 545 </div> 546 547 if (GetLoop("DeliveryRegions").Count > 0) 548 { 549 <div class="form__field-group dw-mod"> 550 <label for="EcomOrderDeliveryRegion">@Translate("State/Region")</label> 551 <select class="u-full-width" name="EcomOrderDeliveryRegion" id="EcomOrderDeliveryRegion" onchange="Cart.SubmitCart()"> 552 @foreach (LoopItem state in GetLoop("DeliveryRegions")) 553 { 554 string selected = GetString("Ecom:Order.Delivery.Region") == state.GetString("Ecom:DeliveryRegion.Name") ? "selected" : ""; 555 <option value="@state.GetString("Ecom:DeliveryRegion.Name")" @selected>@state.GetString("Ecom:DeliveryRegion.Name")</option> 556 } 557 </select> 558 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderDeliveryState.ErrorMessage")</div> 559 </div> 560 } 561 562 <div class="form__field-group dw-mod"> 563 <label for="EcomOrderDeliveryCountry">@Translate("Country")</label> 564 <select class="u-full-width" name="EcomOrderDeliveryCountry" id="EcomOrderDeliveryCountry" onchange="Cart.SubmitCart()"> 565 @{ 566 string deliveryCountry = GetString("Ecom:Order.Delivery.Country.Code"); 567 foreach (LoopItem country in GetLoop("Countries")) 568 { 569 string selected = GetString("Ecom:Order.Delivery.Country.Code") == country.GetString("Ecom:Country.Code2") ? "selected" : ""; 570 571 if (string.IsNullOrEmpty(deliveryCountry) && string.IsNullOrEmpty(selected)) 572 { 573 selected = country.GetString("Ecom:Country.Code2") == GetGlobalValue("Global:Area.Culture.CountryCode").ToString() ? "selected" : ""; 574 } 575 576 <option value="@country.GetString("Ecom:Country.Code2")" @selected>@country.GetString("Ecom:Country.Name")</option> 577 } 578 } 579 </select> 580 </div> 581 } 582 </div> 583 </div> 584 } 585 586 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 587 @using Dynamicweb.Core 588 @using System 589 @using System.Web 590 @using System.Collections.Generic 591 @using Dynamicweb.Rapido.Blocks 592 593 @{ 594 BlocksPage paymentCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 595 bool pointShop = !String.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Ecommerce").GetString("PointShopOnly")) ? Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly") : false; 596 597 if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HidePayment") && GetLoop("Paymethods").Count != 0 && !pointShop) 598 { 599 Block paymentBlock = new Block() 600 { 601 Id = "Payment", 602 SortId = 10, 603 Template = RenderPayment(), 604 Design = new Design 605 { 606 RenderType = RenderType.Column, 607 Size = "6" 608 } 609 }; 610 paymentCheckoutPage.Add("OrderContainerRow", paymentBlock); 611 } 612 } 613 614 @helper RenderPayment() { 615 string cardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 616 string savedCardName = ""; 617 618 <div class="card-header u-color-light--bg dw-mod"> 619 <h3><i class="fas fa-credit-card"></i> @Translate("Payment")</h3> 620 </div> 621 622 <div class="card u-color-light--bg @cardHeightClass dw-mod"> 623 @foreach (LoopItem payment in GetLoop("Paymethods")) 624 { 625 bool supportSavedCards = payment.GetBoolean("Ecom:Cart.Paymethod.SupportSavedCard") && Dynamicweb.Core.Converter.ToBoolean(GetGlobalValue("Global:Extranet.UserName")); 626 string cardIsSaved = !String.IsNullOrEmpty(payment.GetString("Ecom:Order.SavedCardName")) ? "checked" : ""; 627 string selected = payment.GetBoolean("Ecom:Cart.Paymethod.IsSelected") ? "checked" : ""; 628 629 <div> 630 <div class="form__field-group u-margin-bottom"> 631 <input class="form__control" data-expand="savedCards_@payment.GetString("Ecom:Cart.Paymethod.Name")" onchange="Cart.DeselectRadioGroup('EcomCartSavedCardID'); Cart.SubmitCart()" type="radio" name="EcomCartPaymethodID" id="EcomCartPaymethodID_@payment.GetString("Ecom:Cart.Paymethod.ID")" value="@payment.GetString("Ecom:Cart.Paymethod.ID")" @selected /> 632 <label for="EcomCartPaymethodID_@payment.GetString("Ecom:Cart.Paymethod.ID")" class="u-inline">@payment.GetString("Ecom:Cart.Paymethod.Name")</label> 633 </div> 634 @if (supportSavedCards) 635 { 636 <div class="expandable--collapsed dw-mod" data-trigger="savedCards_@payment.GetString("Ecom:Cart.Paymethod.Name")"> 637 <div class="u-border-top u-border-bottom u-padding u-margin-bottom show"> 638 <div class="form__field-group u-margin-bottom"> 639 <input type="checkbox" class="form__control" name="EcomOrderSavedCardCreate" id="EcomOrderSavedCardCreate_@payment.GetString("Ecom:Cart.Paymethod.ID")" value="true" @cardIsSaved /> 640 <label for="EcomOrderSavedCardCreate_@payment.GetString("Ecom:Cart.Paymethod.ID")">@Translate("Save used card")</label> 641 </div> 642 <div> 643 <input type="text" class="u-full-width u-no-margin" onkeyup="document.getElementById('MySavedCardName').value = this.value;" placeholder="@Translate("Saved card name")" value="@payment.GetString("Ecom:Order.SavedCardName")" /> 644 </div> 645 </div> 646 </div> 647 } 648 </div> 649 } 650 651 @if (GetLoop("SavedCards").Count > 0) 652 { 653 <div class="u-bold u-margin-top">@Translate("Pay with a saved card")</div> 654 655 foreach (LoopItem card in GetLoop("SavedCards")) 656 { 657 string selected = card.GetBoolean("Ecom:SavedCard.IsSelected") ? "checked" : ""; 658 659 <div> 660 <input onchange="Cart.DeselectRadioGroup('EcomCartPaymethodID'); Cart.SubmitCart()" class="form__control" type="radio" name="EcomCartSavedCardID" id="EcomCartSavedCardID" value="@card.GetString("Ecom:SavedCard.ID")" @selected /> 661 <label for="EcomCartSavedCardID" class="u-inline u-margin-bottom">@card.GetString("Ecom:SavedCard.Name")</label> 662 </div> 663 664 if (!String.IsNullOrEmpty(selected)) 665 { 666 savedCardName = card.GetString("Ecom:SavedCard.Name"); 667 } 668 } 669 } 670 671 <input type="hidden" name="EcomOrderSavedCardName" id="MySavedCardName" value="@savedCardName" /> 672 </div> 673 } 674 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 675 @using Dynamicweb.Core 676 @using System 677 @using System.Web 678 @using System.Collections.Generic 679 @using Dynamicweb.Rapido.Blocks 680 681 @{ 682 BlocksPage shippingCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 683 684 if (GetLoop("Shippingmethods").Count > 0) { 685 Block shippingBlock = new Block() 686 { 687 Id = "Shipping", 688 SortId = 20, 689 Template = RenderShipping(), 690 Design = new Design 691 { 692 RenderType = RenderType.Column, 693 Size = "6" 694 } 695 }; 696 shippingCheckoutPage.Add("OrderContainerRow", shippingBlock); 697 698 Block parcelShopsModal = new Block() 699 { 700 Id = "ParcelShopsModal", 701 SortId = 10, 702 Template = RenderParcelShopsModal() 703 }; 704 shippingCheckoutPage.Add("CheckoutTopSnippets", parcelShopsModal); 705 } 706 } 707 708 @helper RenderShipping() { 709 string cardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 710 bool defaultShippingIsSet = Dynamicweb.Ecommerce.Orders.Shipping.GetDefaultShippingMethod(Dynamicweb.Ecommerce.Common.Context.Cart.ShippingMethodCountryCode) != null; 711 712 <div class="card-header u-color-light--bg dw-mod"> 713 <h3><i class="fas fa-truck"></i> @Translate("Shipping")</h3> 714 </div> 715 716 <div class="card u-color-light--bg @cardHeightClass dw-mod"> 717 @{ 718 bool haveShippingContent = GetLoop("Shippingmethods").Count != 1 || !defaultShippingIsSet; 719 bool showShippingsBlock = haveShippingContent; 720 } 721 722 @foreach (LoopItem shipping in GetLoop("Shippingmethods")) 723 { 724 bool selected = Converter.ToBoolean(shipping.GetString("Ecom:Cart.Shippingmethod.IsSelected")); 725 object shippingProviderContent = selected ? Newtonsoft.Json.JsonConvert.DeserializeObject(shipping.GetString("Ecom:ShippingProvider.Content")) : null; 726 string isChecked = "checked"; //selected ? "checked" : ""; 727 string hideLabel = haveShippingContent ? "" : "u-hidden"; 728 string leftMargin = haveShippingContent ? "u-margin-left" : ""; 729 730 <div class="form__field-group dw-mod"> 731 <input onchange="Cart.SubmitCart()" type="radio" class="form__control" name="EcomCartShippingmethodID" id="EcomCartShippingmethodID_@shipping.GetString("Ecom:Cart.Shippingmethod.ID")" value="@shipping.GetString("Ecom:Cart.Shippingmethod.ID")" @isChecked /> 732 @*<label for="EcomCartShippingmethodID_@shipping.GetString("Ecom:Cart.Shippingmethod.ID")" class="@hideLabel"> 733 @shipping.GetString("Ecom:Cart.Shippingmethod.Name") 734 </label>*@ 735 <p>@Translate("Shipping free if you buy for more than 100EURO")</p> 736 </div> 737 738 if (shippingProviderContent != null) 739 { 740 showShippingsBlock = true; 741 742 <div id="ShippingProviderContent" class="@leftMargin" data-template="ShippingProviderContentTemplate"></div> 743 <script> 744 document.addEventListener("DOMContentLoaded", function (event) { 745 HandlebarsBolt.CreateItemsFromJson(@shippingProviderContent, "ShippingProviderContent", "ShippingProviderContentTemplate"); 746 HandlebarsBolt.CreateItemsFromJson(@shippingProviderContent, "ParcelShops", "ParcelShopsTemplate"); 747 }); 748 749 var data = @shippingProviderContent; 750 751 if (document.getElementById("DeliveryAddressFields")) { 752 document.getElementById("DeliveryAddressFields").addEventListener("contentLoaded", setParcelShopToDeliveryFields); 753 } else { 754 setParcelShopToDeliveryFields(); 755 } 756 757 function setParcelShopToDeliveryFields() { 758 759 var deliveryAddress = document.getElementById("EcomOrderDeliveryAddress").value; 760 761 if (data != "") { 762 if (deliveryAddress == "") { 763 document.getElementById("AlternateAddressBlock").checked = true; 764 765 document.getElementById("EcomOrderDeliveryCompany").value = data[0].ParcelShops[0].company; 766 document.getElementById("EcomOrderDeliveryName").value = data[0].ParcelShops[0].company; 767 document.getElementById("EcomOrderDeliveryPhone").value = ""; 768 document.getElementById("EcomOrderDeliveryEmail").value = ""; 769 document.getElementById("EcomOrderDeliveryAddress").value = data[0].ParcelShops[0].address; 770 document.getElementById("EcomOrderDeliveryZip").value = data[0].ParcelShops[0].zip; 771 document.getElementById("EcomOrderDeliveryCity").value = data[0].ParcelShops[0].city; 772 document.getElementById("Country").setAttribute("data-countrycode", data[0].ParcelShops[0].countryCode); 773 } 774 } 775 776 document.getElementById("DeliveryAddressFields").removeEventListener("contentLoaded", setParcelShopToDeliveryFields); 777 } 778 </script> 779 } 780 781 if (shipping.GetString("Ecom:ShippingProvider.Content") != "" && @shipping.GetString("Ecom:ShippingProvider.Content").Length < 10) 782 { 783 <button class="btn btn--secondary btn--full u-no-margin u-margin-bottom dw-mod" onclick="Cart.SubmitCart()">@Translate("Get parcel shops")</button> 784 <small class="help-text dw-mod">@Translate("Requires an address for either billing og shipping")</small> 785 } 786 } 787 @if (!showShippingsBlock) 788 { 789 <script> 790 document.getElementById("shippingsBlock").classList.add("u-hidden"); 791 </script> 792 } 793 </div> 794 } 795 796 @helper RenderParcelShopsModal() { 797 string parcelShopModalHeader = Pageview.Device.ToString() != "Mobile" ? Translate("Choose a parcel shop") : Translate("Choose"); 798 799 <!-- Trigger for the pacel shops modal --> 800 <input type="checkbox" id="ParcelShopsModalTrigger" class="modal-trigger" /> 801 802 <!-- Map modal --> 803 <div class="modal-container"> 804 <label for="ParcelShopsModalTrigger" id="ParcelShopsModalOverlay" class="modal-overlay"></label> 805 <div class="modal modal--lg" id="ParcelShopsModal"> 806 <div class="modal__header"> 807 <h2>@parcelShopModalHeader</h2> 808 </div> 809 <div class="modal__body"> 810 <div class="grid"> 811 <div class="grid__col-auto"> 812 <ul class="list list--clean list--scroll dw-mod" id="ParcelShops" data-template="ParcelShopsTemplate"></ul> 813 </div> 814 @if (Pageview.Device.ToString() != "Mobile") 815 { 816 <div class="grid__col-8"> 817 <div class="map-container"> 818 <div id="MapCanvas" class="map-container__canvas"></div> 819 </div> 820 </div> 821 } 822 </div> 823 </div> 824 </div> 825 </div> 826 } 827 828 829 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 830 @using Dynamicweb.Core 831 @using System 832 @using System.Web 833 @using System.Collections.Generic 834 @using Dynamicweb.Rapido.Blocks 835 836 @{ 837 BlocksPage voucherCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 838 839 if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideVoucher")) 840 { 841 Block voucherBlock = new Block() 842 { 843 Id = "Voucher", 844 SortId = 30, 845 Template = RenderVoucher(), 846 Design = new Design 847 { 848 RenderType = RenderType.Column, 849 Size = "auto" 850 } 851 }; 852 voucherCheckoutPage.Add("OrderContainerRow", voucherBlock); 853 } 854 } 855 856 @helper RenderVoucher() { 857 string cardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 858 859 <div class="card-header u-color-light--bg dw-mod"> 860 <h3><i class="fas fa-gift"></i> @Translate("Voucher")</h3> 861 </div> 862 863 <div class="card u-color-light--bg @cardHeightClass dw-mod"> 864 <div class="form__field-combi"> 865 <input type="text" class="u-full-width" placeholder="@Translate("Enter voucher code")" name="EcomOrderVoucherCode" id="EcomOrderVoucherCode" onkeyup="checkEmpty();" value="@GetString("Ecom:Order.Customer.VoucherCode")" /> 866 <button type="submit" class="btn btn--primary dw-mod btn--condensed u-no-margin" id="EcomOrderVoucherApply" disabled>@Translate("Apply")</button> 867 </div> 868 <script> 869 function checkEmpty() { 870 document.getElementById("EcomOrderVoucherApply").disabled = document.getElementById("EcomOrderVoucherCode").value.trim() == ""; 871 } 872 873 checkEmpty(); 874 </script> 875 @{ 876 var errors = new List<string>(); 877 string voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); 878 if (!string.IsNullOrWhiteSpace(voucherCode)) 879 { 880 Order order = new OrderService().GetOrder(GetString("Ecom:Order.ID")); 881 882 IEnumerable<string> codes = new List<string>(); 883 884 if (order.VoucherUseType.HasFlag(VoucherUseCategoryType.Discount)) 885 { 886 codes = voucherCode.Split(new string[] { ",", ";", " " }, StringSplitOptions.RemoveEmptyEntries); 887 } 888 else 889 { 890 codes = new string[] { voucherCode.Trim() }; 891 } 892 893 foreach (string code in codes) 894 { 895 Voucher vouch = Voucher.GetVoucherByCode(code); 896 if (vouch == null) 897 { 898 errors.Add(Translate("Voucher") + " <span class=u-bold>" + code + "</span> " + Translate("not found")); 899 continue; 900 } 901 if (vouch.DateUsed.HasValue) 902 { 903 errors.Add(Translate("Voucher") + " <span class=u-bold>" + code + "</span> " + Translate("already used")); 904 continue; 905 } 906 VoucherList voucherList = VoucherList.GetListById(vouch.ListId); 907 if (!voucherList.ListActive) 908 { 909 errors.Add(Translate("Voucher") + " <span class=u-bold>" + code + "</span> " + Translate("is not active")); 910 continue; 911 } 912 <div class="field-success u-margin-bottom dw-mod">@Translate("Voucher") <span class="u-bold">@code</span> @Translate("applied to order")</div> 913 } 914 915 foreach (string error in errors) 916 { 917 <div class="field-error u-margin-bottom dw-mod">@error</div> 918 } 919 } 920 } 921 </div> 922 } 923 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 924 @using Dynamicweb.Core 925 @using System 926 @using System.Web 927 @using System.Collections.Generic 928 @using Dynamicweb.Rapido.Blocks 929 930 @{ 931 BlocksPage recurringCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 932 933 if (!string.IsNullOrWhiteSpace(GetString("Ecom:Order.PaymentMethod.RecurringSupport")) && !Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideRecurringOrder")) 934 { 935 Block recurringOrderBlock = new Block() 936 { 937 Id = "RecurringOrder", 938 SortId = 40, 939 Template = RenderRecurringOrder(), 940 Design = new Design 941 { 942 RenderType = RenderType.Column, 943 Size = "12" 944 } 945 }; 946 recurringCheckoutPage.Add("OrderContainerRow", recurringOrderBlock); 947 } 948 } 949 950 @helper RenderRecurringOrder() { 951 string cardHeightClass = Pageview.Device.ToString() != "Tablet" ? "u-full-height" : ""; 952 string dateFormat = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern; 953 954 <div class="card-header u-color-light--bg dw-mod"> 955 <h3><i class="fas fa-calendar"></i> @Translate("Recurring order")</h3> 956 </div> 957 958 <div class="card u-color-light--bg @cardHeightClass dw-mod"> 959 <div class="form__field-group u-margin-bottom"> 960 <input type="checkbox" class="js-remember-state form__control" checked="@GetBoolean("Ecom:Order.Recurring.Enabled")" name="EcomRecurringOrderCreate" data-expand="EcomRecurringOrderCreate" id="EcomRecurringOrderCreate"> 961 <label for="EcomRecurringOrderCreate">@Translate("Create recurring order")</label> 962 </div> 963 <div class="expandable--collapsed" data-trigger="EcomRecurringOrderCreate"> 964 <div class="form__field-group dw-mod"> 965 <label for="Country">@Translate("I want my order every")</label> 966 <div class="grid grid--external-bleed-x"> 967 <div class="grid__col-6 grid__col--bleed-y"> 968 <select class="u-full-width" name="EcomOrderRecurringInterval" id="EcomOrderRecurringInterval"> 969 @*interval*@ 970 @for (var i = 1; i <= 12; i++) 971 { 972 <option value="@i" @(GetInteger("Ecom:Order.Recurring.Interval") == i ? "selected" : "")> @i</option> 973 } 974 </select> 975 </div> 976 <div class="grid__col-6 grid__col--bleed-y"> 977 <select class="u-full-width" name="EcomOrderRecurringIntervalUnit" id="EcomOrderRecurringIntervalUnit"> 978 @{ var units = new[] { "Days", "Weeks", "Months" }; } 979 @for (int i = 0; i < units.Length; i++) 980 { 981 <option value="@i" @(GetInteger("Ecom:Order.Recurring.IntervalUnit") == i ? "selected" : "")>@Translate(units[i])</option> 982 } 983 </select> 984 </div> 985 </div> 986 </div> 987 <div class="grid grid--external-bleed-x"> 988 <div class="grid__col-6 grid__col--bleed-y"> 989 <div class="form__field-group dw-mod"> 990 <label for="EcomOrderRecurringStartDate">@Translate("Start date")</label> 991 @{string startDate = !string.IsNullOrEmpty(GetString("Ecom:Order.Recurring.StartDate.Clean")) ? GetDate("Ecom:Order.Recurring.StartDate.Clean").ToString(dateFormat) : "";} 992 <input type="text" class="u-full-width" id="EcomOrderRecurringStartDate" name="EcomOrderRecurringStartDate" placeholder="@Translate("Never")" value="@startDate" /> 993 </div> 994 </div> 995 <div class="grid__col-6 grid__col--bleed-y"> 996 <div class="form__field-group dw-mod"> 997 <label for="EcomOrderRecurringEndDate">@Translate("And it should end on")</label> 998 @{string endDate = !string.IsNullOrEmpty(GetString("Ecom:Order.Recurring.EndDate.Clean")) ? GetDate("Ecom:Order.Recurring.EndDate.Clean").ToString(dateFormat) : "";} 999 <input type="text" class="u-full-width" id="EcomOrderRecurringEndDate" name="EcomOrderRecurringEndDate" placeholder="@Translate("Never")" value="@endDate"> 1000 </div> 1001 </div> 1002 </div> 1003 </div> 1004 </div> 1005 1006 //* *// 1007 <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/flatpickr/dist/flatpickr.min.css"> 1008 <style> 1009 .flatpickr-months .flatpickr-month { 1010 height: 40px; 1011 } 1012 </style> 1013 <script src="https://cdn.jsdelivr.net/npm/flatpickr"></script> 1014 <script> 1015 @{ 1016 dateFormat = dateFormat.Replace("dd", "d"); 1017 dateFormat = dateFormat.Replace("MM", "m"); 1018 dateFormat = dateFormat.Replace("yyyy", "Y"); 1019 } 1020 1021 flatpickr("#EcomOrderRecurringStartDate, #EcomOrderRecurringEndDate", { 1022 dateFormat: "@dateFormat", 1023 minDate: "today" 1024 }); 1025 </script> 1026 } 1027 1028 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 1029 @using Dynamicweb 1030 @using Dynamicweb.Core 1031 @using System 1032 @using System.Web 1033 @using System.Collections.Generic 1034 @using Dynamicweb.Rapido.Blocks 1035 1036 @functions{ 1037 BlocksPage reviewOrderCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 1038 int cartOrderlinesFeedPageId; 1039 string pageId; 1040 } 1041 1042 @{ 1043 string reviewOrderType = checkoutPageType != null ? checkoutPageType : "onestep"; //The "checkoutPageType" comes from the main template for the cart page 1044 pageId = GetGlobalValue("Global:Page.ID"); 1045 cartOrderlinesFeedPageId = GetPageIdByNavigationTag("CartOrderlinesFeed"); 1046 1047 Block reviewOrderBlock = new Block() 1048 { 1049 Id = "ReviewOrder", 1050 SortId = 50, 1051 Template = RenderReviewOrder(), 1052 SkipRenderBlocksList = true 1053 }; 1054 reviewOrderCheckoutPage.Add("OrderContainerRow", reviewOrderBlock); 1055 1056 if (reviewOrderType == "onestep") 1057 { 1058 Block inlineAcceptanceBlock = new Block() 1059 { 1060 Id = "Acceptance", 1061 SortId = 10, 1062 Template = RenderInlineAcceptance() 1063 }; 1064 reviewOrderCheckoutPage.Add("ReviewOrder", inlineAcceptanceBlock); 1065 1066 Block reviewOrderFooterBlock = new Block() 1067 { 1068 Id = "ReviewOrderFooter", 1069 SortId = 20, 1070 Template = RenderReviewOrderFooter() 1071 }; 1072 reviewOrderCheckoutPage.Add("ReviewOrder", reviewOrderFooterBlock); 1073 } 1074 1075 if (reviewOrderType == "quote") 1076 { 1077 Block reviewOrderFooterBlock = new Block() 1078 { 1079 Id = "ReviewOrderFooter", 1080 SortId = 20, 1081 Template = RenderReviewOrderFooterQuote() 1082 }; 1083 reviewOrderCheckoutPage.Add("ReviewOrder", reviewOrderFooterBlock); 1084 } 1085 1086 Block reviewOrderScriptTemplates = new Block() 1087 { 1088 Id = "ReviewOrderScriptTempaltes", 1089 SortId = 30, 1090 Template = RenderReviewOrderScriptTemplates() 1091 }; 1092 reviewOrderCheckoutPage.Add("CheckoutBottomSnippets", reviewOrderScriptTemplates); 1093 1094 Block reviewOrderScripts = new Block() 1095 { 1096 Id = "ReviewOrderScripts", 1097 SortId = 40, 1098 Template = RenderOrderScripts() 1099 }; 1100 reviewOrderCheckoutPage.Add("CheckoutBottomSnippets", reviewOrderScripts); 1101 } 1102 1103 @helper RenderReviewOrder() { 1104 cartOrderlinesFeedPageId = GetPageIdByNavigationTag("CartOrderlinesFeed"); 1105 1106 <div class="grid__col-12"> 1107 <div class="js-handlebars-root" id="Cart" data-template="CartContent" data-cart-id="@cartOrderlinesFeedPageId" data-json-feed="/Default.aspx?ID=@cartOrderlinesFeedPageId" data-preloader="overlay"></div> 1108 </div> 1109 } 1110 1111 @helper RenderReviewOrderScriptTemplates() { 1112 List<Block> subBlocks = reviewOrderCheckoutPage.GetBlockListById("ReviewOrder").OrderBy(item => item.SortId).ToList(); 1113 1114 bool pointShop = !String.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Ecommerce").GetString("PointShopOnly")) ? Pageview.AreaSettings.GetItem("Ecommerce").GetBoolean("PointShopOnly") : false; 1115 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 1116 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 1117 1118 @* Template for when the cart is empty *@ 1119 <script id="EmptyCart" type="text/x-template"> 1120 @Translate("You have no items in the cart") 1121 </script> 1122 1123 @* Template for the cart *@ 1124 <script id="CartContent" type="text/x-template"> 1125 {{#.}} 1126 @if (useGoogleTagManager) 1127 { 1128 <text>{{{googleEnchantImpressionEmptyCart OrderLines}}}</text> 1129 } 1130 <div class="card-header u-color-light--bg dw-mod"> 1131 <h3> @Translate("Review order") ({{numberofproducts}})</h3> 1132 </div> 1133 <div class="card u-color-light--bg u-no-padding--xs dw-mod"> 1134 <div class="{{isempty}}"> 1135 <table class="table cart-table dw-mod"> 1136 <tbody id="OrderLines"> 1137 {{#OrderLines}} 1138 {{#ifCond template "===" "CartOrderline"}} 1139 {{>CartOrderline}} 1140 {{/ifCond}} 1141 {{#ifCond template "===" "CartOrderlineMobile"}} 1142 {{>CartOrderlineMobile}} 1143 {{/ifCond}} 1144 {{#ifCond template "===" "CartOrderlineDiscount"}} 1145 {{>CartOrderlineDiscount}} 1146 {{/ifCond}} 1147 {{/OrderLines}} 1148 </tbody> 1149 </table> 1150 </div> 1151 <div class="grid u-border-top"> 1152 <div class="grid__col-sm-6"> 1153 @if (Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints") && !string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.UserName"))) 1154 { 1155 <text> 1156 {{#if userPoints}} 1157 <div class="u-border u-border-color--loyalty-points u-padding--lg u-full-height"> 1158 <h3 class="u-no-margin">@Translate("Your point balance")</h3> 1159 <div class="u-font-size--lg u-margin-bottom"> 1160 <span class="u-color--loyalty-points">{{userPoints}}</span> @Translate("points") 1161 </div> 1162 <div>@Translate("On this order you will use"): <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points")</div> 1163 </div> 1164 {{/if}} 1165 </text> 1166 } 1167 </div> 1168 1169 <div class="grid__col-sm-6"> 1170 @if (!pointShop) 1171 { 1172 <div class="{{hideSubTotal}}"> 1173 <div class="cart-summary__subtotals dw-mod">@Translate("Subtotal")</div> 1174 <div class="cart-summary__subtotals u-pull--right dw-mod">{{subtotalprice}}</div> 1175 </div> 1176 <div class="{{hidePaymentfee}}"> 1177 <div class="cart-summary__info dw-mod"><i class="fas fa-credit-card"></i> {{paymentmethod}}</div> 1178 <div class="cart-summary__info u-pull--right dw-mod">{{paymentfee}}</div> 1179 </div> 1180 } 1181 <div class="{{hideShippingfee}}"> 1182 <div class="cart-summary__info dw-mod"><i class="fas fa-truck"></i> {{shippingmethod}}</div> 1183 <div class="cart-summary__info u-pull--right dw-mod">{{shippingfee}}</div> 1184 </div> 1185 @if (!pointShop) 1186 { 1187 <div> 1188 <div class="cart-summary__info dw-mod">@Translate("VAT")</div> 1189 <div class="cart-summary__info u-pull--right dw-mod">{{totalvat}}</div> 1190 </div> 1191 } 1192 @if (Pageview.User != null && Dynamicweb.Security.Licensing.LicenseManager.LicenseHasFeature("LoyaltyPoints")) 1193 { 1194 <text> 1195 {{#if earnings}} 1196 <div> 1197 <div class="cart-summary__info dw-mod">@Translate("Earnings")</div> 1198 <div class="cart-summary__info u-pull--right dw-mod"><span class="u-color--loyalty-points">{{earnings}}</span> @Translate("points")</div> 1199 </div> 1200 {{/if}} 1201 </text> 1202 } 1203 <div class="cart-summary__totals-container dw-mod"> 1204 <div class="cart-summary__totals dw-mod">@Translate("Total")</div> 1205 <div class="cart-summary__totals u-pull--right dw-mod"> 1206 @if (pointShop) 1207 { 1208 <span class="u-color--loyalty-points">{{pointsUsedInCart}}</span> @Translate("points") 1209 } 1210 else 1211 { 1212 <text>{{totalprice}}</text> 1213 } 1214 </div> 1215 </div> 1216 </div> 1217 </div> 1218 1219 <div class="grid"> 1220 <div class="grid__col-12 grid__col--line-top"></div> 1221 </div> 1222 1223 <div class="grid__cell u-padding--xs {{hideComment}}"> 1224 <textarea rows="3" class="u-full-width" placeholder="@Translate("Enter comment")" name="EcomOrderCustomerComment" id="EcomOrderCustomerComment">{{comment}}</textarea> 1225 </div> 1226 1227 @foreach (LoopItem error in GetLoop("ValidationErrors")) 1228 { 1229 <div class="error-block">@error.GetString("Ecom:Cart.ValidationError.ErrorMessage")</div> 1230 } 1231 1232 @RenderBlockList(subBlocks) 1233 </div> 1234 {{/.}} 1235 </script> 1236 1237 @* Template for the orderlines *@ 1238 <script id="CartOrderline" type="text/x-template"> 1239 <tr id="Orderline{{id}}" class="cart-orderline {{isempty}}"> 1240 <td class="cart-orderline__cell cart-table__image u-hidden-xs u-hidden-xxs dw-mod"><div class="cart-orderline__cell__block {{hideimage}} dw-mod"><img src="/Admin/Public/GetImage.ashx?width=60&height=60&crop=5&Compression=75&image={{image}}" alt="{{name}} {{variantname}}"></div></td> 1241 <td class="cart-orderline__cell dw-mod" title="{{name}} {{variantname}}"> 1242 <a href="{{link}}" class="u-color-inherit cart-orderline__name">{{name}}</a> 1243 <div class="cart-orderline__cell__block item-number dw-mod">#{{productnumber}}</div> 1244 {{#if variantname}} 1245 <div class="cart-orderline__cell__block item-number dw-mod">{{variantname}}</div> 1246 {{/if}} 1247 {{#if unitname}} 1248 <div class="cart-orderline__cell__block item-number dw-mod">{{unitname}}</div> 1249 {{/if}} 1250 </td> 1251 <td class="cart-orderline__cell u-ta-right u-hidden-xs u-hidden-xxs dw-mod" width="120"> 1252 {{#if pointsTotal}} 1253 <span class="u-color--loyalty-points">{{pointPrice}}</span> @Translate("points") 1254 {{else}} 1255 {{unitprice}} 1256 {{/if}} 1257 </td> 1258 1259 @if (!Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote) 1260 { 1261 <td class="cart-orderline__cell u-ta-right dw-mod" width="80"><input class="u-w80px u-no-margin" id="Quantity_{{orderLineId}}" type="number" min="1" onchange="Cart.ChangeQuantity('@cartOrderlinesFeedPageId', '{{orderLineId}}', this.value)" name='QuantityOrderLine{{orderLineId}}' value="{{quantity}}"></td> 1262 <td class="cart-orderline__cell u-ta-left dw-mod" width="50"><button type="button" class="btn btn--clean btn--condensed u-no-margin" onclick="{{removeFromCartGoogleImpression}}; Cart.UpdateCart('Cart', '/Default.aspx?ID=@cartOrderlinesFeedPageId', '&CartCmd=DelOrderLine&key={{orderLineId}}', true);"><i class="fas fa-times"></i></button></td> 1263 } 1264 else 1265 { 1266 <td class="cart-orderline__cell u-ta-right dw-mod" width="80"> 1267 <input id="Quantity_{{orderLineId}}" type="hidden" name='QuantityOrderLine{{orderLineId}}' value="{{quantity}}"> 1268 <div class="u-w80px u-no-margin">{{quantity}}</div> 1269 </td> 1270 } 1271 1272 <td class="cart-orderline__cell u-ta-right dw-mod"> 1273 {{#if pointsTotal}} 1274 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 1275 {{else}} 1276 <div>{{totalprice}}</div> 1277 {{/if}} 1278 {{#if canBePurchasedWithPoints}} 1279 <button type="button" onclick="Cart.BuyForPoints('@pageId', '@cartOrderlinesFeedPageId', '{{orderLineId}}', '{{id}}', '{{variantId}}');" class="btn btn--loyalty-points dw-mod btn--sm u-no-margin" title="@Translate("Use") {{pointPrice}} @Translate("points")"><i class="far fa-tag"></i> @Translate("Use") {{pointPrice}} @Translate("points")</button> 1280 {{/if}} 1281 </td> 1282 </tr> 1283 <tr class="{{hideBomItems}}"> 1284 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"><div class="{{hideimage}}"></div></td> 1285 <td colspan="5" class="u-no-padding"> 1286 <table class="u-no-margin u-color-light-gray--bg"> 1287 <tbody> 1288 {{#BomItems}} 1289 <tr> 1290 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"><img src="/Admin/Public/GetImage.ashx?width=60&height=60&crop=5&Compression=75&image={{image}}" alt="{{name}} {{variantname}}"></td> 1291 <td title="{{name}} {{variantname}}"> 1292 <a href="{{link}}" class="u-color-inherit dw-mod">{{name}}</a> 1293 <div class="item-number dw-mod">#{{productnumber}}</div> 1294 {{#if variantname}} 1295 <div class="item-number dw-mod">{{variantname}}</div> 1296 {{/if}} 1297 {{#if unitname}} 1298 <div class="item-number dw-mod">{{unitname}}</div> 1299 {{/if}} 1300 </td> 1301 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 1302 <td>{{quantity}}</td> 1303 <td>&nbsp;</td> 1304 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 1305 </tr> 1306 {{/BomItems}} 1307 </tbody> 1308 </table> 1309 </td> 1310 </tr> 1311 </script> 1312 1313 <script id="CartOrderlineMobile" type="text/x-template"> 1314 <tr id="Orderline{{id}}" class="{{isempty}}"> 1315 <td class="cart-table__image dw-mod"><div class="{{hideimage}}"><img src="/Admin/Public/GetImage.ashx?width=60&height=60&crop=5&Compression=75&image={{image}}" alt="{{name}} {{variantname}}"></div></td> 1316 <td title="{{name}} {{variantname}}" colspan="4"> 1317 <a href="{{link}}" class="u-color-inherit">{{name}}</a> 1318 <div>#{{productnumber}}</div> 1319 {{#if variantname}} 1320 <div>{{variantname}}</div> 1321 {{/if}} 1322 {{#if unitname}} 1323 <div>{{unitname}}</div> 1324 {{/if}} 1325 </td> 1326 </tr> 1327 <tr class="{{isempty}} table__row--no-border"> 1328 <td class="cart-table__image dw-mod"></td> 1329 <td colspan="4"> 1330 <div class="u-pull--left"> 1331 <input class="u-w80px u-no-margin" id="Quantity_{{orderLineId}}" type="number" min="1" onchange="Cart.ChangeQuantity('@cartOrderlinesFeedPageId', '{{orderLineId}}', this.value)" name='QuantityOrderLine{{orderLineId}}' value="{{quantity}}"> 1332 <span><button type="button" class="btn btn--clean btn--condensed u-no-margin" onclick="{{removeFromCartGoogleImpression}}; Cart.UpdateCart('Cart', '/Default.aspx?ID=@cartOrderlinesFeedPageId', '&CartCmd=DelOrderLine&key={{orderLineId}}', true);"><i class="fas fa-times"></i></button></span> 1333 </div> 1334 <div class="u-pull--right u-ta-right"> 1335 {{#if pointsTotal}} 1336 <span class="u-color--loyalty-points">{{pointsTotal}}</span> @Translate("points") 1337 {{else}} 1338 <div>{{totalprice}}</div> 1339 {{/if}} 1340 {{#if canBePurchasedWithPoints}} 1341 <button type="button" onclick="Cart.BuyForPoints('@pageId', '@cartOrderlinesFeedPageId', '{{orderLineId}}', '{{id}}', '{{variantId}}');" class="btn btn--loyalty-points dw-mod btn--sm u-no-margin" name="CartCmd" value="addWithPoints" title="@Translate("Use") {{pointPrice}} @Translate("points")"><i class="far fa-tag"></i> @Translate("Use") {{pointPrice}} @Translate("points")</button> 1342 {{/if}} 1343 </div> 1344 </td> 1345 </tr> 1346 <tr class="{{hideBomItems}}"> 1347 <td colspan="6" class="u-no-padding"> 1348 <table class="u-no-margin u-color-light-gray--bg"> 1349 <tbody> 1350 {{#BomItems}} 1351 <tr> 1352 <td class="cart-table__image u-hidden-xs u-hidden-xxs dw-mod"><img src="/Admin/Public/GetImage.ashx?width=120&height=120&crop=5&Compression=75&image={{image}}" alt="{{name}} {{variantname}}"></td> 1353 <td title="{{name}} {{variantname}}"> 1354 <a href="{{link}}" class="mini-cart-orderlines__name dw-mod">{{name}}</a> 1355 <div>#{{productnumber}}</div> 1356 {{#if variantname}} 1357 <div>{{variantname}}</div> 1358 {{/if}} 1359 {{#if unitname}} 1360 <div>{{unitname}}</div> 1361 {{/if}} 1362 </td> 1363 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 1364 <td>{{quantity}}</td> 1365 <td>&nbsp;</td> 1366 <td class="cart-table__price u-ta-right dw-mod">&nbsp;</td> 1367 </tr> 1368 {{/BomItems}} 1369 </tbody> 1370 </table> 1371 </td> 1372 </tr> 1373 </script> 1374 1375 <script id="CartOrderlineDiscount" type="text/x-template"> 1376 <tr class="table__row--no-border"> 1377 <td class="cart-table__image dw-mod">&nbsp;</td> 1378 <td colspan="3">{{name}}</td> 1379 <td class="u-hidden-xs u-hidden-xxs">&nbsp;</td> 1380 <td class="cart-table__price u-ta-right dw-mod">{{totalprice}}</td> 1381 </tr> 1382 </script> 1383 } 1384 1385 @helper RenderInlineAcceptance() { 1386 <div class="grid__cell u-padding--xs"> 1387 @if (GetBoolean("Ecom:Cart.UseNewsletterSubscription")) 1388 { 1389 <div class="form__field-group u-margin-bottom dw-mod"> 1390 <input type="hidden" name="EcomOrderSubscribeToNewsletter" /> 1391 <input type="checkbox" name="EcomOrderSubscribeToNewsletter" id="EcomOrderSubscribeToNewsletter" class="form__control"> 1392 <label for="EcomOrderSubscribeToNewsletter"> 1393 @Translate("Subscribe to newsletter") 1394 </label> 1395 </div> 1396 } 1397 <div class="form__field-group dw-mod"> 1398 <input type="checkbox" name="EcomOrderCustomerAccepted" id="EcomOrderCustomerAccepted" onchange="Cart.EnableCheckoutButton()" class="form__control"> 1399 <label for="EcomOrderCustomerAccepted"> 1400 @Translate("I accept the terms and conditions")&nbsp;<a href='@Translate("ConditionsLink","/Default.aspx?ID=585")' target="_blank">@Translate("Readmore", "Read more")</a> 1401 </label> 1402 </div> 1403 <div class="field-error dw-mod">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerAccepted.ErrorMessage")</div> 1404 </div> 1405 } 1406 1407 @helper RenderReviewOrderFooter() { 1408 int quotesCartPageId = GetPageIdByNavigationTag("QuotesCartPage"); 1409 1410 <div class="grid"> 1411 <div class="grid__col-12 grid__col--line-top"></div> 1412 </div> 1413 1414 <div class="grid__cell-footer"> 1415 <div class="grid__cell u-padding--xs"> 1416 <div class="u-pull--right"> 1417 <button type="submit" class="btn btn--primary btn--condensed dw-mod u-pull--right u-no-margin disabled" name="@GetString("CartV2.NextStepButtonName")" id="@GetString("CartV2.NextStepButtonName")" disabled>@Translate("Go to checkout")</button> 1418 </div> 1419 <div class="u-pull--left"> 1420 <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> 1421 </div> 1422 @if (!Pageview.AreaSettings.GetItem("Ecommerce").GetItem("Checkout").GetBoolean("HideQuotesCartLink")) 1423 { 1424 <div class="u-pull--right"> 1425 <a href="/Default.aspx?ID=@quotesCartPageId" class="btn btn--link btn--condensed dw-mod u-no-margin u-margin-right--lg u-no-margin--xs">@Translate("Create quote request")</a> 1426 </div> 1427 } 1428 </div> 1429 </div> 1430 } 1431 1432 @helper RenderReviewOrderFooterQuote() { 1433 <div class="grid"> 1434 <div class="grid__col-12 grid__col--line-top"></div> 1435 </div> 1436 1437 <div class="grid__cell-footer"> 1438 <div class="grid__cell u-padding--xs"> 1439 <div class="u-pull--right"> 1440 <button type="submit" class="btn btn--primary btn--condensed dw-mod u-pull--right u-no-margin" name="@GetString("CartV2.NextStepButtonName")" id="@GetString("CartV2.NextStepButtonName")">@Translate("Submit quote request")</button> 1441 </div> 1442 <div class="u-pull--left"> 1443 <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> 1444 </div> 1445 </div> 1446 </div> 1447 } 1448 1449 @helper RenderOrderScripts() { 1450 if (!string.IsNullOrWhiteSpace(Pageview.AreaSettings.GetItem("Settings").GetString("FacebookPixelID"))) 1451 { 1452 <script> 1453 fbq('track', 'InitiateCheckout', { 1454 currency: '@GetString("Ecom:Order.Price.Currency.Code")', 1455 value: @GetDouble("Ecom:Order.Price.Price"), 1456 num_items: "@GetInteger("Ecom:Order.OrderLines.TotalProductQuantity")" 1457 }); 1458 </script> 1459 } 1460 } 1461 1462 1463 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 1464 @using Dynamicweb.Core 1465 @using System 1466 @using System.Web 1467 @using System.Collections.Generic 1468 @using Dynamicweb.Rapido.Blocks 1469 1470 @{ 1471 bool useGoogleTagManager = !string.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleTagManagerID")); 1472 1473 BlocksPage googleImpressionsPage = BlocksPage.GetBlockPage("CheckoutPage"); 1474 1475 Block googleImpressionsBlock = new Block() 1476 { 1477 Id = "GoogleImpressionsBlock", 1478 SortId = 10, 1479 Template = RenderScript() 1480 }; 1481 1482 if (useGoogleTagManager) 1483 { 1484 googleImpressionsPage.Add("CheckoutBottomSnippets", googleImpressionsBlock); 1485 } 1486 } 1487 1488 @helper RenderScript() { 1489 <script> 1490 /** 1491 * A function to handle a click on a checkout button. This function uses the eventCallback 1492 * data layer variable to handle navigation after the ecommerce data has been sent to Google Analytics. 1493 */ 1494 dataLayer.push({ 1495 'event': 'checkout', 1496 'ecommerce': { 1497 'checkout': { 1498 'actionField': {'step': 1}, 1499 'products': [ 1500 @foreach (LoopItem orderline in GetLoop("OrderLines")) 1501 { 1502 var groupObject = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(orderline.GetString("Ecom:Product.PrimaryOrFirstGroupID")); 1503 <text> 1504 { 1505 'name': "@orderline.GetString("Ecom:Order:OrderLine.ProductName")", 1506 'id': "@orderline.GetString("Ecom:Product.ID")", 1507 'price': "@orderline.GetDouble("Ecom:Order:OrderLine.UnitPrice.Price")", 1508 'brand': "@orderline.GetString("Ecom:Product:Field.brand.Value")", 1509 'category': "@(groupObject != null ? groupObject.Name : "")", 1510 'variant': "@orderline.GetString("Ecom:Order:OrderLine.ProductVariantID")", 1511 'quantity': @orderline.GetInteger("Ecom:Order:OrderLine.Quantity") 1512 }, 1513 </text> 1514 } 1515 ] 1516 } 1517 }, 1518 'eventCallback': function() { 1519 document.location = 'checkout.html'; 1520 } 1521 }); 1522 </script> 1523 } 1524 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 1525 @using Dynamicweb.Core 1526 @using System 1527 @using System.Web 1528 @using System.Collections.Generic 1529 @using Dynamicweb.Rapido.Blocks 1530 1531 @{ 1532 BlocksPage snippetsCheckoutPage = BlocksPage.GetBlockPage("CheckoutPage"); 1533 1534 Block parcelShopsScriptTemplates = new Block() 1535 { 1536 Id = "ShippingProviderTemplates", 1537 SortId = 10, 1538 Template = RenderShippingProviderTemplates() 1539 }; 1540 snippetsCheckoutPage.Add("CheckoutBottomSnippets", parcelShopsScriptTemplates); 1541 } 1542 1543 @helper RenderShippingProviderTemplates() { 1544 <script id="ShippingProviderContentTemplate" type="text/x-template"> 1545 {{#.}} 1546 <div class="{{hideShippingProvider}}"> 1547 <ul class="list list--clean parcel-shop-address dw-mod" id="SelectedParcelShop"> 1548 {{#SelectedParcelShop}} 1549 <li data-number="{{number}}" data-lat="{{latitude}}" data-lng="{{longitude}}"> 1550 <div class="u-hidden"> 1551 <input type="radio" class="u-no-margin" name="{{fieldPrefix}}{{fieldPostfix}}" value="{{number}}" {{selected}} /> 1552 </div> 1553 <div> 1554 <i class="fas fa-map-marker"></i> 1555 <span class="u-bold">{{company}}, </span> 1556 <span>{{address}} </span> 1557 <span>{{city}} </span> 1558 <span>{{countryCode}} </span> 1559 </div> 1560 </li> 1561 {{/SelectedParcelShop}} 1562 {{^SelectedParcelShop}} 1563 <li>@Translate("No points found")</li> 1564 {{/SelectedParcelShop}} 1565 </ul> 1566 <div class="{{hideShippingProvider}}"> 1567 <label for="ParcelShopsModalTrigger" class="btn btn--secondary btn--full dw-mod" onclick="Maps.Init('MapCanvas', {{toJSON ParcelShops}}, Cart.SelectParcelShop, Cart.SubmitCart, '@Translate("Select")')">@Translate("Change parcel shop")</label> 1568 </div> 1569 </div> 1570 {{/.}} 1571 </script> 1572 1573 <script id="ParcelShopsTemplate" type="text/x-template"> 1574 {{#.}} 1575 {{#ParcelShops}} 1576 <li data-number="{{number}}" data-lat="{{latitude}}" data-lng="{{longitude}}"> 1577 <input type="radio" name="{{fieldPrefix}}{{fieldPostfix}}" value="{{number}}" class="form__control" id="{{fieldPrefix}}ParcelShopNumber_{{number}}" {{selected}} onclick="Cart.SubmitCart()" /> 1578 <label for="{{fieldPrefix}}ParcelShopNumber_{{number}}" class="u-flex"> 1579 <span class="u-inline-block"> 1580 <span class="u-bold">{{company}}, </span> 1581 <span class="u-block">{{address}}, {{city}}</span> 1582 <span class="u-block">{{countryCode}} </span> 1583 </span> 1584 </label> 1585 </li> 1586 <li class="list__seperator"></li> 1587 {{/ParcelShops}} 1588 {{/.}} 1589 </script> 1590 1591 1592 string mapsScriptUrl = "//maps.googleapis.com/maps/api/js"; 1593 mapsScriptUrl += !String.IsNullOrEmpty(Pageview.AreaSettings.GetItem("Settings").GetString("GoogleMapsAPIKey")) ? "?key=" + Pageview.AreaSettings.GetItem("Settings").GetString("GoogleMapsAPIKey") : ""; 1594 1595 <script src="@mapsScriptUrl"></script> 1596 1597 if (Converter.ToBoolean(GetGlobalValue("Global:Extranet.UserName")) && GetLoop("UserManagement:User.UserAddresses").Count > 0) 1598 { 1599 <script> 1600 document.addEventListener("DOMContentLoaded", function (event) { 1601 document.getElementById("DeliveryAddressFields").addEventListener('contentLoaded', function (e) { 1602 var target = getTarget(e); 1603 if (target.name == "EcomOrderDeliveryCountry") { 1604 target.value = target.getAttribute("data-countryCode"); 1605 } 1606 }, false); 1607 }); 1608 </script> 1609 } 1610 } 1611 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 1612 @using Dynamicweb.Core 1613 @using System 1614 @using System.Web 1615 @using System.Collections.Generic 1616 @using Dynamicweb.Rapido.Blocks 1617 @using Dynamicweb.Rapido.Blocks.Extensibility 1618 1619 @{ 1620 BlocksPage customBlocksPage = BlocksPage.GetBlockPage("CheckoutPage"); 1621 if (GetGlobalValue("Global:Area.LongLang") != "en-US") 1622 { 1623 Block vatTemplates = new Block() 1624 { 1625 Id = "VatTemplate", 1626 SortId = 10, 1627 Template = RenderVatTemplates() 1628 }; 1629 customBlocksPage.Add("AddressContainerRow", vatTemplates); 1630 1631 Block vatScriptTemplates = new Block() 1632 { 1633 Id = "VatScriptTemplate", 1634 SortId = 11, 1635 Template = RenderVatScriptTemplates() 1636 }; 1637 customBlocksPage.Add("CheckoutBottomSnippets", vatScriptTemplates); 1638 } 1639 } 1640 1641 @helper RenderVatTemplates() 1642 { 1643 @* Templates for Vat Input *@ 1644 <script id="CartVatInput" type="text/x-template"> 1645 <div> 1646 <input type="hidden" id="PricesWithVat" value="@Dynamicweb.Ecommerce.Common.Context.DisplayPricesWithVat" /> 1647 </div> 1648 1649 <div class="form__field-group dw-mod"> 1650 <label for="EcomOrderCustomerVatRegNumber">@Translate("VatRegNumber")</label> 1651 <input type="text" class="u-full-width" name="EcomOrderCustomerVatRegNumber" id="EcomOrderCustomerVatRegNumber" value="@GetString("Ecom:Order.Customer.VatRegNumber")" /> 1652 <div class="u-pull--right"> 1653 <button type="button" class="btn btn--secondary btn--condensed dw-mod u-pull--left u-no-margin" onclick="VatCheck.ValidateVat(document.getElementById('EcomOrderCustomerVatRegNumber').value, document.getElementById('EcomOrderCustomerCountry').value, '@GetString("Ecom:Order.ID")');">Validate VAT</button> 1654 </div> 1655 <div class="field-error dw-mod ValidationErrorCustomerVatRegNumber" id="">@GetString("Ecom:Cart.ValidationError.EcomOrderCustomerVatRegNumber.ErrorMessage")</div> 1656 <div class="field-success dw-mod ValidationsuccessCustomerVatRegNumber" id=""></div> 1657 <input type="hidden" class="u-full-width" name="OrderIsVatValid" id="OrderIsVatValid" value="@(GetString("OrderIsVatValid.Clean") == "yes" ? "yes" : "" )" /> 1658 1659 1660 </div> 1661 </script> 1662 1663 } 1664 1665 @helper RenderVatScriptTemplates() 1666 { 1667 @* Templates for addresses *@ 1668 <script type="text/javascript"> 1669 // insert template in billingaddress 1670 document.querySelector("#Block__BillingAddress .card").insertAdjacentHTML('beforeend', document.getElementById("CartVatInput").innerHTML); 1671 1672 VatValidationTexts = { 1673 ValidOk: '@Translate("VatValid")', 1674 ValidError: '@Translate("VatError")' 1675 } 1676 </script> 1677 } 1678 1679 1680 1681 <section class="multiple-paragraphs-container u-color-light-gray--bg paragraph-container--full-width"> 1682 <div class="center-container center-container--with-background-image dw-mod"> 1683 <div class="paragraph-container"> 1684 <form name="ordersubmit" id="OrderSubmit" method="post" action="/Default.aspx?ID=@pageId" autocomplete="off"> 1685 <div class="grid"> 1686 @* The @RenderBlockList base helper is included in Components/GridBuilder.cshtml *@ 1687 @RenderBlockList(checkoutPage.BlocksRoot.BlocksList) 1688 </div> 1689 </form> 1690 </div> 1691 </div> 1692 </section>