• 1
  • 2
  • 3
Error executing template "Designs/Forney/eCom7/CartV2/Step/Step1-Dealers.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_2d8973975f4a43d88ac6079eb26ce4d8.Execute() in f:\Domains\Sites\forneyind.com\Files\Templates\Designs\Forney\eCom7\CartV2\Step\Step1-Dealers.cshtml:line 74
   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 RazorTemplateBase<RazorTemplateModel<Template>> 2 @using Dynamicweb.Rendering; 3 @using System.Web; 4 @using System.Web.Helpers; 5 @using System.Web.Script.Serialization; 6 @using System.Collections.Generic; 7 @using Dynamicweb.Ecommerce.Orders; 8 9 @{ 10 bool userIsLoggedIn = Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn(); 11 List<LoopItem> orderLines = GetLoop("OrderLines"); 12 string alertErrors = ""; 13 @* todo 14 Dictionary<string, double> linesToUpdate = new Dictionary<string, double>(); 15 double stockNumber = 0; 16 if(userIsLoggedIn) { 17 foreach (LoopItem ol in orderLines) 18 { 19 double orderlineStock = ol.GetDouble("Ecom:Order:OrderLine.Quantity"); 20 21 if (!string.IsNullOrWhiteSpace(ol.GetString("Ecom:Order:OrderLine.ProductVariantID"))) 22 { 23 stockNumber = Dynamicweb.Ecommerce.Products.Product.GetProductById(ol.GetString("Ecom:Order:OrderLine.ProductID"), ol.GetString("Ecom:Order:OrderLine.ProductVariantID")).Stock; 24 } 25 else 26 { 27 stockNumber = Dynamicweb.Ecommerce.Products.Product.GetProductById(ol.GetString("Ecom:Order:OrderLine.ProductID")).Stock; 28 } 29 // todo stock webservice 30 stockNumber = !string.IsNullOrEmpty(ol.GetString("WebSeviceConnectionStatus")) ? ol.GetInteger("WebSeviceConnectionStatus") : stockNumber; 31 32 if (stockNumber < 1) 33 { 34 linesToUpdate.Add(ol.GetString("Ecom:Order:OrderLine.Id"), 0); 35 } 36 else if (orderlineStock > stockNumber){ 37 linesToUpdate.Add(ol.GetString("Ecom:Order:OrderLine.Id"), stockNumber); 38 } 39 } 40 41 if (linesToUpdate.Any()) 42 { 43 Order order = Order.GetOrderById(Dynamicweb.Ecommerce.Common.Context.Cart.Id); 44 List<OrderLine> linesToDelete = new List<OrderLine>(); 45 string errorString = ""; 46 foreach (OrderLine orderline in order.OrderLines) 47 { 48 if (linesToUpdate.ContainsKey(orderline.Id)) 49 { 50 string str_orderlineProductCompleteName = !string.IsNullOrWhiteSpace(orderline.ProductVariantText) ? orderline.ProductName + " " + orderline.ProductVariantText : orderline.ProductName; 51 if (linesToUpdate[orderline.Id] < 1) 52 { 53 linesToDelete.Add(orderline); 54 errorString = Translate("productNoLongerAvalilable", "Sorry '{{CompleteProductName}}' is no longer available").Replace("{{CompleteProductName}}", str_orderlineProductCompleteName); 55 alertErrors += errorString + "<br/>"; 56 } 57 else 58 { 59 orderline.Quantity = linesToUpdate[orderline.Id]; 60 errorString = Translate("productStockUpdated", "Sorry there are now only '{{Stock}}' available of '{{CompleteProductName}}'. Your cart has been updated with the new amount").Replace("{{Stock}}", linesToUpdate[orderline.Id].ToString()).Replace("{{CompleteProductName}}", str_orderlineProductCompleteName); 61 alertErrors += errorString + "<br/>"; 62 } 63 } 64 } 65 if (linesToDelete.Any()) 66 { 67 linesToDelete.ForEach(ol => order.OrderLines.Remove(ol)); 68 } 69 order.Save(); 70 Dynamicweb.Ecommerce.Common.Context.SetCart(order); 71 } 72 } 73 *@ 74 string userID = Pageview.User.ID.ToString(), 75 errors = "", 76 errorsID = "", 77 customerCountryCode = GetString("Ecom:Order.Customer.Country.Code"), 78 customerCountry = customerCountryCode != "" ? customerCountryCode : GetString("UserManagement:User.DefaultAddress.Country"), 79 customerRegionCode = GetString("Ecom:Order.Customer.Region"), 80 customerRegion = customerRegionCode != "" ? customerRegionCode : GetString("UserManagement:User.DefaultAddress.State"), 81 customerZip = GetString("Ecom:Order.Customer.Zip") != "" ? GetString("Ecom:Order.Customer.Zip") : GetString("UserManagement:User.DefaultAddress.Zip"), 82 customerCity = GetString("Ecom:Order.Customer.City") != "" ? GetString("Ecom:Order.Customer.City") : GetString("UserManagement:User.DefaultAddress.City"), 83 customerPhone = GetString("Ecom:Order.Customer.Phone") != "" ? GetString("Ecom:Order.Customer.Phone") : GetString("UserManagement:User.DefaultAddress.Phone"), 84 deliveryEmail = GetString("Ecom:Order.Delivery.Email"), 85 voucherValue = GetString("discountVoucher.Clean"), 86 cartContentDivClass = userIsLoggedIn ? "col-xs-12" : "col-sm-5 col-xs-12", 87 cartContentDiv2Class = userIsLoggedIn ? "col-xs-12" : "col-sm-7 col-xs-12", 88 deliveryAddress = "", 89 customerAddress = "", 90 deliveryCity = GetString("Ecom:Order.Delivery.City") != "" ? GetString("Ecom:Order.Delivery.City") : customerCity, 91 deliveryPhone = GetString("Ecom:Order.Delivery.Phone") != "" ? GetString("Ecom:Order.Delivery.Phone") : customerPhone, 92 deliveryZip = GetString("Ecom:Order.Delivery.Zip") != "" ? GetString("Ecom:Order.Delivery.Zip") : customerZip, 93 deliveryRegion =""; 94 var item = Pageview.Area.Item; 95 string str_voucherName = ""; 96 string str_promoCode = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(Convert.ToInt32((item["PromoCodes"] ?? "0").ToString())); 97 string str_checkPromoCode = item["CheckInvalidCode"].ToString(); 98 99 100 101 102 103 deliveryAddress = GetString("Ecom:Order.Delivery.Address") + GetString("Ecom:Order.Delivery.Address2") + GetString("Ecom:Order.Delivery.City") + GetString("Ecom:Order.Delivery.Region") + GetString("Ecom:Order.Delivery.Zip") + GetString("Ecom:Order.Delivery.Country"); 104 customerAddress = GetString("Ecom:Order.Customer.Address") + GetString("Ecom:Order.Customer.Address2") + GetString("Ecom:Order.Customer.City") + GetString("Ecom:Order.Customer.Region") + GetString("Ecom:Order.Customer.Zip") + GetString("Ecom:Order.Customer.Country"); 105 bool addressesAreDifferent = deliveryAddress != customerAddress; 106 List<LoopItem> addressValidators = GetLoop("AddressValidators"); 107 bool hasErrors = false; 108 109 110 111 foreach(LoopItem av in addressValidators) { 112 string errorMessage = av.GetString("Ecom:Order.AddressValidator.ErrorMessage"); 113 if(!string.IsNullOrWhiteSpace(errorMessage)) { 114 hasErrors = true; 115 } else { 116 foreach(LoopItem af in av.GetLoop("AddressFields")) { 117 hasErrors = av.GetLoop("AddressFields").Count() > 0 ? true : false; 118 } 119 } 120 121 } 122 123 if(addressValidators.Any() && hasErrors) { 124 string fieldType = ""; 125 bool firstTime = true; 126 127 <div id="addressValidatorsContainer" class="hidden"> 128 129 <div id="addressValidators"> 130 131 132 @RenderSnippet("TitleChange") 133 @foreach(LoopItem av in addressValidators) 134 { 135 @* string errorMessage = av.GetString("Ecom:Order.AddressValidator.ErrorMessage"); *@ 136 string errorMessage = Translate(av.GetString("Ecom:Order.AddressValidator.ErrorMessage")); 137 138 if(!string.IsNullOrWhiteSpace(errorMessage)){ 139 <span class="addressValidationError">@errorMessage</span> 140 @SnippetStart("TitleChange") 141 <h2>@Translate("error", "Error")</h2> 142 @SnippetEnd("TitleChange") 143 break; 144 } 145 else if(firstTime) { 146 firstTime = false; 147 @SnippetStart("TitleChange") 148 <h2>@Translate("pleaseSelectTheChanges", "Please select the changes")</h2> 149 <label for="changeAll"><input id="changeAll" name="changeAll" type="checkbox">@Translate("all", "All")</label> 150 151 @SnippetEnd("TitleChange") 152 } 153 foreach(LoopItem af in av.GetLoop("AddressFields")) 154 { 155 string oldValue = af.GetString("Ecom:Order.AddressValidator.Field.OldValue"), 156 newValue = af.GetString("Ecom:Order.AddressValidator.Field.NewValue"), 157 type = af.GetString("Ecom:Order.AddressValidator.AddressType"), 158 field = af.GetString("Ecom:Order.AddressValidator.Field.Type"), 159 id = field + type; 160 161 if(fieldType != type) { 162 fieldType = type; 163 string title = fieldType == "Billing" ? Translate("billingAddress","Billing Address") : Translate("shippingAddress","Shipping Address") ; 164 165 <h3 class="col-xs-12 noPadding">@title</h3> 166 } 167 168 <div class="col-xs-12 noPadding addressChange" data-type="@type"> 169 <span class="col-xs-12 noPadding">@field</span> 170 <label data-type='@type' data-field='@field' class="col-xs-12 noPadding" for="@id"><input id="@id" name="@id" type="checkbox"><strike class="weightNormal">@oldValue</strike><span> - </span><span class="newValue">@newValue</span></label> 171 </div> 172 } 173 174 if (!addressesAreDifferent) { break; } 175 } 176 </div> 177 </div> 178 } 179 180 181 @* deliveryAddress = GetString("Ecom:Order.Delivery.Address") + GetString("Ecom:Order.Delivery.Address2") + GetString("Ecom:Order.Delivery.City") + GetString("Ecom:Order.Delivery.Region") + GetString("Ecom:Order.Delivery.Zip") + GetString("Ecom:Order.Delivery.Country"); 182 customerAddress = GetString("Ecom:Order.Customer.Address") + GetString("Ecom:Order.Customer.Address2") + GetString("Ecom:Order.Customer.City") + GetString("Ecom:Order.Customer.Region") + GetString("Ecom:Order.Customer.Zip") + GetString("Ecom:Order.Customer.Country"); 183 bool addressesAreDifferent = deliveryAddress != customerAddress; 184 List<LoopItem> addressValidators = GetLoop("AddressValidators"); 185 186 if(addressValidators.Any()) { 187 string fieldType = ""; 188 bool firstTime = true; 189 190 <div id="addressValidatorsContainer" class="hidden"> 191 <div id="addressValidators"> 192 193 194 @RenderSnippet("TitleChange") 195 @foreach(LoopItem av in addressValidators) 196 { 197 string errorMessage = av.GetString("Ecom:Order.AddressValidator.ErrorMessage"); 198 199 if(!string.IsNullOrWhiteSpace(errorMessage)){ 200 <span class="addressValidationError">@errorMessage</span> 201 @SnippetStart("TitleChange") 202 <h2>@Translate("error", "Error")</h2> 203 @SnippetEnd("TitleChange") 204 break; 205 } 206 else if(firstTime) { 207 firstTime = false; 208 @SnippetStart("TitleChange") 209 <h2>@Translate("pleaseSelectTheChanges", "Please select the changes")</h2> 210 <label for="changeAll"><input id="changeAll" name="changeAll" type="checkbox">@Translate("all", "All")</label> 211 @SnippetEnd("TitleChange") 212 } 213 214 foreach(LoopItem af in av.GetLoop("AddressFields")) 215 { 216 string oldValue = af.GetString("Ecom:Order.AddressValidator.Field.OldValue"), 217 newValue = af.GetString("Ecom:Order.AddressValidator.Field.NewValue"), 218 type = af.GetString("Ecom:Order.AddressValidator.AddressType"), 219 field = af.GetString("Ecom:Order.AddressValidator.Field.Type"), 220 id = field + type; 221 222 if(fieldType != type) { 223 fieldType = type; 224 string title = fieldType == "Billing" ? Translate("billingAddress","Billing Address") : Translate("shippingAddress","Shipping Address") ; 225 226 <h3 class="col-xs-12 noPadding">@title</h3> 227 } 228 229 <div class="col-xs-12 noPadding addressChange" data-type="@type"> 230 <span class="col-xs-12 noPadding">@field</span> 231 <label data-type='@type' data-field='@field' class="col-xs-12 noPadding" for="@id"><input id="@id" name="@id" type="checkbox"><strike class="weightNormal">@oldValue</strike><span> - </span><span class="newValue">@newValue</span></label> 232 </div> 233 } 234 235 if (!addressesAreDifferent) { break; } 236 } 237 </div> 238 </div> 239 } *@ 240 string showDeliveryAddress = addressesAreDifferent && !string.IsNullOrEmpty(deliveryEmail) ? "" : "hide"; 241 customerCountry = customerCountry != "" ? customerCountry : Dna.IP.Frontend.GetCountryCode(); 242 Dynamicweb.Content.Items.Item itemArea = Pageview.Area.Item; 243 Dictionary<string, Dictionary<string, string>> addressesId = new Dictionary<string, Dictionary<string, string>>(); 244 List<LoopItem> userAddresses = GetLoop("UserManagement:User.UserAddresses"); 245 246 if(System.Web.HttpContext.Current.Request.Cookies["checkout"] != null) { 247 System.Web.HttpCookie cookie2 = new System.Web.HttpCookie("checkout"); 248 cookie2.Expires = DateTime.Now.AddDays(-1d); 249 System.Web.HttpContext.Current.Response.Cookies.Add(cookie2); 250 } 251 } 252 <style> 253 254 .DMForms .bootstrap-select > .btn::before { 255 content: ""; 256 background-color: rgba(255, 0, 0, 0.59); 257 position: absolute; 258 top: 0; 259 left: 0; 260 bottom: 0; 261 z-index: 2; 262 right: 0; 263 } 264 265 .bootstrap-select.btn-group .btn .caret { 266 display:none; 267 } 268 </style> 269 270 <div id="cartFormContainer" class="col-xs-12 noPadding"> 271 <h2 class="cartDetail">@Translate("customerDetails", "Customer details") </h2> 272 <div class="col-xs-12 col-sm-8 col-md-9 noPaddingLeft"> 273 274 @if(System.Web.HttpContext.Current.Request.Params["error"] == null && GetInteger("Ecom:Order.OrderLines.TotalProductQuantity") > 0){ 275 <form class="DMForms" action='/Default.aspx?ID=@Pageview.Page.ID' name="ordersubmit" id="customerInfo" method="post"> 276 <input type="hidden" id="updater" data-next='@GetString("CartV2.NextStepButtonName")' name="@GetString("CartV2.NextStepButtonName")" value="@Translate("continueCheckout", "Continue Checkout")" /> 277 278 <div class="continueButton col-xs-12 topButton"> 279 <input class="btn btn-bg pull-right" type="submit" value="@Translate("continueCheckout", "Continue Checkout")"> 280 </div> 281 282 <div id="formContainer" class="blockCart col-xs-12 noPadding"> 283 <div class="hide"> 284 <input id="EcomOrderCustomerAccepted" name="EcomOrderCustomerAccepted" checked type="checkbox"> 285 </div> 286 <h2 class="smallTitle">@Translate("deliveryAddress", "Delivery Address")</h2> 287 <div id="customerInformation" class="part col-xs-12 noPadding"> 288 @if(userAddresses.Any()) { 289 <fieldset class="Select"> 290 <label for="selectAddress">@Translate("myAddresses", "My Addresses")</label> 291 <div class="select"> 292 <select data-live-search="true" name="selectAddress" id="selectAddress"> 293 @foreach (LoopItem userAddress in userAddresses) 294 { 295 Dictionary<string, string> addresses = new Dictionary<string, string>(); 296 string selected = userAddress.GetBoolean("UserManagement:User.UserAddress.Default") ? "selected" : "" ; 297 298 addresses.Add("EcomOrderCustomerAddress", userAddress.GetString("UserManagement:User.UserAddress.Address")); 299 addresses.Add("EcomOrderCustomerAddress2", userAddress.GetString("UserManagement:User.UserAddress.Address2")); 300 addresses.Add("EcomOrderCustomerZip", userAddress.GetString("UserManagement:User.UserAddress.Zip")); 301 addresses.Add("EcomOrderCustomerCity", userAddress.GetString("UserManagement:User.UserAddress.City")); 302 addresses.Add("EcomOrderCustomerCountry", userAddress.GetString("UserManagement:User.UserAddress.Country")); 303 addresses.Add("EcomOrderCustomerRegion", userAddress.GetString("UserManagement:User.UserAddress.State")); 304 addressesId.Add(userAddress.GetString("UserManagement:User.UserAddress.ID"), addresses); 305 <option @selected value="@(userAddress.GetString("UserManagement:User.UserAddress.ID"))">@userAddress.GetString("UserManagement:User.UserAddress.Address")</option> 306 } 307 </select> 308 </div> 309 </fieldset> 310 }else{ 311 customerAddress = GetString("Ecom:Order.Customer.Address") != "" ? GetString("Ecom:Order.Customer.Address") : GetString("UserManagement:User.DefaultAddress.Address"); 312 deliveryAddress = GetString("Ecom:Order.Delivery.Address") != "" ? GetString("Ecom:Order.Delivery.Address") : customerAddress; 313 <fieldset class="Select"> 314 <label for="selectAddress">@Translate("myAddresses", "My Addresses")</label> 315 <div class="select"> 316 @{ 317 Dictionary<string, string> addresses = new Dictionary<string, string>(); 318 addresses.Add("EcomOrderCustomerAddress", GetString("UserManagement:User.DefaultAddress.Address")); 319 addresses.Add("EcomOrderCustomerAddress2", GetString("UserManagement:User.DefaultAddress.Address2")); 320 addresses.Add("EcomOrderCustomerZip", GetString("UserManagement:User.DefaultAddress.Zip")); 321 addresses.Add("EcomOrderCustomerCity", GetString("UserManagement:User.DefaultAddress.City")); 322 addresses.Add("EcomOrderCustomerCountry", GetString("UserManagement:User.DefaultAddress.Country")); 323 addresses.Add("EcomOrderCustomerRegion", GetString("UserManagement:User.DefaultAddress.State")); 324 } 325 <select data-live-search="true" name="selectAddress" id="selectAddress"> 326 <option selected value="">@GetString("UserManagement:User.DefaultAddress.Address") @GetString("UserManagement:User.DefaultAddress.Zip") @GetString("UserManagement:User.DefaultAddress.State") @GetString("UserManagement:User.DefaultAddress.City")</option> 327 </select> 328 </div> 329 </fieldset> 330 } 331 332 333 <fieldset class="readonly"> 334 <label for="EcomOrderCustomerEmail">@Translate("email", "Email")</label> 335 <input type="email" name="EcomOrderCustomerEmail" id="EcomOrderCustomerEmail" value='@(GetString("UserManagement:SecondaryUser.Email"))' readonly/> 336 @*<div class="note">@Translate("receiptWillBeSentToEmail", "A receipt will be sent to this address")</div>*@ 337 </fieldset> 338 <input type="hidden" name="EcomOrderCustomerName" id="EcomOrderCustomerName" value="@(GetString("Ecom:Order.Customer.Name"))" /> 339 <input type="hidden"name="EcomOrderCustomerFirstName" id="EcomOrderCustomerFirstName" value="@GetString("Ecom:Order.Customer.FirstName")" /> 340 <input type="hidden"name="EcomOrderCustomerSurname" id="EcomOrderCustomerSurname" value="@GetString("Ecom:Order.Customer.Surname")"/> 341 @Fieldset("readonly", "EcomOrderCustomerCompany", @Translate("company", "Company"), "text", @GetString("Ecom:Order.Customer.Company"), "") 342 @Fieldset("readonly", "EcomOrderCustomerAddress", @Translate("billingAddress", "Address"), "text", @customerAddress,"readonly") 343 @Fieldset("readonly", "EcomOrderCustomerAddress2", @Translate("secondAddressLine", "Address 2"), "text", @GetString("Ecom:Order.Customer.Address2"),"readonly") 344 @Fieldset("readonly", "EcomOrderCustomerCity", @Translate("city", "City"), "text", @customerCity,"readonly") 345 346 <fieldset class="Select readonly region" data-region="@customerRegion"> 347 <label for="EcomOrderCustomerRegion" data-text="@Translate("stateProvince", "State / Province")" data-textUS="@Translate("state", "State")" data-textCA="@Translate("province", "Province")">@Translate("stateProvince", "State / Province")</label> 348 <div class="select region"> 349 <select data-live-search="true" data-size="8" name="EcomOrderCustomerRegion" id="EcomOrderCustomerRegion" data-text="@Translate("stateProvince", "State / Province")" data-textUS="@Translate("state", "State")" data-textCA="@Translate("province", "Province")"> 350 <option class="defaultOption" value="">@Translate("stateProvince", "State / Province")</option> 351 </select> 352 </div> 353 </fieldset> 354 355 <fieldset class="readonly"> 356 <label for="EcomOrderCustomerZip" data-text="@Translate("zipPostal", "Zip / Postal Code")" data-textUS="@Translate("zip", "Zip")" data-textCA="@Translate("postalCode", "Postal Code")">@Translate("zipPostal", "Zip / Postal Code")</label> 357 <input type="text" name="EcomOrderCustomerZip" id="EcomOrderCustomerZip" value="@customerZip" readonly/> 358 </fieldset> 359 <fieldset class="readonly Select country"> 360 <label for="EcomOrderCustomerCountry">@Translate("country", "Country")</label> 361 <div class="select country"> 362 <select data-live-search="true" id="EcomOrderCustomerCountry" name="EcomOrderCustomerCountry" data-size="8"> 363 <option value="">@Translate("country", "Country")</option> 364 @RenderSnippet("highlightedContries") 365 </select> 366 </div> 367 </fieldset> 368 @Fieldset("readonly", "EcomOrderCustomerPhone", @Translate("phone", "Phone"), "text", @GetString("Ecom:Order.Customer.Phone"),"readonly") 369 </div> 370 @*shipping address*@ 371 <div id="deliveryAddress" class="part col-xs-12 noPadding blockCart hidden"> 372 <div id="sameAddress"> 373 <h2>@Translate("shippingAddress", "Shipping Address")</h2> 374 <div class="chooseDelivery"> 375 <span class="col-xs-12 noPadding">@Translate("isTheAddressAbove","Is the address above also the shipping address")</span> 376 <label> 377 <input value="no" type="radio" name="deliveryaddress" @(deliveryAddress == customerAddress || string.IsNullOrEmpty(deliveryEmail) ? "checked" : "") /> 378 @Translate("yes", "Yes") 379 </label> 380 <label> 381 <input value="yes" type="radio" name="deliveryaddress" @(deliveryAddress != customerAddress && !string.IsNullOrEmpty(deliveryEmail) ? "checked" : "") /> 382 @Translate("no", "No") 383 </label> 384 </div> 385 </div> 386 <div class="@showDeliveryAddress" id="deliveryFormContainer"> 387 @if(userAddresses.Any()) { 388 <fieldset class="Select"> 389 <label for="selectAddress2">@Translate("myAddresses", "My Addresses")</label> 390 <div class="select"> 391 <select data-live-search="true" name="selectAddress2" id="selectAddress2"> 392 @foreach (LoopItem userAddress in userAddresses) 393 { 394 string selected = userAddress.GetBoolean("UserManagement:User.UserAddress.Default") ? "selected" : "" ; 395 396 <option @selected value="@(userAddress.GetString("UserManagement:User.UserAddress.ID"))">@userAddress.GetString("UserManagement:User.UserAddress.Address")</option> 397 } 398 </select> 399 </div> 400 </fieldset> 401 } 402 @Fieldset("", "EcomOrderDeliveryFirstName", @Translate("attention", "Attention"), "text", @GetString("Ecom:Order.Delivery.FirstName"),"readonly") 403 @Fieldset("", "EcomOrderDeliveryEmail", @Translate("email", "Email"), "email", @deliveryEmail,"readonly") 404 @Fieldset("mandatory", "EcomOrderDeliveryAddress", @Translate("address", "Address"), "text", @deliveryAddress,"readonly") 405 @Fieldset("", "EcomOrderDeliveryAddress2", @Translate("secondAddressLine", "Address 2"), "text", @GetString("Ecom:Order.Delivery.Address2"),"readonly") 406 @Fieldset("mandatory", "EcomOrderDeliveryCity", @Translate("city", "City"), "text", @deliveryCity,"readonly") 407 <fieldset class="Select" data-region="@deliveryRegion"> 408 <label for="EcomOrderDeliveryRegion" data-text="@Translate("stateProvince", "State / Province")" data-textUS="@Translate("state", "State")" data-textCA="@Translate("province", "Province")">@Translate("stateProvince", "State / Province")</label> 409 <div class="select"> 410 <select data-live-search="true" data-size="8" name="EcomOrderDeliveryRegion" id="EcomOrderDeliveryRegion" data-text="@Translate("stateProvince", "State / Province")" data-textUS="@Translate("state", "State")" data-textCA="@Translate("province", "Province")"> 411 <option value="">@Translate("stateProvince", "State / Province")</option> 412 </select> 413 </div> 414 </fieldset> 415 <fieldset class="mandatory"> 416 <label for="EcomOrderDeliveryZip" data-text="@Translate("zipPostal", "Zip / Postal Code")" data-textUS="@Translate("zip", "Zip")" data-textCA="@Translate("postalCode", "Postal Code")">@Translate("zipPostal", "Zip / Postal Code")</label> 417 <input type="text" name="EcomOrderDeliveryZip" id="EcomOrderDeliveryZip" value="@deliveryZip" /> 418 </fieldset> 419 <fieldset class="mandatory Select"> 420 <label for="EcomOrderDeliveryCountry">@Translate("country", "Country")</label> 421 <div class="select"> 422 <select data-live-search="true" id="EcomOrderDeliveryCountry" name="EcomOrderDeliveryCountry" data-size="8"> 423 <option value="">@Translate("country", "Country")</option> 424 @RenderSnippet("highlightedContries") 425 </select> 426 </div> 427 </fieldset> 428 @Fieldset("mandatory", "EcomOrderDeliveryPhone", @Translate("phone", "Phone"), "text", @deliveryPhone,"readonly") 429 </div> 430 </div> 431 432 </div> 433 </form> 434 435 <div class="continueButton col-xs-12 bottom"> 436 <a class="btn btn-bg pull-right" type="submit" href="javascript:document.getElementById('customerInfo').submit();">@Translate("continueCheckout", "Continue Checkout")</a> 437 <div id="promoCodeContainer" class="pull-left"> 438 <span>@Translate("voucherCodeText", "Enter a Voucher Code:")</span> 439 <form class="cartPromo" method="POST" action="/Default.aspx?ID=@Pageview.Page.ID"> 440 @{ 441 string invalid = Translate("invalidPromotionCode", "We’re sorry, this promotion code is invalid. Please try again."); 442 string inactive = Translate("inactivePromotionCode", "We're sorry, this promotion code is not yet active."); 443 string expired = Translate("expiredPromotionCode", "We're sorry, this promotion code has expired."); 444 } 445 @if(GetString("Ecom:Order.Customer.VoucherCode") == "") { 446 <input type="text" data-checkCode="@str_checkPromoCode" name="EcomOrderVoucherCode" value="@(GetString("Ecom:Order.Customer.VoucherCode"))" onkeydown="upperCaseF(this)" data-invalid='@invalid' data-inactive='@inactive' data-expired='@expired' /> 447 <button class="submitVoucher btn btn-bg" type="submit"> 448 @Translate("apply", "Apply") 449 </button> 450 } else { 451 <input type="text" data-checkCode="@str_checkPromoCode" name="EcomOrderVoucherCode" value="@(GetString("Ecom:Order.Customer.VoucherCode"))" onkeydown="upperCaseF(this)" data-invalid='@invalid' data-inactive='@inactive' data-expired='@expired' disabled /> 452 <button class="cancelVoucher btn btn-black" type="button"> 453 @Translate("removeVoucher", "Remove") 454 </button> 455 } 456 457 </form> 458 @GetString("Ecom:Cart.ValidationError.EcomOrderVoucherCode.ErrorMessage") 459 </div> 460 </div> 461 462 <div class="col-xs-12 col-sm-7 noPadding-xs"> 463 464 465 </div> 466 } 467 else if(System.Web.HttpContext.Current.Request.Params["error"] != null){ 468 @*Validation errors*@ 469 foreach (LoopItem validationError in GetLoop("ValidationErrors")){ 470 errors += validationError.GetString("Ecom:Cart.ValidationError.ErrorMessage") + "--"; 471 errorsID += validationError.GetString("Ecom:Cart.ValidationError.FieldSystemName") + "--"; 472 } 473 474 foreach(LoopItem av in GetLoop("AddressValidators")) 475 { 476 errors += av.GetString("Ecom:Order.AddressValidator.ErrorMessage"); 477 errorsID += av.GetString("Ecom:Order.AddressValidator.FieldSystemName") + "--"; 478 } 479 480 errors = HttpUtility.JavaScriptStringEncode(errors); 481 482 <div data-errorid="@errorsID" id="error">@errors</div> 483 } 484 else if(GetInteger("Ecom:Order.OrderLines.TotalProductQuantity")==0){ 485 System.Web.HttpContext.Current.Response.Redirect("/"); 486 } 487 </div> 488 @using Dynamicweb.Ecommerce.Orders; 489 @using Dynamicweb.Rendering; 490 @using System.Linq; 491 @using System.Collections.Specialized; 492 @functions{ 493 private string OrderType(string orderType, bool isProduct, string productId, bool productPriceIsZeroBool, string productPriceIsZero, string discountType, string parentLineId, string voucherValue, bool loadedVoucherBool ){ 494 bool isDiscount = false; 495 496 if (orderType == "3" || orderType == "1") 497 { 498 isDiscount = true; 499 if (isProduct) 500 { 501 discountType = "offerProduct"; 502 } 503 else { 504 discountType = "offerValue"; 505 } 506 } 507 if (isDiscount && voucherValue != "") 508 { 509 discountType = "offerVoucher"; 510 } 511 512 return discountType; 513 514 } 515 } 516 @using Dna.Forney.Ecommerce; 517 @{ 518 var permissions = PermissionsFacade.GetPermissions(); 519 @* string userType = permissions.Type.ToString(); *@ 520 string orderFromExcelLink = "/Default.aspx?ID=195"; 521 522 bool AccessToConsumerProductSet = permissions.AccessToConsumerProductSet, 523 AccessToDealerProductSet4KProducts = permissions.AccessToDealerProductSet4KProducts, 524 AccessToIndustrialProProductSet9KProducts = permissions.AccessToIndustrialProProductSet9KProducts, 525 DisplayMsrpPricing = permissions.DisplayMsrpPricing, 526 DisplayMsrpPricingPlus = permissions.DisplayMsrpPricingPlus, 527 DisplayAccountSpecificTradeAgreementPricing = permissions.DisplayAccountSpecificTradeAgreementPricing, 528 DisplayQuantityDiscounts = permissions.DisplayQuantityDiscounts, 529 DisplayGreenbackRebateLinkButton = permissions.DisplayGreenbackRebateLinkButton, 530 AbilityToViewShippingAddress = permissions.AbilityToViewShippingAddress, 531 AbilityToUpdateShippingAndBillingAddress = permissions.AbilityToUpdateShippingAndBillingAddress, 532 CreditCardPayments = permissions.CreditCardPayments, 533 PoPayments = permissions.PoPayments, 534 UpsShippingMethod = permissions.UpsShippingMethod, 535 ShipMethodIncludingLtlDeterminedByForneyRep = permissions.ShipMethodIncludingLtlDeterminedByForneyRep, 536 ShipCancelOrBackorderDisplay = permissions.ShipCancelOrBackorderDisplay, 537 AbilityToCreateAccountsOnline = permissions.AbilityToCreateAccountsOnline, 538 DisplayTotalPricingOnPastOrders = permissions.DisplayTotalPricingOnPastOrders, 539 DisplayPoNumberOnPastOrders = permissions.DisplayPoNumberOnPastOrders, 540 AbilityToDownloadOrdersAsCsv = permissions.AbilityToDownloadOrdersAsCsv, 541 HasZipcode = !string.IsNullOrEmpty(UserFacade.GetZipCode())? true : false, 542 @* isDealer = (userType == "Dealer" || userType == "IndPro") ? true : false, *@ 543 CanOrderFromExcel = permissions.Type.ToString() == "Dealer" || permissions.Type.ToString() == "IndPro" ? true : false; 544 545 var zipCode = UserFacade.GetZipCode(); 546 547 } 548 @{ 549 550 551 double subtotalNum = GetDouble("Ecom:Order.PriceWithoutDiscountsOrTaxes.Price") - GetDouble("Ecom:Order.ShippingFee.PriceWithoutVAT"); 552 string subtotalString = GetString("Ecom:Order.Currency.Symbol") + subtotalNum.ToString("#,##.00"); 553 } 554 <div id="cartRightContent" class="col-xs-12 col-sm-4 col-md-3 noPaddingRight"> 555 <h2>@Translate("orderSummary", "Order Summary")</h2> 556 557 @if(orderLines.Any()) { 558 string currency = GetString("Ecom:Order.Price.Currency.Symbol"); 559 560 <ul class="col-xs-12 noPadding rightColProducts"> 561 @if(!string.IsNullOrWhiteSpace(GetString("Ecom:Order.Delivery.Address"))) { 562 <li class="col-xs-12 noPadding longContainer"> 563 @if(deliveryAddress == customerAddress) { 564 <h3 class="col-xs-12 rightTitle"> 565 @Translate("billingShippingAddress","Billing & Shipping Address") 566 </h3> 567 <div class="col-xs-12"> 568 @GetString("Ecom:Order.Delivery.Address") @GetString("Ecom:Order.Delivery.Address2") <br/> 569 @GetString("Ecom:Order.Delivery.City"), @GetString("Ecom:Order.Delivery.Region") @GetString("Ecom:Order.Delivery.Zip"), @GetString("Ecom:Order.Delivery.Country") 570 </div> 571 } 572 else { 573 if(!CanOrderFromExcel){ 574 <h3 class="col-xs-12 rightTitle"> 575 @Translate("billingAddress","Billing Address") 576 </h3> 577 <div class="col-xs-12"> 578 @GetString("Ecom:Order.Customer.Address") @GetString("Ecom:Order.Customer.Address2") <br/> 579 @GetString("Ecom:Order.Customer.City"), @GetString("Ecom:Order.Customer.Region") @GetString("Ecom:Order.Customer.Zip"), @GetString("Ecom:Order.Customer.Country") 580 </div> 581 } 582 <h3 class="col-xs-12 rightTitle"> 583 @Translate("shippingAddress","Shipping Address") 584 </h3> 585 <div class="col-xs-12"> 586 @GetString("Ecom:Order.Delivery.Address") @GetString("Ecom:Order.Delivery.Address2") <br/> 587 @GetString("Ecom:Order.Delivery.City"), @GetString("Ecom:Order.Delivery.Region") @GetString("Ecom:Order.Delivery.Zip")<br/> 588 @GetString("Ecom:Order.Delivery.Country") 589 </div> 590 } 591 </li> 592 } 593 594 595 @if(!string.IsNullOrWhiteSpace(GetString("Ecom:Order.Delivery.Address"))) { 596 <li class="col-xs-12 noPadding longContainer"> 597 <h3 class="col-xs-12">@Translate("orderDetails","Order Details")</h3> 598 </li> 599 } 600 601 @foreach (LoopItem orderLine in orderLines) 602 { 603 bool isProduct = orderLine.GetBoolean("Ecom:Order:OrderLine.IsProduct"), 604 productPriceIsZeroBool = orderLine.GetBoolean("Ecom:Order:OrderLine.Price.IsZero"), 605 isDiscount = false; 606 string parentLineId = orderLine.GetString("Ecom:Order:OrderLine.ParentLineID"), 607 orderType = orderLine.GetString("Ecom:Order:OrderLine.Type"), 608 discountType = "", 609 productPriceIsZero = orderLine.GetString("Ecom:Order.Price.PricePIP"), 610 productId = orderLine.GetString("Ecom:Order:OrderLine.ProductID"), 611 priceWithoutVATFormatted = orderLine.GetString("Ecom:Order:OrderLine.Price.PriceWithoutVATFormatted"), 612 totalPriceWithProductDiscounts = orderLine.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts"), 613 variantText = orderLine.GetString("Ecom:Order:OrderLine.ProductVariantText"); 614 615 discountType = OrderType(orderType, isProduct, productId, productPriceIsZeroBool, productPriceIsZero, discountType, parentLineId, voucherValue, false ); 616 617 if(discountType == "" && isProduct) { 618 <li class="col-xs-12 noPadding"> 619 <div> 620 <h3 class="col-xs-8"> 621 @orderLine.GetString("Ecom:Order:OrderLine.ProductName") 622 @if(!string.IsNullOrEmpty(variantText)){ 623 <br/> 624 <span>@variantText</span> 625 } 626 </h3> 627 @if( priceWithoutVATFormatted != totalPriceWithProductDiscounts ) { 628 <span class="col-xs-4 text-right">@orderLine.GetString("Ecom:Order:OrderLine.Price.PriceWithoutVATFormatted")</span> 629 } 630 </div> 631 <div> 632 <span class="col-xs-6">@Translate("qty", "Qty"): @orderLine.GetString("Ecom:Order:OrderLine.Quantity")</span> 633 <span class="col-xs-6 text-right bold">@orderLine.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts")</span> 634 </div> 635 </li> 636 } 637 } 638 <li class="col-xs-12 noPadding"> 639 @if(GetDouble("Ecom:Order.RewardTotalPoints") > 0) 640 { 641 <div class="col-xs-12">@Translate("loyaltyPointsEarned","Loyalty Points Earned") @GetString("Ecom:Order.RewardTotalPoints")</div> 642 } 643 <ul> 644 <li class="clearfix" style="width: 100%;"> 645 <div class="col-xs-6"><b>@Translate("subTotal", "Subtotal")</b></div> 646 <div class="col-xs-6 text-right"><b>@subtotalString</b></div> 647 648 </li> 649 650 651 @if(GetString("Ecom:Order.OrderLines.TotalDiscount") != (currency+"0.00")) 652 { 653 <li class="clearfix" style="width: 100%;"> 654 <div class="col-xs-6">@Translate("discount", "Discount")</div> 655 <div class="col-xs-6 text-right">@GetString("Ecom:Order.OrderLines.TotalDiscount")</div> 656 </li> 657 } 658 659 @if(GetString("Ecom:Order.Taxes.Total.Price") != "0.00") { 660 <li class="clearfix" style="width: 100%;"> 661 <div class="col-xs-6">@Translate("taxes", "Taxes")</div> 662 <div class="col-xs-6 text-right">@GetString("Ecom:Order.Taxes.Total")</div> 663 </li> 664 } 665 </ul> 666 @if(GetDouble("Ecom:Order.TotalPoints") > 0) 667 { 668 <div class="col-xs-12">@GetString("Ecom:Order.TotalPoints") @Translate("LoyaltyPointsSpent","Loyalty Points Spent")</div> 669 } 670 </li> 671 <li class="col-xs-12 totalContainer"> 672 <b class="col-xs-6">@Translate("total", "Total")</b> 673 <b class="col-xs-6 text-right">@GetString("Ecom:Order.OrderLines.Total.PriceWithoutVAT")</b> 674 </li> 675 </ul> 676 if(GetBoolean("Ecom:Order.ShippingFee.IsZero") && !CanOrderFromExcel){ 677 <small class="col-xs-12">* @Translate("taxesCalculatedCheckoutDealers", "Taxes and Shipping Calculated at Checkout")</small> 678 } 679 <div id="editOrderButton" class="col-xs-12 text-center"> 680 <a class="btn btn-bg" href='@itemArea["ShowCart"]'>@Translate("editOrder","Edit order")</a> 681 </div> 682 683 } 684 </div> 685 686 </div> 687 688 @{ 689 690 foreach (LoopItem country in GetLoop("Countries")) 691 { 692 if(country.GetString("Ecom:Country.Code2") == "CA" || country.GetString("Ecom:Country.Code2")== "US"){ 693 @SnippetStart("highlightedContries") 694 <option value="@(country.GetString("Ecom:Country.Code2"))"> 695 @country.GetString("Ecom:Country.Name") 696 </option> 697 @SnippetEnd("highlightedContries") 698 } 699 @* <option value="@(country.GetString("Ecom:Country.Code2"))"> 700 @country.GetString("Ecom:Country.Name") 701 </option> *@ 702 } 703 } 704 705 706 @helper DisplayCountries(bool firstTime){ 707 @*@RenderSnippet("highlightedContries") 708 foreach (LoopItem country in GetLoop("Countries")) 709 { 710 if(firstTime) { 711 if(country.GetString("Ecom:Country.Code2") == "CA" || country.GetString("Ecom:Country.Code2")== "US"){ 712 @SnippetStart("highlightedContries") 713 <option value="@(country.GetString("Ecom:Country.Code2"))"> 714 @country.GetString("Ecom:Country.Name") 715 </option> 716 @SnippetEnd("highlightedContries") 717 } 718 } 719 <option value="@(country.GetString("Ecom:Country.Code2"))"> 720 @country.GetString("Ecom:Country.Name") 721 </option> 722 } 723 if(firstTime) { 724 @SnippetStart("highlightedContries") 725 <option disabled="disabled" value=""> 726 ---------------- 727 </option> 728 @SnippetEnd("highlightedContries") 729 }*@ 730 } 731 732 @helper DisplayRegions(){ 733 Dictionary<string, dynamic> locations = new Dictionary<string, dynamic>(); 734 string productJSON = ""; 735 736 locations.Add("locations", new Dictionary<string, dynamic>()); 737 locations["locations"].Add("Countries", new List<dynamic>()); 738 739 foreach (LoopItem ct in GetLoop("Countries")) 740 { 741 List<LoopItem> regionsList = ct.GetLoop("Regions"); 742 Dictionary<string, dynamic> countryDict = new Dictionary<string, dynamic>(); 743 Dictionary<string, dynamic> countryKey = new Dictionary<string, dynamic>(); 744 745 countryKey.Add("id", ct.GetString("Ecom:Country.Code2")); 746 countryKey.Add("regions", new List<dynamic>()); 747 748 foreach (LoopItem region in regionsList.OrderBy(s => s.GetString("Ecom:Region.Name"))) 749 { 750 Dictionary<string, string> regionsDict = new Dictionary<string, string>(); 751 752 regionsDict.Add("name", region.GetString("Ecom:Region.Name")); 753 regionsDict.Add("code", region.GetString("Ecom:Region.RegionCode")); 754 countryKey["regions"].Add(regionsDict); 755 } 756 countryDict.Add("country", countryKey); 757 locations["locations"]["Countries"].Add(countryDict); 758 } 759 productJSON = new JavaScriptSerializer().Serialize(locations); 760 @productJSON 761 762 } 763 @functions { 764 public static string toJson(Dictionary<string, Dictionary<string, string>> obj_dictionary) 765 { 766 var json = new JavaScriptSerializer().Serialize(obj_dictionary); 767 768 return json; 769 } 770 } 771 @SnippetStart("jsOnLoad") 772 onLoadCartStep1( { 773 errors:{ 774 str_errors : "@errors", 775 str_errorsID : "@errorsID" 776 }, 777 str_alertErrors : "@alertErrors", 778 submitedValues : { 779 str_customerCountry : "@customerCountry", 780 str_deliveryCountry : "@customerCountry", //"@GetString("Ecom:Order.Delivery.Country.Code")", 781 str_customerRegion : "@customerRegion", 782 str_deliveryRegion : "@GetString("Ecom:Order.Delivery.Region")" 783 }, 784 regions : '@DisplayRegions()', 785 addresses : '@toJson(addressesId)' 786 787 }); 788 //$(function () { 789 //$('#EcomOrderCustomerRegion button[type="button"]').prop('disabled', true) 790 //}); 791 @SnippetEnd("jsOnLoad") 792 @helper Fieldset(string className, string labelFor, string labelText, string inputType, string value, string readOnly) { 793 <fieldset class="@className"> 794 <label for="@labelFor">@labelText</label> 795 <input type="@inputType"name="@labelFor" id="@labelFor" value="@value" @readOnly/> 796 </fieldset> 797 }