• 1
  • 2
  • 3
Exception in template (Designs\Forney\eCom7/CartV2/Step/Step1-Dealers.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.daadabecce.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Templating.TemplateService.Run(ITemplate template, DynamicViewBag viewBag)
   at RazorEngine.Templating.TemplateService.Parse(String razorTemplate, Object model, DynamicViewBag viewBag, String cacheName)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, DynamicViewBag viewBag, String cacheName)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()
@inherits RazorTemplateBase<RazorTemplateModel<Template>> @using Dynamicweb.Rendering; @using System.Web; @using System.Web.Helpers; @using System.Web.Script.Serialization; @using System.Collections.Generic; @using Dynamicweb.Ecommerce.Orders; @{ bool userIsLoggedIn = Dynamicweb.Security.UserManagement.User.IsExtranetUserLoggedIn(); List<LoopItem> orderLines = GetLoop("OrderLines"); string alertErrors = ""; @* todo Dictionary<string, double> linesToUpdate = new Dictionary<string, double>(); double stockNumber = 0; if(userIsLoggedIn) { foreach (LoopItem ol in orderLines) { double orderlineStock = ol.GetDouble("Ecom:Order:OrderLine.Quantity"); if (!string.IsNullOrWhiteSpace(ol.GetString("Ecom:Order:OrderLine.ProductVariantID"))) { stockNumber = Dynamicweb.Ecommerce.Products.Product.GetProductById(ol.GetString("Ecom:Order:OrderLine.ProductID"), ol.GetString("Ecom:Order:OrderLine.ProductVariantID")).Stock; } else { stockNumber = Dynamicweb.Ecommerce.Products.Product.GetProductById(ol.GetString("Ecom:Order:OrderLine.ProductID")).Stock; } // todo stock webservice stockNumber = !string.IsNullOrEmpty(ol.GetString("WebSeviceConnectionStatus")) ? ol.GetInteger("WebSeviceConnectionStatus") : stockNumber; if (stockNumber < 1) { linesToUpdate.Add(ol.GetString("Ecom:Order:OrderLine.Id"), 0); } else if (orderlineStock > stockNumber){ linesToUpdate.Add(ol.GetString("Ecom:Order:OrderLine.Id"), stockNumber); } } if (linesToUpdate.Any()) { Order order = Order.GetOrderById(Dynamicweb.Ecommerce.Common.Context.Cart.Id); List<OrderLine> linesToDelete = new List<OrderLine>(); string errorString = ""; foreach (OrderLine orderline in order.OrderLines) { if (linesToUpdate.ContainsKey(orderline.Id)) { string str_orderlineProductCompleteName = !string.IsNullOrWhiteSpace(orderline.ProductVariantText) ? orderline.ProductName + " " + orderline.ProductVariantText : orderline.ProductName; if (linesToUpdate[orderline.Id] < 1) { linesToDelete.Add(orderline); errorString = Translate("productNoLongerAvalilable", "Sorry '{{CompleteProductName}}' is no longer available").Replace("{{CompleteProductName}}", str_orderlineProductCompleteName); alertErrors += errorString + "<br/>"; } else { orderline.Quantity = linesToUpdate[orderline.Id]; 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); alertErrors += errorString + "<br/>"; } } } if (linesToDelete.Any()) { linesToDelete.ForEach(ol => order.OrderLines.Remove(ol)); } order.Save(); Dynamicweb.Ecommerce.Common.Context.SetCart(order); } } *@ string userID = Pageview.User.ID.ToString(), errors = "", errorsID = "", customerCountryCode = GetString("Ecom:Order.Customer.Country.Code"), customerCountry = customerCountryCode != "" ? customerCountryCode : GetString("UserManagement:User.DefaultAddress.Country"), customerRegionCode = GetString("Ecom:Order.Customer.Region"), customerRegion = customerRegionCode != "" ? customerRegionCode : GetString("UserManagement:User.DefaultAddress.State"), customerZip = GetString("Ecom:Order.Customer.Zip") != "" ? GetString("Ecom:Order.Customer.Zip") : GetString("UserManagement:User.DefaultAddress.Zip"), customerCity = GetString("Ecom:Order.Customer.City") != "" ? GetString("Ecom:Order.Customer.City") : GetString("UserManagement:User.DefaultAddress.City"), customerPhone = GetString("Ecom:Order.Customer.Phone") != "" ? GetString("Ecom:Order.Customer.Phone") : GetString("UserManagement:User.DefaultAddress.Phone"), deliveryEmail = GetString("Ecom:Order.Delivery.Email"), voucherValue = GetString("discountVoucher.Clean"), cartContentDivClass = userIsLoggedIn ? "col-xs-12" : "col-sm-5 col-xs-12", cartContentDiv2Class = userIsLoggedIn ? "col-xs-12" : "col-sm-7 col-xs-12", deliveryAddress = "", customerAddress = "", deliveryCity = GetString("Ecom:Order.Delivery.City") != "" ? GetString("Ecom:Order.Delivery.City") : customerCity, deliveryPhone = GetString("Ecom:Order.Delivery.Phone") != "" ? GetString("Ecom:Order.Delivery.Phone") : customerPhone, deliveryZip = GetString("Ecom:Order.Delivery.Zip") != "" ? GetString("Ecom:Order.Delivery.Zip") : customerZip, deliveryRegion =""; var item = Pageview.Area.Item; string str_voucherName = ""; string str_promoCode = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(Convert.ToInt32((item["PromoCodes"] ?? "0").ToString())); string str_checkPromoCode = item["CheckInvalidCode"].ToString(); 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"); 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"); bool addressesAreDifferent = deliveryAddress != customerAddress; List<LoopItem> addressValidators = GetLoop("AddressValidators"); bool hasErrors = false; foreach(LoopItem av in addressValidators) { string errorMessage = av.GetString("Ecom:Order.AddressValidator.ErrorMessage"); if(!string.IsNullOrWhiteSpace(errorMessage)) { hasErrors = true; } else { foreach(LoopItem af in av.GetLoop("AddressFields")) { hasErrors = av.GetLoop("AddressFields").Count() > 0 ? true : false; } } } if(addressValidators.Any() && hasErrors) { string fieldType = ""; bool firstTime = true; <div id="addressValidatorsContainer" class="hidden"> <div id="addressValidators"> @RenderSnippet("TitleChange") @foreach(LoopItem av in addressValidators) { @* string errorMessage = av.GetString("Ecom:Order.AddressValidator.ErrorMessage"); *@ string errorMessage = Translate(av.GetString("Ecom:Order.AddressValidator.ErrorMessage")); if(!string.IsNullOrWhiteSpace(errorMessage)){ <span class="addressValidationError">@errorMessage</span> @SnippetStart("TitleChange") <h2>@Translate("error", "Error")</h2> @SnippetEnd("TitleChange") break; } else if(firstTime) { firstTime = false; @SnippetStart("TitleChange") <h2>@Translate("pleaseSelectTheChanges", "Please select the changes")</h2> <label for="changeAll"><input id="changeAll" name="changeAll" type="checkbox">@Translate("all", "All")</label> @SnippetEnd("TitleChange") } foreach(LoopItem af in av.GetLoop("AddressFields")) { string oldValue = af.GetString("Ecom:Order.AddressValidator.Field.OldValue"), newValue = af.GetString("Ecom:Order.AddressValidator.Field.NewValue"), type = af.GetString("Ecom:Order.AddressValidator.AddressType"), field = af.GetString("Ecom:Order.AddressValidator.Field.Type"), id = field + type; if(fieldType != type) { fieldType = type; string title = fieldType == "Billing" ? Translate("billingAddress","Billing Address") : Translate("shippingAddress","Shipping Address") ; <h3 class="col-xs-12 noPadding">@title</h3> } <div class="col-xs-12 noPadding addressChange" data-type="@type"> <span class="col-xs-12 noPadding">@field</span> <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> </div> } if (!addressesAreDifferent) { break; } } </div> </div> } @* 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"); 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"); bool addressesAreDifferent = deliveryAddress != customerAddress; List<LoopItem> addressValidators = GetLoop("AddressValidators"); if(addressValidators.Any()) { string fieldType = ""; bool firstTime = true; <div id="addressValidatorsContainer" class="hidden"> <div id="addressValidators"> @RenderSnippet("TitleChange") @foreach(LoopItem av in addressValidators) { string errorMessage = av.GetString("Ecom:Order.AddressValidator.ErrorMessage"); if(!string.IsNullOrWhiteSpace(errorMessage)){ <span class="addressValidationError">@errorMessage</span> @SnippetStart("TitleChange") <h2>@Translate("error", "Error")</h2> @SnippetEnd("TitleChange") break; } else if(firstTime) { firstTime = false; @SnippetStart("TitleChange") <h2>@Translate("pleaseSelectTheChanges", "Please select the changes")</h2> <label for="changeAll"><input id="changeAll" name="changeAll" type="checkbox">@Translate("all", "All")</label> @SnippetEnd("TitleChange") } foreach(LoopItem af in av.GetLoop("AddressFields")) { string oldValue = af.GetString("Ecom:Order.AddressValidator.Field.OldValue"), newValue = af.GetString("Ecom:Order.AddressValidator.Field.NewValue"), type = af.GetString("Ecom:Order.AddressValidator.AddressType"), field = af.GetString("Ecom:Order.AddressValidator.Field.Type"), id = field + type; if(fieldType != type) { fieldType = type; string title = fieldType == "Billing" ? Translate("billingAddress","Billing Address") : Translate("shippingAddress","Shipping Address") ; <h3 class="col-xs-12 noPadding">@title</h3> } <div class="col-xs-12 noPadding addressChange" data-type="@type"> <span class="col-xs-12 noPadding">@field</span> <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> </div> } if (!addressesAreDifferent) { break; } } </div> </div> } *@ string showDeliveryAddress = addressesAreDifferent && !string.IsNullOrEmpty(deliveryEmail) ? "" : "hide"; customerCountry = customerCountry != "" ? customerCountry : Dna.IP.Frontend.GetCountryCode(); Dynamicweb.Content.Items.Item itemArea = Pageview.Area.Item; Dictionary<string, Dictionary<string, string>> addressesId = new Dictionary<string, Dictionary<string, string>>(); List<LoopItem> userAddresses = GetLoop("UserManagement:User.UserAddresses"); if(System.Web.HttpContext.Current.Request.Cookies["checkout"] != null) { System.Web.HttpCookie cookie2 = new System.Web.HttpCookie("checkout"); cookie2.Expires = DateTime.Now.AddDays(-1d); System.Web.HttpContext.Current.Response.Cookies.Add(cookie2); } } <style> .DMForms .bootstrap-select > .btn::before { content: ""; background-color: rgba(255, 0, 0, 0.59); position: absolute; top: 0; left: 0; bottom: 0; z-index: 2; right: 0; } .bootstrap-select.btn-group .btn .caret { display:none; } </style> <div id="cartFormContainer" class="col-xs-12 noPadding"> <h2 class="cartDetail">@Translate("customerDetails", "Customer details") </h2> <div class="col-xs-12 col-sm-8 col-md-9 noPaddingLeft"> @if(System.Web.HttpContext.Current.Request.Params["error"] == null && GetInteger("Ecom:Order.OrderLines.TotalProductQuantity") > 0){ <form class="DMForms" action='/Default.aspx?ID=@Pageview.Page.ID' name="ordersubmit" id="customerInfo" method="post"> <input type="hidden" id="updater" data-next='@GetString("CartV2.NextStepButtonName")' name="@GetString("CartV2.NextStepButtonName")" value="@Translate("continueCheckout", "Continue Checkout")" /> <div class="continueButton col-xs-12 topButton"> <input class="btn btn-bg pull-right" type="submit" value="@Translate("continueCheckout", "Continue Checkout")"> </div> <div id="formContainer" class="blockCart col-xs-12 noPadding"> <div class="hide"> <input id="EcomOrderCustomerAccepted" name="EcomOrderCustomerAccepted" checked type="checkbox"> </div> <h2 class="smallTitle">@Translate("deliveryAddress", "Delivery Address")</h2> <div id="customerInformation" class="part col-xs-12 noPadding"> @if(userAddresses.Any()) { <fieldset class="Select"> <label for="selectAddress">@Translate("myAddresses", "My Addresses")</label> <div class="select"> <select data-live-search="true" name="selectAddress" id="selectAddress"> @foreach (LoopItem userAddress in userAddresses) { Dictionary<string, string> addresses = new Dictionary<string, string>(); string selected = userAddress.GetBoolean("UserManagement:User.UserAddress.Default") ? "selected" : "" ; addresses.Add("EcomOrderCustomerAddress", userAddress.GetString("UserManagement:User.UserAddress.Address")); addresses.Add("EcomOrderCustomerAddress2", userAddress.GetString("UserManagement:User.UserAddress.Address2")); addresses.Add("EcomOrderCustomerZip", userAddress.GetString("UserManagement:User.UserAddress.Zip")); addresses.Add("EcomOrderCustomerCity", userAddress.GetString("UserManagement:User.UserAddress.City")); addresses.Add("EcomOrderCustomerCountry", userAddress.GetString("UserManagement:User.UserAddress.Country")); addresses.Add("EcomOrderCustomerRegion", userAddress.GetString("UserManagement:User.UserAddress.State")); addressesId.Add(userAddress.GetString("UserManagement:User.UserAddress.ID"), addresses); <option @selected value="@(userAddress.GetString("UserManagement:User.UserAddress.ID"))">@userAddress.GetString("UserManagement:User.UserAddress.Address")</option> } </select> </div> </fieldset> }else{ customerAddress = GetString("Ecom:Order.Customer.Address") != "" ? GetString("Ecom:Order.Customer.Address") : GetString("UserManagement:User.DefaultAddress.Address"); deliveryAddress = GetString("Ecom:Order.Delivery.Address") != "" ? GetString("Ecom:Order.Delivery.Address") : customerAddress; <fieldset class="Select"> <label for="selectAddress">@Translate("myAddresses", "My Addresses")</label> <div class="select"> @{ Dictionary<string, string> addresses = new Dictionary<string, string>(); addresses.Add("EcomOrderCustomerAddress", GetString("UserManagement:User.DefaultAddress.Address")); addresses.Add("EcomOrderCustomerAddress2", GetString("UserManagement:User.DefaultAddress.Address2")); addresses.Add("EcomOrderCustomerZip", GetString("UserManagement:User.DefaultAddress.Zip")); addresses.Add("EcomOrderCustomerCity", GetString("UserManagement:User.DefaultAddress.City")); addresses.Add("EcomOrderCustomerCountry", GetString("UserManagement:User.DefaultAddress.Country")); addresses.Add("EcomOrderCustomerRegion", GetString("UserManagement:User.DefaultAddress.State")); } <select data-live-search="true" name="selectAddress" id="selectAddress"> <option selected value="">@GetString("UserManagement:User.DefaultAddress.Address") @GetString("UserManagement:User.DefaultAddress.Zip") @GetString("UserManagement:User.DefaultAddress.State") @GetString("UserManagement:User.DefaultAddress.City")</option> </select> </div> </fieldset> } <fieldset class="readonly"> <label for="EcomOrderCustomerEmail">@Translate("email", "Email")</label> <input type="email" name="EcomOrderCustomerEmail" id="EcomOrderCustomerEmail" value='@(GetString("UserManagement:SecondaryUser.Email"))' readonly/> @*<div class="note">@Translate("receiptWillBeSentToEmail", "A receipt will be sent to this address")</div>*@ </fieldset> <input type="hidden" name="EcomOrderCustomerName" id="EcomOrderCustomerName" value="@(GetString("Ecom:Order.Customer.Name"))" /> <input type="hidden"name="EcomOrderCustomerFirstName" id="EcomOrderCustomerFirstName" value="@GetString("Ecom:Order.Customer.FirstName")" /> <input type="hidden"name="EcomOrderCustomerSurname" id="EcomOrderCustomerSurname" value="@GetString("Ecom:Order.Customer.Surname")"/> @Fieldset("readonly", "EcomOrderCustomerCompany", @Translate("company", "Company"), "text", @GetString("Ecom:Order.Customer.Company"), "") @Fieldset("readonly", "EcomOrderCustomerAddress", @Translate("billingAddress", "Address"), "text", @customerAddress,"readonly") @Fieldset("readonly", "EcomOrderCustomerAddress2", @Translate("secondAddressLine", "Address 2"), "text", @GetString("Ecom:Order.Customer.Address2"),"readonly") @Fieldset("readonly", "EcomOrderCustomerCity", @Translate("city", "City"), "text", @customerCity,"readonly") <fieldset class="Select readonly region" data-region="@customerRegion"> <label for="EcomOrderCustomerRegion" data-text="@Translate("stateProvince", "State / Province")" data-textUS="@Translate("state", "State")" data-textCA="@Translate("province", "Province")">@Translate("stateProvince", "State / Province")</label> <div class="select region"> <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")"> <option class="defaultOption" value="">@Translate("stateProvince", "State / Province")</option> </select> </div> </fieldset> <fieldset class="readonly"> <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> <input type="text" name="EcomOrderCustomerZip" id="EcomOrderCustomerZip" value="@customerZip" readonly/> </fieldset> <fieldset class="readonly Select country"> <label for="EcomOrderCustomerCountry">@Translate("country", "Country")</label> <div class="select country"> <select data-live-search="true" id="EcomOrderCustomerCountry" name="EcomOrderCustomerCountry" data-size="8"> <option value="">@Translate("country", "Country")</option> @RenderSnippet("highlightedContries") </select> </div> </fieldset> @Fieldset("readonly", "EcomOrderCustomerPhone", @Translate("phone", "Phone"), "text", @GetString("Ecom:Order.Customer.Phone"),"readonly") </div> @*shipping address*@ <div id="deliveryAddress" class="part col-xs-12 noPadding blockCart hidden"> <div id="sameAddress"> <h2>@Translate("shippingAddress", "Shipping Address")</h2> <div class="chooseDelivery"> <span class="col-xs-12 noPadding">@Translate("isTheAddressAbove","Is the address above also the shipping address")</span> <label> <input value="no" type="radio" name="deliveryaddress" @(deliveryAddress == customerAddress || string.IsNullOrEmpty(deliveryEmail) ? "checked" : "") /> @Translate("yes", "Yes") </label> <label> <input value="yes" type="radio" name="deliveryaddress" @(deliveryAddress != customerAddress && !string.IsNullOrEmpty(deliveryEmail) ? "checked" : "") /> @Translate("no", "No") </label> </div> </div> <div class="@showDeliveryAddress" id="deliveryFormContainer"> @if(userAddresses.Any()) { <fieldset class="Select"> <label for="selectAddress2">@Translate("myAddresses", "My Addresses")</label> <div class="select"> <select data-live-search="true" name="selectAddress2" id="selectAddress2"> @foreach (LoopItem userAddress in userAddresses) { string selected = userAddress.GetBoolean("UserManagement:User.UserAddress.Default") ? "selected" : "" ; <option @selected value="@(userAddress.GetString("UserManagement:User.UserAddress.ID"))">@userAddress.GetString("UserManagement:User.UserAddress.Address")</option> } </select> </div> </fieldset> } @Fieldset("", "EcomOrderDeliveryFirstName", @Translate("attention", "Attention"), "text", @GetString("Ecom:Order.Delivery.FirstName"),"readonly") @Fieldset("", "EcomOrderDeliveryEmail", @Translate("email", "Email"), "email", @deliveryEmail,"readonly") @Fieldset("mandatory", "EcomOrderDeliveryAddress", @Translate("address", "Address"), "text", @deliveryAddress,"readonly") @Fieldset("", "EcomOrderDeliveryAddress2", @Translate("secondAddressLine", "Address 2"), "text", @GetString("Ecom:Order.Delivery.Address2"),"readonly") @Fieldset("mandatory", "EcomOrderDeliveryCity", @Translate("city", "City"), "text", @deliveryCity,"readonly") <fieldset class="Select" data-region="@deliveryRegion"> <label for="EcomOrderDeliveryRegion" data-text="@Translate("stateProvince", "State / Province")" data-textUS="@Translate("state", "State")" data-textCA="@Translate("province", "Province")">@Translate("stateProvince", "State / Province")</label> <div class="select"> <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")"> <option value="">@Translate("stateProvince", "State / Province")</option> </select> </div> </fieldset> <fieldset class="mandatory"> <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> <input type="text" name="EcomOrderDeliveryZip" id="EcomOrderDeliveryZip" value="@deliveryZip" /> </fieldset> <fieldset class="mandatory Select"> <label for="EcomOrderDeliveryCountry">@Translate("country", "Country")</label> <div class="select"> <select data-live-search="true" id="EcomOrderDeliveryCountry" name="EcomOrderDeliveryCountry" data-size="8"> <option value="">@Translate("country", "Country")</option> @RenderSnippet("highlightedContries") </select> </div> </fieldset> @Fieldset("mandatory", "EcomOrderDeliveryPhone", @Translate("phone", "Phone"), "text", @deliveryPhone,"readonly") </div> </div> </div> </form> <div class="continueButton col-xs-12 bottom"> <a class="btn btn-bg pull-right" type="submit" href="javascript:document.getElementById('customerInfo').submit();">@Translate("continueCheckout", "Continue Checkout")</a> <div id="promoCodeContainer" class="pull-left"> <span>@Translate("voucherCodeText", "Enter a Voucher Code:")</span> <form class="cartPromo" method="POST" action="/Default.aspx?ID=@Pageview.Page.ID"> @{ string invalid = Translate("invalidPromotionCode", "We’re sorry, this promotion code is invalid. Please try again."); string inactive = Translate("inactivePromotionCode", "We're sorry, this promotion code is not yet active."); string expired = Translate("expiredPromotionCode", "We're sorry, this promotion code has expired."); } @if(GetString("Ecom:Order.Customer.VoucherCode") == "") { <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' /> <button class="submitVoucher btn btn-bg" type="submit"> @Translate("apply", "Apply") </button> } else { <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 /> <button class="cancelVoucher btn btn-black" type="button"> @Translate("removeVoucher", "Remove") </button> } </form> @GetString("Ecom:Cart.ValidationError.EcomOrderVoucherCode.ErrorMessage") </div> </div> <div class="col-xs-12 col-sm-7 noPadding-xs"> </div> } else if(System.Web.HttpContext.Current.Request.Params["error"] != null){ @*Validation errors*@ foreach (LoopItem validationError in GetLoop("ValidationErrors")){ errors += validationError.GetString("Ecom:Cart.ValidationError.ErrorMessage") + "--"; errorsID += validationError.GetString("Ecom:Cart.ValidationError.FieldSystemName") + "--"; } foreach(LoopItem av in GetLoop("AddressValidators")) { errors += av.GetString("Ecom:Order.AddressValidator.ErrorMessage"); errorsID += av.GetString("Ecom:Order.AddressValidator.FieldSystemName") + "--"; } errors = HttpUtility.JavaScriptStringEncode(errors); <div data-errorid="@errorsID" id="error">@errors</div> } else if(GetInteger("Ecom:Order.OrderLines.TotalProductQuantity")==0){ System.Web.HttpContext.Current.Response.Redirect("/"); } </div> @using Dynamicweb.Ecommerce.Orders; @using Dynamicweb.Rendering; @using System.Linq; @using System.Collections.Specialized; @functions{ private string OrderType(string orderType, bool isProduct, string productId, bool productPriceIsZeroBool, string productPriceIsZero, string discountType, string parentLineId, string voucherValue, bool loadedVoucherBool ){ bool isDiscount = false; if (orderType == "3" || orderType == "1") { isDiscount = true; if (isProduct) { discountType = "offerProduct"; } else { discountType = "offerValue"; } } if (isDiscount && voucherValue != "") { discountType = "offerVoucher"; } return discountType; } } @using Dna.Forney.Ecommerce; @{ var permissions = PermissionsFacade.GetPermissions(); @* string userType = permissions.Type.ToString(); *@ string orderFromExcelLink = "/Default.aspx?ID=195"; bool AccessToConsumerProductSet = permissions.AccessToConsumerProductSet, AccessToDealerProductSet4KProducts = permissions.AccessToDealerProductSet4KProducts, AccessToIndustrialProProductSet9KProducts = permissions.AccessToIndustrialProProductSet9KProducts, DisplayMsrpPricing = permissions.DisplayMsrpPricing, DisplayMsrpPricingPlus = permissions.DisplayMsrpPricingPlus, DisplayAccountSpecificTradeAgreementPricing = permissions.DisplayAccountSpecificTradeAgreementPricing, DisplayQuantityDiscounts = permissions.DisplayQuantityDiscounts, DisplayGreenbackRebateLinkButton = permissions.DisplayGreenbackRebateLinkButton, AbilityToViewShippingAddress = permissions.AbilityToViewShippingAddress, AbilityToUpdateShippingAndBillingAddress = permissions.AbilityToUpdateShippingAndBillingAddress, CreditCardPayments = permissions.CreditCardPayments, PoPayments = permissions.PoPayments, UpsShippingMethod = permissions.UpsShippingMethod, ShipMethodIncludingLtlDeterminedByForneyRep = permissions.ShipMethodIncludingLtlDeterminedByForneyRep, ShipCancelOrBackorderDisplay = permissions.ShipCancelOrBackorderDisplay, AbilityToCreateAccountsOnline = permissions.AbilityToCreateAccountsOnline, DisplayTotalPricingOnPastOrders = permissions.DisplayTotalPricingOnPastOrders, DisplayPoNumberOnPastOrders = permissions.DisplayPoNumberOnPastOrders, AbilityToDownloadOrdersAsCsv = permissions.AbilityToDownloadOrdersAsCsv, HasZipcode = !string.IsNullOrEmpty(UserFacade.GetZipCode())? true : false, @* isDealer = (userType == "Dealer" || userType == "IndPro") ? true : false, *@ CanOrderFromExcel = permissions.Type.ToString() == "Dealer" || permissions.Type.ToString() == "IndPro" ? true : false; var zipCode = UserFacade.GetZipCode(); } @{ double subtotalNum = GetDouble("Ecom:Order.PriceWithoutDiscountsOrTaxes.Price") - GetDouble("Ecom:Order.ShippingFee.PriceWithoutVAT"); string subtotalString = GetString("Ecom:Order.Currency.Symbol") + subtotalNum.ToString("#,##.00"); } <div id="cartRightContent" class="col-xs-12 col-sm-4 col-md-3 noPaddingRight"> <h2>@Translate("orderSummary", "Order Summary")</h2> @if(orderLines.Any()) { string currency = GetString("Ecom:Order.Price.Currency.Symbol"); <ul class="col-xs-12 noPadding rightColProducts"> @if(!string.IsNullOrWhiteSpace(GetString("Ecom:Order.Delivery.Address"))) { <li class="col-xs-12 noPadding longContainer"> @if(deliveryAddress == customerAddress) { <h3 class="col-xs-12 rightTitle"> @Translate("billingShippingAddress","Billing & Shipping Address") </h3> <div class="col-xs-12"> @GetString("Ecom:Order.Delivery.Address") @GetString("Ecom:Order.Delivery.Address2") <br/> @GetString("Ecom:Order.Delivery.City"), @GetString("Ecom:Order.Delivery.Region") @GetString("Ecom:Order.Delivery.Zip"), @GetString("Ecom:Order.Delivery.Country") </div> } else { if(!CanOrderFromExcel){ <h3 class="col-xs-12 rightTitle"> @Translate("billingAddress","Billing Address") </h3> <div class="col-xs-12"> @GetString("Ecom:Order.Customer.Address") @GetString("Ecom:Order.Customer.Address2") <br/> @GetString("Ecom:Order.Customer.City"), @GetString("Ecom:Order.Customer.Region") @GetString("Ecom:Order.Customer.Zip"), @GetString("Ecom:Order.Customer.Country") </div> } <h3 class="col-xs-12 rightTitle"> @Translate("shippingAddress","Shipping Address") </h3> <div class="col-xs-12"> @GetString("Ecom:Order.Delivery.Address") @GetString("Ecom:Order.Delivery.Address2") <br/> @GetString("Ecom:Order.Delivery.City"), @GetString("Ecom:Order.Delivery.Region") @GetString("Ecom:Order.Delivery.Zip")<br/> @GetString("Ecom:Order.Delivery.Country") </div> } </li> } @if(!string.IsNullOrWhiteSpace(GetString("Ecom:Order.Delivery.Address"))) { <li class="col-xs-12 noPadding longContainer"> <h3 class="col-xs-12">@Translate("orderDetails","Order Details")</h3> </li> } @foreach (LoopItem orderLine in orderLines) { bool isProduct = orderLine.GetBoolean("Ecom:Order:OrderLine.IsProduct"), productPriceIsZeroBool = orderLine.GetBoolean("Ecom:Order:OrderLine.Price.IsZero"), isDiscount = false; string parentLineId = orderLine.GetString("Ecom:Order:OrderLine.ParentLineID"), orderType = orderLine.GetString("Ecom:Order:OrderLine.Type"), discountType = "", productPriceIsZero = orderLine.GetString("Ecom:Order.Price.PricePIP"), productId = orderLine.GetString("Ecom:Order:OrderLine.ProductID"), priceWithoutVATFormatted = orderLine.GetString("Ecom:Order:OrderLine.Price.PriceWithoutVATFormatted"), totalPriceWithProductDiscounts = orderLine.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts"), variantText = orderLine.GetString("Ecom:Order:OrderLine.ProductVariantText"); discountType = OrderType(orderType, isProduct, productId, productPriceIsZeroBool, productPriceIsZero, discountType, parentLineId, voucherValue, false ); if(discountType == "" && isProduct) { <li class="col-xs-12 noPadding"> <div> <h3 class="col-xs-8"> @orderLine.GetString("Ecom:Order:OrderLine.ProductName") @if(!string.IsNullOrEmpty(variantText)){ <br/> <span>@variantText</span> } </h3> @if( priceWithoutVATFormatted != totalPriceWithProductDiscounts ) { <span class="col-xs-4 text-right">@orderLine.GetString("Ecom:Order:OrderLine.Price.PriceWithoutVATFormatted")</span> } </div> <div> <span class="col-xs-6">@Translate("qty", "Qty"): @orderLine.GetString("Ecom:Order:OrderLine.Quantity")</span> <span class="col-xs-6 text-right bold">@orderLine.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts")</span> </div> </li> } } <li class="col-xs-12 noPadding"> @if(GetDouble("Ecom:Order.RewardTotalPoints") > 0) { <div class="col-xs-12">@Translate("loyaltyPointsEarned","Loyalty Points Earned") @GetString("Ecom:Order.RewardTotalPoints")</div> } <ul> <li class="clearfix" style="width: 100%;"> <div class="col-xs-6"><b>@Translate("subTotal", "Subtotal")</b></div> <div class="col-xs-6 text-right"><b>@subtotalString</b></div> </li> @if(GetString("Ecom:Order.OrderLines.TotalDiscount") != (currency+"0.00")) { <li class="clearfix" style="width: 100%;"> <div class="col-xs-6">@Translate("discount", "Discount")</div> <div class="col-xs-6 text-right">@GetString("Ecom:Order.OrderLines.TotalDiscount")</div> </li> } @if(GetString("Ecom:Order.Taxes.Total.Price") != "0.00") { <li class="clearfix" style="width: 100%;"> <div class="col-xs-6">@Translate("taxes", "Taxes")</div> <div class="col-xs-6 text-right">@GetString("Ecom:Order.Taxes.Total")</div> </li> } </ul> @if(GetDouble("Ecom:Order.TotalPoints") > 0) { <div class="col-xs-12">@GetString("Ecom:Order.TotalPoints") @Translate("LoyaltyPointsSpent","Loyalty Points Spent")</div> } </li> <li class="col-xs-12 totalContainer"> <b class="col-xs-6">@Translate("total", "Total")</b> <b class="col-xs-6 text-right">@GetString("Ecom:Order.OrderLines.Total.PriceWithoutVAT")</b> </li> </ul> if(GetBoolean("Ecom:Order.ShippingFee.IsZero") && !CanOrderFromExcel){ <small class="col-xs-12">* @Translate("taxesCalculatedCheckoutDealers", "Taxes and Shipping Calculated at Checkout")</small> } <div id="editOrderButton" class="col-xs-12 text-center"> <a class="btn btn-bg" href='@itemArea["ShowCart"]'>@Translate("editOrder","Edit order")</a> </div> } </div> </div> @{ foreach (LoopItem country in GetLoop("Countries")) { if(country.GetString("Ecom:Country.Code2") == "CA" || country.GetString("Ecom:Country.Code2")== "US"){ @SnippetStart("highlightedContries") <option value="@(country.GetString("Ecom:Country.Code2"))"> @country.GetString("Ecom:Country.Name") </option> @SnippetEnd("highlightedContries") } @* <option value="@(country.GetString("Ecom:Country.Code2"))"> @country.GetString("Ecom:Country.Name") </option> *@ } } @helper DisplayCountries(bool firstTime){ @*@RenderSnippet("highlightedContries") foreach (LoopItem country in GetLoop("Countries")) { if(firstTime) { if(country.GetString("Ecom:Country.Code2") == "CA" || country.GetString("Ecom:Country.Code2")== "US"){ @SnippetStart("highlightedContries") <option value="@(country.GetString("Ecom:Country.Code2"))"> @country.GetString("Ecom:Country.Name") </option> @SnippetEnd("highlightedContries") } } <option value="@(country.GetString("Ecom:Country.Code2"))"> @country.GetString("Ecom:Country.Name") </option> } if(firstTime) { @SnippetStart("highlightedContries") <option disabled="disabled" value=""> ---------------- </option> @SnippetEnd("highlightedContries") }*@ } @helper DisplayRegions(){ Dictionary<string, dynamic> locations = new Dictionary<string, dynamic>(); string productJSON = ""; locations.Add("locations", new Dictionary<string, dynamic>()); locations["locations"].Add("Countries", new List<dynamic>()); foreach (LoopItem ct in GetLoop("Countries")) { List<LoopItem> regionsList = ct.GetLoop("Regions"); Dictionary<string, dynamic> countryDict = new Dictionary<string, dynamic>(); Dictionary<string, dynamic> countryKey = new Dictionary<string, dynamic>(); countryKey.Add("id", ct.GetString("Ecom:Country.Code2")); countryKey.Add("regions", new List<dynamic>()); foreach (LoopItem region in regionsList.OrderBy(s => s.GetString("Ecom:Region.Name"))) { Dictionary<string, string> regionsDict = new Dictionary<string, string>(); regionsDict.Add("name", region.GetString("Ecom:Region.Name")); regionsDict.Add("code", region.GetString("Ecom:Region.RegionCode")); countryKey["regions"].Add(regionsDict); } countryDict.Add("country", countryKey); locations["locations"]["Countries"].Add(countryDict); } productJSON = new JavaScriptSerializer().Serialize(locations); @productJSON } @functions { public static string toJson(Dictionary<string, Dictionary<string, string>> obj_dictionary) { var json = new JavaScriptSerializer().Serialize(obj_dictionary); return json; } } @SnippetStart("jsOnLoad") onLoadCartStep1( { errors:{ str_errors : "@errors", str_errorsID : "@errorsID" }, str_alertErrors : "@alertErrors", submitedValues : { str_customerCountry : "@customerCountry", str_deliveryCountry : "@customerCountry", //"@GetString("Ecom:Order.Delivery.Country.Code")", str_customerRegion : "@customerRegion", str_deliveryRegion : "@GetString("Ecom:Order.Delivery.Region")" }, regions : '@DisplayRegions()', addresses : '@toJson(addressesId)' }); //$(function () { //$('#EcomOrderCustomerRegion button[type="button"]').prop('disabled', true) //}); @SnippetEnd("jsOnLoad") @helper Fieldset(string className, string labelFor, string labelText, string inputType, string value, string readOnly) { <fieldset class="@className"> <label for="@labelFor">@labelText</label> <input type="@inputType"name="@labelFor" id="@labelFor" value="@value" @readOnly/> </fieldset> }