Error compiling template "Designs/Swift/eCom7/CartV2/Step/InformationUser.cshtml" Line 13: The using directive for 'System.IO' appeared previously in this namespace Line 16: The using directive for 'Dynamicweb' appeared previously in this namespace Line 18: The using directive for 'Dynamicweb.Ecommerce.Orders' appeared previously in this namespace Line 22: The using directive for 'System.Text.RegularExpressions' appeared previously in this namespace Line 24: The using directive for 'System.Text' appeared previously in this namespace Line 109: The name 'RenderAddressUser' does not exist in the current context Line 157: The name 'helper' does not exist in the current context Line 254: The name 'userAccountPage' does not exist in the current context Line 261: The name 'hideEditShippingAddress' does not exist in the current context Line 265: The name 'userAddressesPage' does not exist in the current context Line 283: The name 'useBillingIsChecked' does not exist in the current context Line 287: The name 'disabled' does not exist in the current context Line 291: The name 'disabled' does not exist in the current context Line 295: The name 'disabled' does not exist in the current context Line 299: The name 'disabled' does not exist in the current context Line 303: The name 'disabled' does not exist in the current context Line 307: The name 'disabled' does not exist in the current context Line 311: The name 'disabled' does not exist in the current context Line 315: The name 'disabled' does not exist in the current context Line 319: The name 'disabled' does not exist in the current context Line 323: The name 'disabled' does not exist in the current context Line 327: The name 'userAddressLoop' does not exist in the current context Line 361: The name 'userAddressSelected' does not exist in the current context Line 361: The name 'selectedAddress' does not exist in the current context Line 381: The name 'isStandardSwiftTemplates' does not exist in the current context
1 // <auto-generated/> 2 #pragma warning disable 1591 3 namespace CompiledRazorTemplates.Dynamic 4 { 5 #line hidden 6 using System.Threading.Tasks; 7 using System; 8 using System.Linq; 9 using Dynamicweb; 10 using Dynamicweb.Rendering; 11 using System.IO; 12 using Dynamicweb.Environment; 13 using System.IO; 14 using Dynamicweb.Ecommerce.Cart; 15 using Dynamicweb.Ecommerce.Orders; 16 using Dynamicweb; 17 using Dynamicweb.Ecommerce.ProductCatalog; 18 using Dynamicweb.Ecommerce.Orders; 19 using System.Text.RegularExpressions; 20 using System.Text; 21 using System.Collections.Generic; 22 using System.Text.RegularExpressions; 23 using Dynamicweb.Ecommerce.International; 24 using System.Text; 25 internal class RazorEngine_ae193b209d3e47a8b5f2988215d0dade : Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 26 { 27 #pragma warning disable 1998 28 public async override global::System.Threading.Tasks.Task ExecuteAsync() 29 { 30 WriteLiteral("\n"); 31 string googleTagManagerID = Pageview.AreaSettings.GetString("GoogleTagManagerID"); string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID"); bool allowTracking = true; if (CookieManager.IsCookieManagementActive) { var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical")); } List<string> addressList = new List<string>(); if (!string.IsNullOrEmpty(GetString("UserManagement:User.Address"))) { addressList.Add(GetString("UserManagement:User.Address")); } if (!string.IsNullOrEmpty(GetString("UserManagement:User.Zip"))) { addressList.Add(GetString("UserManagement:User.Zip")); } if (!string.IsNullOrEmpty(GetString("UserManagement:User.City"))) { addressList.Add(GetString("UserManagement:User.City")); } string addressString = (string.Join(",", addressList.Select(x => x.ToString()).ToArray())); var themeRaw = Pageview.CurrentParagraph.Item["Theme"]?.ToString(); string theme = !string.IsNullOrEmpty(themeRaw) ? " theme " + themeRaw.Replace(" ", "").Trim().ToLower() : ""; WriteLiteral("\n<div class=\"grid gap-0 h-100\">\n\t<div"); 32 BeginWriteAttribute("class", " class=\"", 1487, "\"", 1584, 10); 33 WriteAttributeValue("", 1495, "g-col-12", 1495, 8, true); 34 WriteAttributeValue(" ", 1503, "g-col-lg-8", 1504, 11, true); 35 WriteAttributeValue(" ", 1514, "p-3", 1515, 4, true); 36 WriteAttributeValue(" ", 1518, "p-lg-4", 1519, 7, true); 37 WriteAttributeValue(" ", 1525, "pe-xl-5", 1526, 8, true); 38 WriteAttributeValue(" ", 1533, "ps-xl-6", 1534, 8, true); 39 WriteAttributeValue(" ", 1541, "ps-xxl-8", 1542, 9, true); 40 WriteAttributeValue(" ", 1550, "order-last", 1551, 11, true); 41 WriteAttributeValue(" ", 1561, "order-lg-first", 1562, 15, true); 42 WriteAttributeValue("", 1576, theme, 1576, 8, false); 43 EndWriteAttribute(); 44 WriteLiteral(">\n\t\t<form name=\"ordersubmit\" id=\"ordersubmit\" method=\"post\" autocomplete=\"off\" style=\"max-width: 65rem; margin-left: auto;\">\n\n"); 45 Write(RenderLogo()); 46 Write(RenderStepsBreadcrumbs()); 47 Write(RenderErrors()); 48 Write(RenderStepSummary()); 49 WriteLiteral("\n\t\t\t<input type=\"hidden\" id=\"CurrentStep\">\n\t\t\t<input type=\"hidden\" name=\"EcomOrderCustomerEmail\""); 50 BeginWriteAttribute("value", " value=\"", 1914, "\"", 1961, 1); 51 WriteAttributeValue("", 1922, GetString("UserManagement:User.Email"), 1922, 39, false); 52 EndWriteAttribute(); 53 WriteLiteral(">\n\t\t\t<input type=\"hidden\" name=\"EcomOrderCustomerPhone\""); 54 BeginWriteAttribute("value", " value=\"", 2017, "\"", 2064, 1); 55 WriteAttributeValue("", 2025, GetString("UserManagement:User.Phone"), 2025, 39, false); 56 EndWriteAttribute(); 57 WriteLiteral(">\n\t\t\t<input type=\"hidden\" name=\"EcomOrderCustomerCompany\""); 58 BeginWriteAttribute("value", " value=\"", 2122, "\"", 2171, 1); 59 WriteAttributeValue("", 2130, GetString("UserManagement:User.Company"), 2130, 41, false); 60 EndWriteAttribute(); 61 WriteLiteral(">\n\t\t\t<input type=\"hidden\" name=\"EcomOrderCustomerAddress\""); 62 BeginWriteAttribute("value", " value=\"", 2229, "\"", 2278, 1); 63 WriteAttributeValue("", 2237, GetString("UserManagement:User.Address"), 2237, 41, false); 64 EndWriteAttribute(); 65 WriteLiteral(">\n\t\t\t<input type=\"hidden\" name=\"EcomOrderCustomerZip\""); 66 BeginWriteAttribute("value", " value=\"", 2332, "\"", 2377, 1); 67 WriteAttributeValue("", 2340, GetString("UserManagement:User.Zip"), 2340, 37, false); 68 EndWriteAttribute(); 69 WriteLiteral(">\n\t\t\t<input type=\"hidden\" name=\"EcomOrderCustomerCity\""); 70 BeginWriteAttribute("value", " value=\"", 2432, "\"", 2478, 1); 71 WriteAttributeValue("", 2440, GetString("UserManagement:User.City"), 2440, 38, false); 72 EndWriteAttribute(); 73 WriteLiteral(">\n\t\t\t<input type=\"hidden\" name=\"EcomOrderCustomerRegion\""); 74 BeginWriteAttribute("value", " value=\"", 2535, "\"", 2582, 1); 75 WriteAttributeValue("", 2543, GetString("UserManagement:User.State"), 2543, 39, false); 76 EndWriteAttribute(); 77 WriteLiteral(">\n\t\t\t<input type=\"hidden\" name=\"EcomOrderCustomerCountry\""); 78 BeginWriteAttribute("value", " value=\"", 2640, "\"", 2693, 1); 79 WriteAttributeValue("", 2648, GetString("UserManagement:User.CountryCode"), 2648, 45, false); 80 EndWriteAttribute(); 81 WriteLiteral(">\n\n"); 82 Write(RenderAddressUser()); 83 WriteLiteral("\n"); 84 if (!string.IsNullOrWhiteSpace(addressString)) { { Write(RenderStepsNavigation()); 85 } } WriteLiteral("\t\t</form>\n\t</div>\n\n"); 86 Write(RenderSummarySidebar()); 87 WriteLiteral("\n</div>\n\n<script>\n\tfunction submitForm() {\n\t\tdocument.querySelector(\"#CurrentStep\").name = \""); 88 Write(GetString("CartV2.CurrentStepButtonName")); 89 WriteLiteral("\";\n\t\tswift.PageUpdater.Update(document.querySelector(\"#ordersubmit\"));\n\t}\n</script>\n\n\n"); 90 if ((!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) || !string.IsNullOrWhiteSpace(googleTagManagerID)) && allowTracking) { WriteLiteral("\t<script>\n\t\tgtag(\"event\", \"begin_checkout\", {\n\t\t\tcurrency: \""); 91 Write(GetString("Ecom:Order.CurrencyCode")); 92 WriteLiteral("\",\n\t\t\tvalue: "); 93 Write(GetDouble("Ecom:Order.Price.Price.Value").ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)); 94 WriteLiteral(",\n\t\t\titems: [\n"); 95 foreach (LoopItem orderline in GetLoop("OrderLines")) { WriteLiteral("\n\t\t\t\t\t{\n\t\t\t\t\t\titem_id: \""); 96 Write(orderline.GetString("Ecom:Order:OrderLine.ProductID")); 97 WriteLiteral("\",\n\t\t\t\t\t\titem_name: \""); 98 Write(Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(orderline.GetString("Ecom:Order:OrderLine.ProductName"))); 99 WriteLiteral("\",\n\t\t\t\t\t\tcurrency: \""); 100 Write(orderline.GetString("Ecom:Order:OrderLine.UnitPrice.CurrencyCode")); 101 WriteLiteral("\",\n\t\t\t\t\t\tprice: "); 102 Write(orderline.GetDouble("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.Price.Value").ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)); 103 WriteLiteral(",\n\t\t\t\t\t\tquantity: "); 104 Write(orderline.GetDouble("Ecom:Order:OrderLine.Quantity").ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)); 105 WriteLiteral("\n\t\t\t\t\t},\n\t\t\t\t\t"); 106 } WriteLiteral("\t\t\t]\n\t\t});\n\t</script>\n"); 107 } WriteLiteral("\n"); 108 WriteLiteral("\n"); 109 WriteLiteral("\n"); 110 WriteLiteral("\n"); 111 WriteLiteral("\n"); 112 WriteLiteral("\n"); 113 WriteLiteral("\n"); 114 WriteLiteral("\n"); 115 WriteLiteral("\n\n"); 116 WriteLiteral("\n"); 117 WriteLiteral("\n"); 118 WriteLiteral("\n"); 119 WriteLiteral("\n"); 120 Write(helper); 121 WriteLiteral(@" RenderAddressUser() { var hideEditShippingAddress = Pageview.CurrentParagraph?.Item[""HideEditShippingAddress""] != null ? Convert.ToBoolean(Pageview.CurrentParagraph.Item[""HideEditShippingAddress""].ToString()) : false; string userAccountPage = Pageview.CurrentParagraph.Item[""UserAccountPageLink""] != null ? Pageview.CurrentParagraph.Item[""UserAccountPageLink""].ToString() + ""&GoBackToPage="" + Pageview.Page.ID : """"; string userAddressesPage = Pageview.CurrentParagraph.Item[""UserAddressesPageLink""] != null ? Pageview.CurrentParagraph.Item[""UserAddressesPageLink""].ToString() + ""&GoBackToPage="" + Pageview.Page.ID : """"; string userId = GetString(""UserManagement:User.ID""); var userAddressLoop = GetLoop(""UserManagement:User.UserAddresses""); bool userHasDefaultAddress = false; bool userAddressSelected = false; foreach (LoopItem userAddress in userAddressLoop) { if (userAddress.GetBoolean(""UserManagement:User.UserAddress.Default"")) { userHasDefaultAddress = true; } if (userAddress.GetBoolean(""Use"); 122 WriteLiteral(@"rManagement:User.UserAddress.SelectedForDeliveryFields"")) { userAddressSelected = true; } } List<string> address = new List<string>(); if (!string.IsNullOrEmpty(GetString(""Ecom:Order.Delivery.Address""))) { address.Add(GetString(""Ecom:Order.Delivery.Address"")); } if (!string.IsNullOrEmpty(GetString(""Ecom:Order.Delivery.Address2""))) { address.Add(GetString(""Ecom:Order.Delivery.Address2"")); } if (!string.IsNullOrEmpty(GetString(""Ecom:Order.Delivery.Zip""))) { address.Add(GetString(""Ecom:Order.Delivery.Zip"")); } if (!string.IsNullOrEmpty(GetString(""Ecom:Order.Delivery.City""))) { address.Add(GetString(""Ecom:Order.Delivery.City"")); } if (!string.IsNullOrEmpty(GetString(""Ecom:Order.Delivery.Country""))) { address.Add(GetString(""Ecom:Order.Delivery.Country"")); } string deliveryAddressString = (string.Join("","", address.Select(x => x.ToString()).ToArray())); List<string> addressList = new List<string>(); if (!string.IsNullOrEmpty(GetString(""UserManagement:User.Address""))) { addre"); 123 WriteLiteral(@"ssList.Add(GetString(""UserManagement:User.Address"")); } if (!string.IsNullOrEmpty(GetString(""UserManagement:User.Address2""))) { addressList.Add(GetString(""UserManagement:User.Address2"")); } if (!string.IsNullOrEmpty(GetString(""UserManagement:User.Zip""))) { addressList.Add(GetString(""UserManagement:User.Zip"")); } if (!string.IsNullOrEmpty(GetString(""UserManagement:User.City""))) { addressList.Add(GetString(""UserManagement:User.City"")); } if (!string.IsNullOrEmpty(GetString(""UserManagement:User.State""))) { var countryCode = !string.IsNullOrEmpty(GetString(""UserManagement:User.CountryCode"")) ? GetString(""UserManagement:User.CountryCode"") : Pageview.Area.EcomCountryCode; string stateName = Dynamicweb.Ecommerce.Services.Countries.GetRegion(countryCode, GetString(""UserManagement:User.State""))?.GetName(Dynamicweb.Ecommerce.Common.Context.LanguageID) ?? string.Empty; addressList.Add(stateName); } if (!string.IsNullOrEmpty(GetString(""UserManagement:User.Country""))) { addressList.Add(GetStr"); 124 WriteLiteral(@"ing(""UserManagement:User.Country"")); } string selectedAddress = Dynamicweb.Context.Current.Request.Form.Get(""EcomOrderDeliverySelectedAddressId"") ?? """"; string addressString = (string.Join("","", addressList.Select(x => x.ToString()).ToArray())); string useBillingIsChecked = !userAddressSelected || selectedAddress == """" || selectedAddress == ""-1"" ? ""checked"" : """"; string disabled = addressString == deliveryAddressString || string.IsNullOrEmpty(deliveryAddressString) || string.IsNullOrEmpty(addressString) ? """" : ""disabled""; disabled = userAddressSelected && userHasDefaultAddress ? ""disabled"" : disabled; bool isStandardSwiftTemplates = Pageview.AreaSettings.GetString(""AddressFieldsBasedOn"", ""swift"") == ""swift""; //Billing address is missing if (string.IsNullOrWhiteSpace(addressString)) { <div class=""text-center border p-5""> <h3 class=""mb-4"">"); 125 Write(Translate("You do not have any address yet")); 126 WriteLiteral("</h3>\n\t\t\t<a"); 127 BeginWriteAttribute("href", " href=\"", 31180, "\"", 31203, 1); 128 WriteAttributeValue("", 31187, userAccountPage, 31187, 16, false); 129 EndWriteAttribute(); 130 WriteLiteral(" class=\"btn btn-primary\" id=\"CreateNewAddressButton\">"); 131 Write(Translate("Create new address")); 132 WriteLiteral("</a>\n\t\t</div>\n\t}\n\telse\n\t{\n\t\t<div class=\"mt-4\">\n\t\t\t<div class=\"d-flex justify-content-between mb-3\">\n\t\t\t\t<h3 class=\"fs-6 fw-normal m-0\">"); 133 Write(Translate("Select delivery address")); 134 WriteLiteral("</h3>\n"); 135 if (!hideEditShippingAddress) { WriteLiteral("\t\t\t\t\t<a"); 136 BeginWriteAttribute("href", " href=\"", 31515, "\"", 31540, 1); 137 WriteAttributeValue("", 31522, userAddressesPage, 31522, 18, false); 138 EndWriteAttribute(); 139 WriteLiteral(" class=\"m-0 h6 fw-normal d-none d-md-block\" id=\"ManageAddressesButton\">"); 140 Write(Translate("Manage your addresses")); 141 WriteLiteral("</a>\n"); 142 } WriteLiteral(@" </div> </div> <div class=""list-group"" id=""SelectDeliveryAddressGroup""> <label class=""list-group-item list-group-item-action""> <div class=""form-check""> <input class=""form-check-input"" type=""radio"" name=""EcomOrderDeliverySelectedAddressId"""); 143 BeginWriteAttribute("id", " id=\"", 31915, "\"", 31991, 2); 144 WriteAttributeValue("", 31920, "EcomOrderDeliverySelectedAddressId_", 31920, 35, true); 145 WriteAttributeValue("", 31955, GetString("UserManagement:User.ID"), 31955, 36, false); 146 EndWriteAttribute(); 147 WriteLiteral(" value=\"-1\" "); 148 Write(useBillingIsChecked); 149 WriteLiteral(" onclick=\"useBillingAddress()\">\n\t\t\t\t\t<span class=\"form-check-label\">"); 150 Write(Translate("Same as the billing address")); 151 WriteLiteral("</span>\n\n\t\t\t\t\t<input "); 152 Write(disabled); 153 WriteLiteral(" type=\"hidden\" name=\"EcomOrderDeliveryName\" value=\""); 154 Write(GetString("UserManagement:User.Name")); 155 WriteLiteral("\">\n\t\t\t\t\t<input "); 156 Write(disabled); 157 WriteLiteral(" type=\"hidden\" name=\"EcomOrderDeliveryEmail\" value=\""); 158 Write(GetString("UserManagement:User.Email")); 159 WriteLiteral("\">\n\t\t\t\t\t<input "); 160 Write(disabled); 161 WriteLiteral(" type=\"hidden\" name=\"EcomOrderDeliveryPhone\" value=\""); 162 Write(GetString("UserManagement:User.Phone")); 163 WriteLiteral("\">\n\t\t\t\t\t<input "); 164 Write(disabled); 165 WriteLiteral(" type=\"hidden\" name=\"EcomOrderDeliveryCompany\" value=\""); 166 Write(GetString("UserManagement:User.Company")); 167 WriteLiteral("\">\n\t\t\t\t\t<input "); 168 Write(disabled); 169 WriteLiteral(" type=\"hidden\" name=\"EcomOrderDeliveryAddress\" value=\""); 170 Write(GetString("UserManagement:User.Address")); 171 WriteLiteral("\">\n\t\t\t\t\t<input "); 172 Write(disabled); 173 WriteLiteral(" type=\"hidden\" name=\"EcomOrderDeliveryAddress2\" value=\""); 174 Write(GetString("UserManagement:User.Address2")); 175 WriteLiteral("\">\n\t\t\t\t\t<input "); 176 Write(disabled); 177 WriteLiteral(" type=\"hidden\" name=\"EcomOrderDeliveryZip\" value=\""); 178 Write(GetString("UserManagement:User.Zip")); 179 WriteLiteral("\">\n\t\t\t\t\t<input "); 180 Write(disabled); 181 WriteLiteral(" type=\"hidden\" name=\"EcomOrderDeliveryCity\" value=\""); 182 Write(GetString("UserManagement:User.City")); 183 WriteLiteral("\">\n\t\t\t\t\t<input "); 184 Write(disabled); 185 WriteLiteral(" type=\"hidden\" name=\"àEcomOrderDeliveryRegion\" value=\""); 186 Write(GetString("UserManagement:User.State")); 187 WriteLiteral("\">\n\t\t\t\t\t<input "); 188 Write(disabled); 189 WriteLiteral(" type=\"hidden\" name=\"EcomOrderDeliveryCountry\" value=\""); 190 Write(GetString("UserManagement:User.CountryCode")); 191 WriteLiteral("\">\n\n\t\t\t\t</div>\n\t\t\t</label>\n\n"); 192 foreach (LoopItem userAddress in userAddressLoop) { string addressId = userAddress.GetString("UserManagement:User.UserAddress.ID"); List<string> userAddressList = new List<string>(); if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.Address"))) { userAddressList.Add(userAddress.GetString("UserManagement:User.UserAddress.Address")); } if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.Address2"))) { userAddressList.Add(userAddress.GetString("UserManagement:User.UserAddress.Address2")); } if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.Zip"))) { userAddressList.Add(userAddress.GetString("UserManagement:User.UserAddress.Zip")); } if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.City"))) { userAddressList.Add(userAddress.GetString("UserManagement:User.UserAddress.City")); } if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.State"))) { var countryCode = userAddress.GetString("UserManagement:User.UserAddress.CountryCode"); string stateName = Dynamicweb.Ecommerce.Services.Countries.GetRegion(countryCode, GetString("UserManagement:User.UserAddress.State"))?.GetName(Dynamicweb.Ecommerce.Common.Context.LanguageID) ?? string.Empty; userAddressList.Add(stateName); } if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.CountryCode"))) { userAddressList.Add(userAddress.GetString("UserManagement:User.UserAddress.Culture.CountryName")); } string userAddressString = (string.Join(",", userAddressList.Select(x => x.ToString()).ToArray())).Replace(",", ", "); string isChecked = userAddress.GetBoolean("UserManagement:User.UserAddress.SelectedForDeliveryFields") ? "checked" : ""; isChecked = userAddressSelected == false && userAddress.GetBoolean("UserManagement:User.UserAddress.Default") && selectedAddress != "-1" ? "checked" : isChecked; WriteLiteral(@" <label class=""list-group-item list-group-item-action""> <div class=""grid""> <div class=""g-col-12 g-col-md-4 d-flex""> <div class=""form-check""> <input class=""form-check-input"" type=""radio"" name=""EcomOrderDeliverySelectedAddressId"""); 193 BeginWriteAttribute("id", " id=\"", 35663, "\"", 35713, 2); 194 WriteAttributeValue("", 35668, "EcomOrderDeliverySelectedAddressId_", 35668, 35, true); 195 WriteAttributeValue("", 35703, addressId, 35703, 10, false); 196 EndWriteAttribute(); 197 BeginWriteAttribute("value", " value=\"", 35714, "\"", 35732, 1); 198 WriteAttributeValue("", 35722, addressId, 35722, 10, false); 199 EndWriteAttribute(); 200 WriteLiteral(" "); 201 Write(isChecked); 202 WriteLiteral(" onclick=\"useUserAddress()\">\n\t\t\t\t\t\t\t\t<span class=\"form-check-label\">"); 203 Write(userAddress.GetString("UserManagement:User.UserAddress.Description")); 204 WriteLiteral("</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div class=\"g-col-12 g-col-md-7 fs-7\">\n"); 205 if (isStandardSwiftTemplates) { Write(userAddressString); 206 } else { Write(RenderUserItemAddressInline(userAddress)); 207 } WriteLiteral("\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</label>\n"); 208 } WriteLiteral(@" </div> <script> useBillingAddress = function () { document.querySelectorAll(""input[name^='EcomOrderDelivery']"").forEach(function (field) { field.removeAttribute(""disabled""); }); submitForm(); } useUserAddress = function () { document.querySelectorAll(""input[name^='EcomOrderDelivery']"").forEach(function (field) { if (field.name != ""EcomOrderDeliverySelectedAddressId"") { field.setAttribute(""disabled"", ""true""); } }); submitForm(); } </script> } } "); 209 WriteLiteral("\n"); 210 WriteLiteral("\n\n"); 211 WriteLiteral("\n"); 212 WriteLiteral("\r\n"); 213 WriteLiteral("\n"); 214 WriteLiteral("\n\n"); 215 WriteLiteral("\n"); 216 WriteLiteral("\n"); 217 WriteLiteral("\n"); 218 WriteLiteral("\n"); 219 WriteLiteral("\n"); 220 } 221 #pragma warning restore 1998 222 string RenderLogo() { string logoLink = Pageview.CurrentParagraph.Item["LogoLink"] != null ? Pageview.CurrentParagraph.Item["LogoLink"].ToString() : ""; WriteLiteral(" <div class=\"mb-4 text-center\">\n"); 223 if (!string.IsNullOrWhiteSpace(logoLink)) { WriteLiteral(" <a"); 224 BeginWriteAttribute("href", " href=\"", 4525, "\"", 4541, 1); 225 WriteAttributeValue("", 4532, logoLink, 4532, 9, false); 226 EndWriteAttribute(); 227 WriteLiteral(" class=\"text-decoration-none\""); 228 BeginWriteAttribute("title", " title=\"", 4571, "\"", 4607, 1); 229 WriteAttributeValue("", 4579, Translate("Leave checkout"), 4579, 28, false); 230 EndWriteAttribute(); 231 WriteLiteral(">\n "); 232 Write(RenderLogoImage()); 233 WriteLiteral("\n </a>\n"); 234 } else { Write(RenderLogoImage()); 235 } WriteLiteral(" </div>\n"); 236 return string.Empty; } string RenderLogoImage() { string logoImage = Pageview.CurrentParagraph.Item["Logo"] != null ? Pageview.CurrentParagraph.Item["Logo"].ToString() : ""; string maxWidth = Pageview.CurrentParagraph.Item["MaxWidth"] != null ? "max-width: " + Pageview.CurrentParagraph.Item["MaxWidth"].ToString() + "px" : ""; string title = Pageview.CurrentParagraph.Item["Title"] != null ? Pageview.CurrentParagraph.Item["Title"].ToString() : Pageview.Area.Name; maxWidth = maxWidth == "max-width: 0px" ? "" : maxWidth; if (logoImage != "") { if (Path.GetExtension(logoImage).ToLower() == ".svg") { WriteLiteral(" <div class=\"icon-auto\""); 237 BeginWriteAttribute("style", " style=\"", 5526, "\"", 5543, 1); 238 WriteAttributeValue("", 5534, maxWidth, 5534, 9, false); 239 EndWriteAttribute(); 240 WriteLiteral(">\n "); 241 Write(ReadFile(logoImage)); 242 WriteLiteral("\n </div>\n"); 243 } else { string imageWidth = Pageview.CurrentParagraph.Item["MaxWidth"] != null ? Pageview.CurrentParagraph.Item["MaxWidth"].ToString() : "400"; string imagePath = "/Admin/Public/GetImage.ashx?width=" + imageWidth + "&image=" + logoImage; WriteLiteral(" <picture class=\"mx-auto d-block\">\n <img"); 244 BeginWriteAttribute("src", " src=\"", 5992, "\"", 6008, 1); 245 WriteAttributeValue("", 5998, logoImage, 5998, 10, false); 246 EndWriteAttribute(); 247 BeginWriteAttribute("alt", " alt=\"", 6009, "\"", 6021, 1); 248 WriteAttributeValue("", 6015, title, 6015, 6, false); 249 EndWriteAttribute(); 250 BeginWriteAttribute("style", " style=\"", 6022, "\"", 6039, 1); 251 WriteAttributeValue("", 6030, maxWidth, 6030, 9, false); 252 EndWriteAttribute(); 253 WriteLiteral(">\n </picture>\n"); 254 } } else { WriteLiteral(" <div class=\"fs-3 p-0\">"); 255 Write(title); 256 WriteLiteral("</div>\n"); 257 } return string.Empty; } string RenderStepsBreadcrumbs() { bool isPaymentStep = GetLoop("StepButtons").Count == 0; WriteLiteral(" <nav aria-label=\"breadcrumb\" class=\"mb-3 mb-md-4 fs-8\" id=\"StepsBreadcrumbs\">\n <ol class=\"breadcrumb\">\n"); 258 foreach (LoopItem step in GetLoop("StepButtons")) { if (step.GetString("Step.Name").ToLower() != "checkout") { if (step.GetBoolean("Step.Current")) { WriteLiteral(" <li class=\"breadcrumb-item fw-bold\" aria-current=\"location\">"); 259 Write(Translate(step.GetString("Step.Name"))); 260 WriteLiteral("</li>\n"); 261 } else { WriteLiteral(" <li class=\"breadcrumb-item\">"); 262 Write(Translate(step.GetString("Step.Name"))); 263 WriteLiteral("</li>\n"); 264 } } } WriteLiteral("\n"); 265 if (isPaymentStep) { var cartSettings = new ModuleSettings(Pageview.CurrentParagraph.ModuleProperties); foreach (CartStepInfo step in cartSettings.Steps) { if (step.IsCheckout) { WriteLiteral(" <li class=\"breadcrumb-item fw-bold\" aria-current=\"location\">"); 266 Write(Translate(step.Name)); 267 WriteLiteral("</li>\n"); 268 break; } else { WriteLiteral(" <li class=\"breadcrumb-item\">"); 269 Write(Translate(step.Name)); 270 WriteLiteral("</li>\n"); 271 } } } WriteLiteral(" </ol>\n </nav>\n"); 272 return string.Empty; } string RenderErrors(){ if (GetLoop("ValidationErrors").Count() != 0) { WriteLiteral(" <div class=\"alert alert-warning\" role=\"alert\">\n <ul class=\"m-0 list-unstyled\">\n"); 273 foreach (LoopItem item in GetLoop("ValidationErrors")) { WriteLiteral(" <li>"); 274 Write(item.GetValue("Ecom:Cart.ValidationError.ErrorMessage")); 275 WriteLiteral("</li>\n"); 276 } WriteLiteral(" </ul>\n </div>\n"); 277 } return string.Empty; } string RenderStepSummary() { bool isPaymentStep = GetLoop("StepButtons").Count == 0; int currentStep = !isPaymentStep ? 1 : 4; int currentUserId = Dynamicweb.Core.Converter.ToInt32(GetGlobalValue("Global:Extranet.UserID")); foreach (LoopItem step in GetLoop("StepButtons")) { if (step.GetBoolean("Step.Current")) { currentStep = step.GetInteger("Step.Number"); } } if (!string.IsNullOrEmpty(GetString("UserManagement:User.Address")) || !string.IsNullOrEmpty(GetString("Ecom:Order.ShippingMethodID")) || !string.IsNullOrEmpty(GetString("Ecom:Order.PaymentMethodID")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Name")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Company")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Address")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Address2")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Zip")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.City")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Email")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Phone")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Name")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Company")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Address")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Address2")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Zip")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.City")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Email")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Phone")) || !string.IsNullOrEmpty(GetString("Ecom:Order.ShippingMethod")) || !string.IsNullOrEmpty(GetString("Ecom:Order.ShippingDate")) || !string.IsNullOrEmpty(GetString("Ecom:Order.PaymentMethod"))) { if (currentUserId != 0) { WriteLiteral(" <div class=\"list-group mb-5\">\n"); 278 Write(RenderStepSummaryOrderCustomer()); 279 Write(RenderStepSummaryUser()); 280 WriteLiteral("\n"); 281 if (currentStep != 1) { { Write(RenderStepSummaryOrderDelivery()); 282 Write(RenderStepSummaryDeliveryMethod()); 283 Write(RenderStepSummaryDeliveryDate()); 284 } } WriteLiteral(" </div>\n"); 285 } else { if (currentStep != 1) { WriteLiteral(" <div class=\"list-group\">\n"); 286 Write(RenderStepSummaryOrderCustomer()); 287 Write(RenderStepSummaryOrderDelivery()); 288 if (currentStep > 2) { { Write(RenderStepSummaryDeliveryMethod()); 289 Write(RenderStepSummaryDeliveryDate()); 290 } } if (currentStep > 3) { { Write(RenderStepSummaryPaymentMethod()); 291 Write(RenderStepSummaryOrderReference()); 292 } } WriteLiteral(" </div>\n"); 293 } } } return string.Empty; } string RenderStepSummaryOrderCustomer() { var hideEditBillingAddress = Pageview.CurrentParagraph?.Item["HideEditBillingAddress"] != null ? Convert.ToBoolean(Pageview.CurrentParagraph.Item["HideEditBillingAddress"].ToString()) : false; int currentUserId = Dynamicweb.Core.Converter.ToInt32(GetGlobalValue("Global:Extranet.UserID")); List<string> contact = new List<string>(); if (!string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Email")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Phone"))) { if (!string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Email"))) { contact.Add(GetString("Ecom:Order.Customer.Email")); } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Phone"))) { contact.Add(GetString("Ecom:Order.Delivery.Phone")); } } string contactString = (string.Join(",", contact.Select(x => x.ToString()).ToArray())).Replace(",", ", "); string userAccountPage = Pageview.CurrentParagraph.Item["UserAccountPageLink"] != null ? Pageview.CurrentParagraph.Item["UserAccountPageLink"].ToString() + "&GoBackToPage=" + Pageview.Page.ID : ""; if (!string.IsNullOrEmpty(contactString)) { WriteLiteral(@" <div class=""list-group-item py-2 fs-7"" style=""background-color: rgba(var(--swift-foreground-color-rgb), 0.05)"" id=""ContactGroup""> <dl class=""grid gap-1 gap-sm-3 mb-0""> <dt class=""g-col-8 g-col-sm-4 fw-normal"">"); 294 Write(Translate("Contact")); 295 WriteLiteral("</dt>\n <dd class=\"g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0\">"); 296 Write(contactString); 297 WriteLiteral("</dd>\n\n"); 298 if (!hideEditBillingAddress) { WriteLiteral(" <dd class=\"g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end\">\n"); 299 if (currentUserId == 0) { WriteLiteral(" <button type=\"submit\" class=\"btn btn-small btn-link fs-8 p-0\" name=\"CartV2.GotoStep0\" id=\"EditBillingAddressButton\">\n <span class=\"text-uppercase\">"); 300 Write(Translate("Edit")); 301 WriteLiteral("</span>\n </button>\n"); 302 } else { WriteLiteral(" <a"); 303 BeginWriteAttribute("href", " href=\"", 14635, "\"", 14658, 1); 304 WriteAttributeValue("", 14642, userAccountPage, 14642, 16, false); 305 EndWriteAttribute(); 306 WriteLiteral(" class=\"btn btn-small btn-link fs-8 p-0\" id=\"EditBillingAddressButton\">\n <span class=\"text-uppercase\">"); 307 Write(Translate("Edit")); 308 WriteLiteral("</span>\n </a>\n"); 309 } WriteLiteral(" </dd>\n"); 310 } WriteLiteral(" </dl>\n </div>\n"); 311 } return string.Empty; } string RenderStepSummaryOrderDelivery() { var hideEditBillingAddress = Pageview.CurrentParagraph?.Item["HideEditBillingAddress"] != null ? Convert.ToBoolean(Pageview.CurrentParagraph.Item["HideEditBillingAddress"].ToString()) : false; int fieldCount = 0; //Helps us render addresses that contains more than just the auto set country bool isStandardSwiftTemplates = Pageview.AreaSettings.GetString("AddressFieldsBasedOn", "swift") == "swift"; string addressString = ""; if (isStandardSwiftTemplates) { List<string> address = new List<string>(); if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Company"))) { address.Add(GetString("Ecom:Order.Delivery.Company")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Name"))) { address.Add(GetString("Ecom:Order.Delivery.Name")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Address"))) { address.Add(GetString("Ecom:Order.Delivery.Address")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Address2"))) { address.Add(GetString("Ecom:Order.Delivery.Address2")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Zip"))) { address.Add(GetString("Ecom:Order.Delivery.Zip")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.City"))) { address.Add(GetString("Ecom:Order.Delivery.City")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Region"))) { string regionName = GetString("Ecom:Order.Delivery.Region"); foreach (LoopItem region in GetLoop("DeliveryRegions")) { if (region.GetString("Ecom:DeliveryRegion.IsDeliveryRegion") == "true") { regionName = region.GetString("Ecom:DeliveryRegion.Name"); } } address.Add(regionName); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Country"))) { address.Add(GetString("Ecom:Order.Delivery.Country")); fieldCount++; } addressString = (string.Join(",", address.Select(x => x.ToString()).ToArray())).Replace(",", ", "); } else { addressString = GetDeliveryAddressString(); } string editStep = "CartV2.GotoStep0"; if (!string.IsNullOrEmpty(addressString) && ((isStandardSwiftTemplates && fieldCount > 1) || !isStandardSwiftTemplates)) { WriteLiteral(" <div class=\"list-group-item py-2 fs-7\" style=\"background-color: rgba(var(--swift-foreground-color-rgb), 0.05)\">\n <dl class=\"grid gap-1 gap-sm-3 mb-0\">\n <dt class=\"g-col-8 g-col-sm-4 fw-normal\">"); 312 Write(Translate("Send to")); 313 WriteLiteral("</dt>\n <dd class=\"g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0\">"); 314 Write(addressString); 315 WriteLiteral("</dd>\n\n"); 316 if (!hideEditBillingAddress) { WriteLiteral(" <dd class=\"g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end\">\n <button class=\"btn btn-small btn-link fs-8 p-0\" type=\"submit\""); 317 BeginWriteAttribute("name", " name=\"", 18712, "\"", 18728, 1); 318 WriteAttributeValue("", 18719, editStep, 18719, 9, false); 319 EndWriteAttribute(); 320 WriteLiteral(" id=\"EditDeliveryAddressButton\">\n <span class=\"text-uppercase\">"); 321 Write(Translate("Edit")); 322 WriteLiteral("</span>\n </button>\n </dd>\n"); 323 } WriteLiteral(" </dl>\n </div>\n"); 324 } return string.Empty; } string RenderStepSummaryUser() { var hideEditBillingAddress = Pageview.CurrentParagraph?.Item["HideEditBillingAddress"] != null ? Convert.ToBoolean(Pageview.CurrentParagraph.Item["HideEditBillingAddress"].ToString()) : false; int fieldCount = 0; //Helps us render addresses that contains more than just the auto set country bool isStandardSwiftTemplates = Pageview.AreaSettings.GetString("AddressFieldsBasedOn", "swift") == "swift"; string addressString = ""; if (isStandardSwiftTemplates) { Dynamicweb.Security.UserManagement.User user = Pageview.User; List<string> address = new List<string>(); if (!string.IsNullOrEmpty(user.Company)) { address.Add(user.Company); fieldCount++; } if (!string.IsNullOrEmpty(user.Name)) { address.Add(user.Name); fieldCount++; } if (!string.IsNullOrEmpty(user.Address)) { address.Add(user.Address); fieldCount++; } if (!string.IsNullOrEmpty(user.Address2)) { address.Add(user.Address2); fieldCount++; } if (!string.IsNullOrEmpty(user.Zip)) { address.Add(user.Zip); fieldCount++; } if (!string.IsNullOrEmpty(user.City)) { address.Add(user.City); fieldCount++; } if (!string.IsNullOrEmpty(user.State)) { var countryCode = user.CountryCode; string stateName = Dynamicweb.Ecommerce.Services.Countries.GetRegion(countryCode, user.State)?.GetName(Dynamicweb.Ecommerce.Common.Context.LanguageID) ?? string.Empty; address.Add(stateName); fieldCount++; } if (!string.IsNullOrEmpty(user.CountryCode)) { string country = user.Region.DisplayName; address.Add(country); fieldCount++; } addressString = (string.Join(",", address.Select(x => x.ToString()).ToArray())).Replace(",", ", "); } else { addressString = GetUserAddressString(); } string editStep = Pageview.CurrentParagraph.Item["UserAccountPageLink"] != null ? Pageview.CurrentParagraph.Item["UserAccountPageLink"].ToString() + "&GoBackToPage=" + Pageview.Page.ID : ""; if (!string.IsNullOrEmpty(addressString) && ((isStandardSwiftTemplates && fieldCount > 1) || !isStandardSwiftTemplates)) { WriteLiteral(" <div class=\"list-group-item py-2 fs-7\" style=\"background-color: rgba(var(--swift-foreground-color-rgb), 0.05)\">\n <dl class=\"grid gap-1 gap-sm-3 mb-0\">\n <dt class=\"g-col-8 g-col-sm-4 fw-normal\">"); 325 Write(Translate("Billing address")); 326 WriteLiteral("</dt>\n <dd class=\"g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0\">"); 327 Write(addressString); 328 WriteLiteral("</dd>\n"); 329 if (!hideEditBillingAddress) { WriteLiteral(" <dd class=\"g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end\">\n <a"); 330 BeginWriteAttribute("href", " href=\"", 22357, "\"", 22373, 1); 331 WriteAttributeValue("", 22364, editStep, 22364, 9, false); 332 EndWriteAttribute(); 333 WriteLiteral(" class=\"btn btn-small btn-link fs-8 p-0\" id=\"EditBillingAddressButton\">\n <span class=\"text-uppercase\">"); 334 Write(Translate("Edit")); 335 WriteLiteral("</span>\n </a>\n </dd>\n"); 336 } WriteLiteral(" </dl>\n </div>\n"); 337 } return string.Empty; } string RenderStepSummaryDeliveryMethod() { string shippingMethod = GetString("Ecom:Order.ShippingMethod"), editStep = "CartV2.GotoStep1"; if (!string.IsNullOrEmpty(shippingMethod)) { WriteLiteral(" <div class=\"list-group-item py-2 fs-7\" style=\"background-color: rgba(var(--swift-foreground-color-rgb), 0.05)\">\n <dl class=\"grid gap-1 gap-sm-3 mb-0\">\n <dt class=\"g-col-8 g-col-sm-4 fw-normal\">"); 338 Write(Translate("Delivery")); 339 WriteLiteral("</dt>\n <dd class=\"g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0\">"); 340 Write(shippingMethod); 341 WriteLiteral("</dd>\n <dd class=\"g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end\">\n <button class=\"btn btn-small btn-link fs-8 p-0\" type=\"submit\""); 342 BeginWriteAttribute("name", " name=\"", 23483, "\"", 23499, 1); 343 WriteAttributeValue("", 23490, editStep, 23490, 9, false); 344 EndWriteAttribute(); 345 WriteLiteral(" id=\"EditDeliveryButton\">\n <span class=\"text-uppercase\">"); 346 Write(Translate("Edit")); 347 WriteLiteral("</span>\n </button>\n </dd>\n </dl>\n </div>\n"); 348 } return string.Empty; } string RenderStepSummaryPaymentMethod() { string PaymentMethodID = GetString("Ecom:Order.ShippingMethodID"); string paymentMethod = GetString("Ecom:Order.PaymentMethod"); string editStep = "CartV2.GotoStep2"; if (!string.IsNullOrEmpty(PaymentMethodID)) { WriteLiteral(@" <div class=""list-group-item d-flex gap-3 align-items-baseline py-2 fs-7"" style=""background-color: rgba(var(--swift-foreground-color-rgb), 0.05)""> <div class=""flex-grow-1""> <dl class=""grid mb-0""> <dt class=""g-col-12 g-col-md-4 mb-lg-0 lh-base fw-normal"">"); 349 Write(Translate("Payment")); 350 WriteLiteral("</dt>\n <dd class=\"g-col-12 g-col-md-8 mb-0\">\n "); 351 Write(paymentMethod); 352 WriteLiteral("\n </dd>\n </dl>\n </div>\n\n <button class=\"btn btn-small btn-link fs-8\" type=\"submit\""); 353 BeginWriteAttribute("name", " name=\"", 24686, "\"", 24702, 1); 354 WriteAttributeValue("", 24693, editStep, 24693, 9, false); 355 EndWriteAttribute(); 356 WriteLiteral(" id=\"EditPaymentButton\">\n <span class=\"text-uppercase\">"); 357 Write(Translate("Edit")); 358 WriteLiteral("</span>\n </button>\n\n </div>\n"); 359 } return string.Empty; } string RenderStepSummaryDeliveryDate() { string shippingDate = GetString("Ecom:Order.ShippingDate"), shippingDateFormatted = GetDate("Ecom:Order.ShippingDate").ToShortDateString(), editStep = "CartV2.GotoStep1"; if (!string.IsNullOrEmpty(shippingDate)) { WriteLiteral(" <div class=\"list-group-item py-2 fs-7\" style=\"background-color: rgba(var(--swift-foreground-color-rgb), 0.05)\">\n <dl class=\"grid gap-1 gap-sm-3 mb-0\">\n <dt class=\"g-col-8 g-col-sm-4 fw-normal\">"); 360 Write(Translate("Delivery date")); 361 WriteLiteral("</dt>\n <dd class=\"g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0\">"); 362 Write(shippingDateFormatted); 363 WriteLiteral("</dd>\n <dd class=\"g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end\">\n <button class=\"btn btn-small btn-link fs-8 p-0\" type=\"submit\""); 364 BeginWriteAttribute("name", " name=\"", 25769, "\"", 25785, 1); 365 WriteAttributeValue("", 25776, editStep, 25776, 9, false); 366 EndWriteAttribute(); 367 WriteLiteral(" id=\"EditDeliveryDateButton\">\n <span class=\"text-uppercase\">"); 368 Write(Translate("Edit")); 369 WriteLiteral("</span>\n </button>\n </dd>\n </dl>\n </div>\n"); 370 } return string.Empty; } string RenderStepSummaryOrderReference() { string orderReference = !string.IsNullOrWhiteSpace(GetString("Ecom:Order.Reference")) ? GetString("Ecom:Order.Reference") : "", editStep = "CartV2.GotoStep2"; if (!string.IsNullOrEmpty(orderReference)) { WriteLiteral(" <div class=\"list-group-item py-2 fs-7\" style=\"background-color: rgba(var(--swift-foreground-color-rgb), 0.05)\">\n <dl class=\"grid gap-1 gap-sm-3 mb-0\">\n <dt class=\"g-col-8 g-col-sm-4 fw-normal\">"); 371 Write(Translate("Order reference")); 372 WriteLiteral("</dt>\n <dd class=\"g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0\">"); 373 Write(orderReference); 374 WriteLiteral("</dd>\n <dd class=\"g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end\">\n <button class=\"btn btn-small btn-link fs-8 p-0\" type=\"submit\""); 375 BeginWriteAttribute("name", " name=\"", 26894, "\"", 26910, 1); 376 WriteAttributeValue("", 26901, editStep, 26901, 9, false); 377 EndWriteAttribute(); 378 WriteLiteral(" id=\"EditorderReferenceButton\">\n <span class=\"text-uppercase\">"); 379 Write(Translate("Edit")); 380 WriteLiteral("</span>\n </button>\n </dd>\n </dl>\n </div>\n"); 381 } return string.Empty; } string RenderStepsNavigation() { string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; int currentStep = 1; string nextButtonName = Translate("Next"); string previousButtonName = Translate("Back"); bool isPaymentStep = GetLoop("StepButtons").Count == 0; bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsWebServiceConnectionAvailable"]); string erpDownCartBehavior = Pageview.AreaSettings.GetRawValueString("ErpDownCartBehavior", "none"); foreach (LoopItem step in GetLoop("StepButtons")) { if (step.GetBoolean("Step.Current")) { currentStep = step.GetInteger("Step.Number"); } if (step.GetInteger("Step.Number") == currentStep + 1) { nextButtonName = Translate(step.GetString("Step.Name")); } if (step.GetInteger("Step.Number") == currentStep + step.GetInteger("Step.Index")) { previousButtonName = Translate("Back to") + " " + Translate(step.GetString("Step.Name")); } } if (currentStep == GetLoop("StepButtons").Count - 1 && Pageview.CurrentParagraph.Item.SystemName != "Swift_QuoteCheckoutApp") { nextButtonName = Translate("Place Order"); Write(RenderTermsAndConditionsCheckbox()); 382 } else if (isPaymentStep) { nextButtonName = Translate("Pay"); } WriteLiteral(" <div class=\"mt-4 d-flex flex-column flex-md-row justify-content-end gap-3 mt-lg-4\" id=\"StepsNavigation\">\n\n"); 383 if (currentStep == 1) { var cartLink = $"Default.aspx?id={Pageview.CurrentParagraph.Page.Parent.ID}"; WriteLiteral(" <a"); 384 BeginWriteAttribute("href", " href=\"", 38541, "\"", 38557, 1); 385 WriteAttributeValue("", 38548, cartLink, 38548, 9, false); 386 EndWriteAttribute(); 387 WriteLiteral(@" class=""btn btn-link link-secondary text-decoration-none order-last order-md-first"" id=""BackToCartButton""> <div class=""d-flex align-items-center justify-content-center position-relative""> <span class=""icon-2 me-1 position-absolute position-md-static start-0""> "); 388 Write(ReadFile(iconPath + "chevron-left.svg")); 389 WriteLiteral("\n </span>\n <span>"); 390 Write(Translate("Back to cart")); 391 WriteLiteral("</span>\n </div>\n </a>\n"); 392 } else { WriteLiteral(" <button"); 393 BeginWriteAttribute("name", " name=\"", 39143, "\"", 39193, 1); 394 WriteAttributeValue("", 39150, GetString("CartV2.PreviousStepButtonName"), 39150, 43, false); 395 EndWriteAttribute(); 396 BeginWriteAttribute("id", " id=\"", 39194, "\"", 39242, 1); 397 WriteAttributeValue("", 39199, GetString("CartV2.PreviousStepButtonName"), 39199, 43, false); 398 EndWriteAttribute(); 399 WriteLiteral(@" class=""btn btn-link link-secondary text-decoration-none""> <div class=""d-flex align-items-center justify-content-center position-relative""> <span class=""icon-2 me-1 position-absolute position-md-static start-0""> "); 400 Write(ReadFile(iconPath + "chevron-left.svg")); 401 WriteLiteral("\n </span>\n <span>"); 402 Write(previousButtonName); 403 WriteLiteral("</span>\n </div>\n </button>\n"); 404 } WriteLiteral("\n"); 405 if (!(currentStep == GetLoop("StepButtons").Count - 1 && isErpConnectionDown && erpDownCartBehavior == "disable")) { var buttonId = GetLoop("StepButtons").Count == 0 ? "PayButton" : GetString("CartV2.NextStepButtonName"); WriteLiteral(" <button type=\"submit\""); 406 BeginWriteAttribute("name", " name=\"", 40025, "\"", 40071, 1); 407 WriteAttributeValue("", 40032, GetString("CartV2.NextStepButtonName"), 40032, 39, false); 408 EndWriteAttribute(); 409 BeginWriteAttribute("id", " id=\"", 40072, "\"", 40086, 1); 410 WriteAttributeValue("", 40077, buttonId, 40077, 9, false); 411 EndWriteAttribute(); 412 WriteLiteral(" class=\"btn btn-primary order-first order-md-last\">\n <div class=\"d-flex align-items-center justify-content-center position-relative\">\n <span>"); 413 Write(nextButtonName); 414 WriteLiteral("</span>\n <span class=\"icon-2 ms-1 position-absolute position-md-static end-0\">\n "); 415 Write(ReadFile(iconPath + "chevron-right.svg")); 416 WriteLiteral("\n </span>\n </div>\n </button>\n"); 417 } else { WriteLiteral(" <button class=\"btn btn-primary pe-none disabled\">"); 418 Write(Translate("Payment is temporarily disabled")); 419 WriteLiteral("</button>\n"); 420 } WriteLiteral(" <script>\n\t\t\tif (window.history.replaceState) {\n\t\t\t\twindow.history.replaceState(null, null, window.location.href);\n\t\t\t}\n\t\t</script>\n\n </div>\n"); 421 return string.Empty; } string RenderTermsAndConditionsCheckbox() { string termsAndConditionsCheckboxValue = GetBoolean("Ecom:Order.Customer.Accepted").ToString(); string termsAndConditionsPageLink = Pageview.CurrentParagraph.Item["TermsAndConditionsPageLink"] != null ? Pageview.CurrentParagraph.Item["TermsAndConditionsPageLink"].ToString() : ""; if (!string.IsNullOrEmpty(termsAndConditionsPageLink)) { WriteLiteral(" <div class=\"mt-4\" id=\"TermsAndConditions\">\n <h3 class=\"fs-6 fw-normal mb-0\">"); 422 Write(Translate("Terms and conditions")); 423 WriteLiteral("</h3>\n <p class=\"fs-8 mb-3\">"); 424 Write(Translate("Agree to terms and conditions and that your informations are correct")); 425 WriteLiteral(@"</p> <div class=""list-group""> <label class=""list-group-item list-group-item-action d-flex justify-content-between"" for=""EcomOrderCustomerAccepted""> <span class=""d-flex justify-content-between align-items-center gap-3""> <input class=""form-check-input m-0"" type=""checkbox"" name=""EcomOrderCustomerAccepted"" id=""EcomOrderCustomerAccepted"""); 426 BeginWriteAttribute("value", " value=\"", 42038, "\"", 42078, 1); 427 WriteAttributeValue("", 42046, termsAndConditionsCheckboxValue, 42046, 32, false); 428 EndWriteAttribute(); 429 WriteLiteral("\n "); 430 if (GetString("Ecom:Order.Customer.Accepted") == "true") { WriteLiteral("checked=\"checked\""); 431 }WriteLiteral(">\n <span>"); 432 Write(Translate("I accept the")); 433 WriteLiteral(" <a"); 434 BeginWriteAttribute("href", " href=\'", 42381, "\'", 42415, 1); 435 WriteAttributeValue("", 42388, termsAndConditionsPageLink, 42388, 27, false); 436 EndWriteAttribute(); 437 WriteLiteral(" target=\'_blank\' rel=\'noopener\' id=\"TermsAndConditionsButton\">"); 438 Write(Translate("terms and conditions")); 439 WriteLiteral("</a></span>\n </span>\n </label>\n </div>\n </div>\n"); 440 } return string.Empty; } string RenderSummarySidebar() { WriteLiteral(" <div class=\"g-col-12 g-col-lg-4 py-2 p-3 p-lg-4 p-xl-5\" id=\"summarySidebar\">\n "); 441 Write(RenderOrderSummaryToggleButton()); 442 WriteLiteral("\n "); 443 Write(RenderOrderSummaryContent()); 444 WriteLiteral("\n </div>\n"); 445 return string.Empty; } string RenderOrderSummaryContent() { WriteLiteral(" <div class=\"d-lg-block h-lg-auto collapse pt-2 pt-lg-0\" id=\"orderSummary\">\n <div class=\"d-flex flex-column gap-2 gap-lg-3 pb-2 pb-lg-3\">\n"); 446 foreach (LoopItem orderline in GetLoop("OrderLines")) { Write(RenderOrderSummaryOrderLineItem(orderline)); 447 } WriteLiteral(" </div>\n\n "); 448 Write(RenderOrderSummary()); 449 WriteLiteral("\n </div>\n"); 450 return string.Empty; } 451 452 private static string GetPrimaryImage(LoopItem orderline, string shopId) 453 { 454 bool isProduct = orderline.GetBoolean("Ecom:Order:OrderLine.IsProduct") || (orderline.GetInteger("Ecom:Order:OrderLine.Type") == 3 && !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.ProductNumber"))); 455 string productId = orderline.GetString("Ecom:Order:OrderLine.ProductID"); 456 string variantId = orderline.GetString("Ecom:Order:OrderLine.ProductVariantID"); 457 458 if (!isProduct || string.IsNullOrEmpty(productId)) return ""; 459 460 ProductViewModelSettings productSetting = new ProductViewModelSettings 461 { 462 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 463 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 464 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 465 ShopId = shopId 466 }; 467 ProductViewModel product = ViewModelFactory.CreateView(productSetting, productId, variantId); 468 return product.DefaultImage.Value; 469 } 470 471 472 string RenderOrderSummaryOrderLineItem(LoopItem orderline) 473 { 474 475 string name = orderline.GetString("Ecom:Order:OrderLine.ProductName"); 476 // string image = "/Admin/Public/GetImage.ashx?width=" + 180 + "&height=" + 180 + "&crop=5&fillcanvas=true&Background=ffffff&image=" + orderline.GetString("Ecom:Product.PrimaryImage") + "&format=webp"; 477 478 string image = "/Admin/Public/GetImage.ashx?width=" + 180 + "&height=" + 180 + "&image=" + orderline.GetString("Ecom:Product.PrimaryImage") + "&format=webp"; 479 480 481 string removeFromBasketLink = orderline.GetString("Ecom:Order:OrderLine.DeleteLink"); 482 string priceTotalWithDiscounts = orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceFormatted"); 483 string priceBefore = orderline.GetString("Ecom:Product.InformativePrice.PriceFormatted"); 484 string unitPrice = orderline.GetString("Ecom:Order:OrderLine.UnitPrice.PriceFormatted"); 485 string discountPrice = orderline.GetString("Ecom:Order:OrderLine.UnitPriceWithProductDiscount.PriceFormatted"); 486 string discountTotal = orderline.GetString("Ecom:Order:OrderLine.TotalDiscount.PriceFormatted"); 487 string variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 488 var orderlineId = orderline.GetValue("Ecom:Order:OrderLine.Id"); 489 var quantity = orderline.GetDouble("Ecom:Order:OrderLine.Quantity"); 490 var unitName = orderline.GetString("Ecom:Order:OrderLine.UnitName"); 491 string primaryGroupId = orderline.GetString("Ecom:Order:OrderLine.PrimaryOrDefaultGroupId"); 492 string productId = orderline.GetString("Ecom:Order:OrderLine.ProductID"); 493 string variantId = orderline.GetString("Ecom:Order:OrderLine.ProductVariantID"); 494 495 string link = "Default.aspx?ID=" + GetPageIdByNavigationTag("Shop"); 496 link += $"&GroupID={primaryGroupId}"; 497 link += $"&ProductID={productId}"; 498 link += !string.IsNullOrEmpty(variantId) ? $"&VariantID={variantId}" : ""; 499 500 bool isProduct = orderline.GetBoolean("Ecom:Order:OrderLine.IsProduct") || (orderline.GetInteger("Ecom:Order:OrderLine.Type") == 3 && !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.ProductNumber"))); 501 502 if (isProduct) 503 { 504 WriteLiteral(" <article class=\"grid grid-12\">\r\n\r\n <div class=\"g-col-2\">\r\n <a"); 505 BeginWriteAttribute("href", " href=\"", 46999, "\"", 47011, 1); 506 WriteAttributeValue("", 47006, link, 47006, 5, false); 507 EndWriteAttribute(); 508 WriteLiteral(" class=\"ratio ratio-1x1 d-block \""); 509 BeginWriteAttribute("title", " title=\"", 47045, "\"", 47058, 1); 510 WriteAttributeValue("", 47053, name, 47053, 5, false); 511 EndWriteAttribute(); 512 WriteLiteral(">\r\n <img"); 513 BeginWriteAttribute("src", " src=\"", 47090, "\"", 47102, 1); 514 WriteAttributeValue("", 47096, image, 47096, 6, false); 515 EndWriteAttribute(); 516 WriteLiteral(" style=\"object-fit: contain;\""); 517 BeginWriteAttribute("alt", " alt=\"", 47132, "\"", 47143, 1); 518 WriteAttributeValue("", 47138, name, 47138, 5, false); 519 EndWriteAttribute(); 520 WriteLiteral(">\r\n </a>\r\n </div>\r\n\r\n <div class=\"g-col-10\">\r\n\r\n <div class=\"d-flex flex-column gap-1\">\r\n"); 521 WriteLiteral(" <h3 class=\"h6 fs-7 m-0\">\r\n \r\n <a"); 522 BeginWriteAttribute("href", " href=\"", 47448, "\"", 47460, 1); 523 WriteAttributeValue("", 47455, link, 47455, 5, false); 524 EndWriteAttribute(); 525 WriteLiteral(" class=\"text-decoration-none\""); 526 BeginWriteAttribute("title", " title=\"", 47490, "\"", 47503, 1); 527 WriteAttributeValue("", 47498, name, 47498, 5, false); 528 EndWriteAttribute(); 529 WriteLiteral(">"); 530 Write(name); 531 WriteLiteral("</a>\r\n </h3>\r\n\r\n"); 532 if (!string.IsNullOrEmpty(variantText)) 533 { 534 WriteLiteral(" <p class=\"fs-8 m-0\">"); 535 Write(variantText); 536 WriteLiteral("</p>\r\n"); 537 } 538 WriteLiteral("\r\n"); 539 if (orderline.GetInteger("Ecom:Order:OrderLine.Type") == 3 && !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.ProductNumber"))) 540 { 541 WriteLiteral(" <p class=\"fs-8 m-0\">"); 542 Write(Translate("Free product")); 543 WriteLiteral("</p>\r\n"); 544 } 545 else 546 { 547 WriteLiteral(" <p class=\"fs-8 m-0\">\r\n"); 548 if (!string.IsNullOrEmpty(unitName)) 549 { 550 WriteLiteral(" <span>"); 551 Write(unitName); 552 WriteLiteral(": </span>\r\n"); 553 } 554 if (discountPrice == unitPrice) 555 { 556 WriteLiteral(" <span class=\"text-price\">"); 557 Write(unitPrice); 558 WriteLiteral("</span>\r\n"); 559 } 560 else 561 { 562 WriteLiteral(" <span class=\"text-price\">"); 563 Write(discountPrice); 564 WriteLiteral("</span>\r\n <span class=\"text-decoration-line-through\">\r\n <span class=\"text-price\">"); 565 Write(unitPrice); 566 WriteLiteral("</span>\r\n </span>\r\n"); 567 } 568 WriteLiteral(" </p>\r\n"); 569 } 570 WriteLiteral(" <div class=\"d-flex flex-row justify-content-between\">\r\n"); 571 WriteLiteral(" <span class=\"fs-8 d-block\">"); 572 Write(Translate("Qty")); 573 WriteLiteral(": "); 574 Write(quantity); 575 WriteLiteral("</span>\r\n\r\n <div class=\"text-end flex-fill\">\r\n"); 576 WriteLiteral(" <span class=\"h6 d-block fs-7 m-0\">\r\n <span class=\"text-price\">"); 577 Write(priceTotalWithDiscounts); 578 WriteLiteral("</span>\r\n </span>\r\n"); 579 if (orderline.GetDouble("Ecom:Order:OrderLine.TotalDiscount.Price.Value") != 0.0) 580 { 581 WriteLiteral(" <span class=\"d-block fs-8\">\r\n <span class=\"text-price\">"); 582 Write(discountTotal); 583 WriteLiteral("</span>\r\n </span>\r\n"); 584 } 585 WriteLiteral(" </div>\r\n </div>\r\n </div>\r\n </div>\r\n </article>\r\n"); 586 } 587 588 return string.Empty; 589 } 590 string RenderOrderSummary(bool renderVoucher = true) { double totalPriceWithoutOrderDiscountsFeesAndTaxesValue = GetDouble("Ecom:Order.TotalPriceWithoutDiscountsFeesAndTaxes.Price.Value") + GetDouble("Ecom:Order.TotalProductDiscount.Price.Value"); var currencyCode = string.IsNullOrWhiteSpace(GetString("Ecom:Order.Currency.Code")) ? "DKK" : GetString("Ecom:Order.Currency.Code"); var orderCurrency = Dynamicweb.Ecommerce.Services.Currencies.GetCurrency(currencyCode); string totalPriceWithoutOrderDiscountsFeesAndTaxes = Dynamicweb.Ecommerce.Services.Currencies.Format(orderCurrency, totalPriceWithoutOrderDiscountsFeesAndTaxesValue); string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower(); bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); bool disableVouchers = Pageview.CurrentParagraph.Item["DisableVouchers"] != null ? (Boolean)Pageview.CurrentParagraph.Item["DisableVouchers"] : false; WriteLiteral(" <div class=\"d-flex flex-column gap-2 gap-lg-3 pb-3 bottom-0 sticky-receipt theme\" id=\"orderSummaryFooter\">\n\n"); 591 if (renderVoucher && !disableVouchers && Pageview.CurrentParagraph.Item.SystemName != "Swift_QuoteCheckoutApp") { // @RenderVoucherForm() } WriteLiteral("\n <div class=\"fs-8 border-top pt-2 pt-lg-3\">\n"); 592 WriteLiteral(" <div class=\"d-flex justify-content-between fw-bold\">\n <span>"); 593 Write(Translate("Subtotal")); 594 WriteLiteral("</span>\n <span class=\"text-end\">\n <span class=\"d-block\">\n"); 595 if (GetDouble("Ecom:Order.TotalPriceWithoutDiscountsFeesAndTaxes.Price.Value") != totalPriceWithoutOrderDiscountsFeesAndTaxesValue) { WriteLiteral(" <span class=\"text-price fw-normal text-decoration-line-through\">"); 596 Write(GetString("Ecom:Order.TotalPriceWithoutDiscountsFeesAndTaxes.PriceFormatted")); 597 WriteLiteral("</span>\n"); 598 } WriteLiteral(" <span class=\"text-price\">"); 599 Write(totalPriceWithoutOrderDiscountsFeesAndTaxes); 600 WriteLiteral("</span>\n </span>\n\n"); 601 if (!neverShowVat && showPricesWithVat == "false") { WriteLiteral(" <span class=\"fs-8 fw-normal d-block\">"); 602 Write(Translate("Excl. VAT")); 603 WriteLiteral("</span>\n"); 604 } else if (!neverShowVat) { WriteLiteral(" <span class=\"fs-8 fw-normal d-block\">"); 605 Write(Translate("Incl. VAT")); 606 WriteLiteral("</span>\n"); 607 } WriteLiteral(" </span>\n </div>\n\n"); 608 foreach (LoopItem orderline in GetLoop("OrderLines")) { bool isDiscount = orderline.GetBoolean("Ecom:Order:OrderLine.IsDiscount"); bool isOrderDiscount = orderline.GetInteger("Ecom:Order:OrderLine.Type") == 1; if (isDiscount && isOrderDiscount) { WriteLiteral(" <div class=\"d-flex justify-content-between\"><span>"); 609 Write(orderline.GetString("Ecom:Order:OrderLine.ProductName")); 610 WriteLiteral("</span><span class=\"text-price\">"); 611 Write(orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceFormatted")); 612 WriteLiteral("</span></div>\n"); 613 } } WriteLiteral("\n"); 614 if (!string.IsNullOrEmpty(GetString("Ecom:Order.ShippingMethodID"))) { if (GetDouble("Ecom:Order.ShippingFee.Price.Value") != 0.0) { WriteLiteral(" <div class=\"d-flex justify-content-between\">\n <span>"); 615 Write(Translate("Delivery")); 616 WriteLiteral("</span>\n <span>"); 617 Write(GetString("Ecom:Order.ShippingFee.PriceFormatted")); 618 WriteLiteral("</span>\n </div>\n"); 619 } } else { WriteLiteral(" <div class=\"d-flex justify-content-between\">\n <span>"); 620 Write(Translate("Delivery")); 621 WriteLiteral("</span>\n <span>"); 622 Write(Translate("Calculated in next step")); 623 WriteLiteral("</span>\n </div>\n"); 624 } WriteLiteral("\n"); 625 if (!string.IsNullOrEmpty(GetString("Ecom:Order.PaymentMethodID"))) { if (GetDouble("Ecom:Order.PaymentFee.Price.Value") != 0) { WriteLiteral(" <div class=\"d-flex justify-content-between\">\n <span>"); 626 Write(Translate("Payment")); 627 WriteLiteral("</span>\n <span class=\"text-price\">"); 628 Write(GetString("Ecom:Order.PaymentFee.PriceFormatted")); 629 WriteLiteral("</span>\n </div>\n"); 630 } } else { WriteLiteral(" <div class=\"d-flex justify-content-between\">\n <span>"); 631 Write(Translate("Payment")); 632 WriteLiteral("</span>\n <span>"); 633 Write(Translate("Calculated in next step")); 634 WriteLiteral("</span>\n </div>\n"); 635 } WriteLiteral("\n"); 636 if (GetDouble("Ecom:Order.Taxes.Total.Price.Value") != 0) { WriteLiteral(" <div class=\"d-flex justify-content-between mb-2\">\n <span>"); 637 Write(Translate("Sales tax")); 638 WriteLiteral("</span>\n <span>"); 639 Write(GetString("Ecom:Order.Taxes.Total.PriceFormatted")); 640 WriteLiteral("</span>\n </div>\n"); 641 } WriteLiteral(" </div>\n <div class=\"fs-8 border-top pt-2 pt-lg-3\">\n <div class=\"d-flex justify-content-between fs-6 fw-bold\">\n <span>"); 642 Write(Translate("Total")); 643 WriteLiteral("</span>\n"); 644 if (!neverShowVat && showPricesWithVat == "false") { WriteLiteral(" <span class=\"text-price text-end\">\n <span class=\"fs-5 d-block\">"); 645 Write(GetString("Ecom:Order.Price.PriceFormatted")); 646 WriteLiteral("</span>\n <span class=\"fs-8 fw-normal d-block\">"); 647 Write(Translate("Excl. VAT")); 648 WriteLiteral("</span>\n </span>\n"); 649 } else if (!neverShowVat && showPricesWithVat == "true") { WriteLiteral(" <span class=\"text-price text-end\">\n <span class=\"fs-5 d-block\">"); 650 Write(GetString("Ecom:Order.Price.PriceFormatted")); 651 WriteLiteral("</span>\n <span class=\"fs-8 fw-normal d-block\">"); 652 Write(Translate("Incl. VAT")); 653 WriteLiteral("</span>\n </span>\n"); 654 } else { WriteLiteral(" <span class=\"text-price fs-5\">"); 655 Write(GetString("Ecom:Order.Price.PriceFormatted")); 656 WriteLiteral("</span>\n"); 657 } WriteLiteral(" </div>\n\n"); 658 if (!neverShowVat) { WriteLiteral(" <div class=\"d-flex justify-content-between\"><span>"); 659 Write(Translate("VAT")); 660 WriteLiteral("</span><span class=\"text-price\">"); 661 Write(GetString("Ecom:Order.Price.VATFormatted")); 662 WriteLiteral("</span></div>\n"); 663 if (showPricesWithVat == "false") { WriteLiteral(" <div class=\"d-flex justify-content-between\"><span>"); 664 Write(Translate("Total incl. VAT")); 665 WriteLiteral("</span><span class=\"text-price\">"); 666 Write(GetString("Ecom:Order.OrderLines.Total.PriceWithVAT")); 667 WriteLiteral("</span></div>\n"); 668 } } WriteLiteral("\n"); 669 if (GetDouble("Ecom:Order.TotalDiscount.Price.Value") != 0) { WriteLiteral(" <div class=\"d-flex justify-content-between\"><span>"); 670 Write(Translate("Discount")); 671 WriteLiteral("</span><span class=\"text-price\">"); 672 Write(GetString("Ecom:Order.TotalDiscount.PriceFormatted")); 673 WriteLiteral("</span></div>\n"); 674 } WriteLiteral(" </div>\n </div>\n"); 675 return string.Empty; } string RenderVoucherForm() { string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; string voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); string voucherCodeError = GetString("Ecom:Cart.ValidationError.EcomOrderVoucherCode.ErrorMessage"); var errors = new List<string>(); string validState = ""; bool vouchersAppliedAsDiscounts = false; IEnumerable<string> codes = new List<string>(); Order order = new OrderService().GetById(GetString("Ecom:Order.ID")); if (!string.IsNullOrWhiteSpace(voucherCode)) { if (order.VoucherUseType.HasFlag(VoucherUseCategoryType.Discount)) { codes = voucherCode.Split(new string[] { ",", ";", " " }, StringSplitOptions.RemoveEmptyEntries); vouchersAppliedAsDiscounts = true; } else { codes = new string[] { voucherCode.Trim() }; } } if (!vouchersAppliedAsDiscounts) { foreach (string code in codes) { Dynamicweb.Ecommerce.Orders.Vouchers.Voucher vouch = Dynamicweb.Ecommerce.Services.Vouchers.GetVoucherByCode(code); if (vouch == null) { validState = "is-invalid"; errors.Add(Translate("Voucher") + " <span class='fw-bold'>" + code + "</span> " + Translate("not found")); continue; } if (vouch.DateUsed.HasValue) { validState = "is-invalid"; errors.Add(Translate("Voucher") + " <span class='fw-bold'>" + code + "</span> " + Translate("already used")); continue; } } } WriteLiteral(" <div class=\"py-3 border-top\" id=\"orderVoucherForm\">\n\n <form method=\"post\" id=\"VoucherForm\">\n <div class=\"input-group input-primary-button-group has-validation\">\n <input type=\"text\""); 676 BeginWriteAttribute("class", " class=\"", 59967, "\"", 60001, 2); 677 WriteAttributeValue("", 59975, "form-control", 59975, 12, true); 678 WriteAttributeValue(" ", 59987, validState, 59988, 13, false); 679 EndWriteAttribute(); 680 WriteLiteral(" name=\"EcomOrderVoucherCodeField\""); 681 BeginWriteAttribute("placeholder", " placeholder=\"", 60035, "\"", 60079, 1); 682 WriteAttributeValue("", 60049, Translate("Add voucher here"), 60049, 30, false); 683 EndWriteAttribute(); 684 WriteLiteral(" id=\"EcomOrderVoucherCodeField\""); 685 BeginWriteAttribute("value", " value=\"", 60111, "\"", 60119, 0); 686 EndWriteAttribute(); 687 BeginWriteAttribute("aria-label", " aria-label=\"", 60120, "\"", 60160, 1); 688 WriteAttributeValue("", 60133, Translate("Voucher input"), 60133, 27, false); 689 EndWriteAttribute(); 690 WriteLiteral(@" onkeyup=""document.querySelector('#EcomOrderVoucherCode').value = this.value;""> <button class=""btn btn-sm btn-primary d-inline-flex align-items-center justify-content-center"" type=""submit"" id=""EcomOrderVoucherApply"" style=""min-width: 100px;""> <span>"); 691 Write(Translate("Apply")); 692 WriteLiteral("</span>\n </button>\n\n <div class=\"invalid-feedback\">\n"); 693 var errorMessage = string.Join(",", errors); WriteLiteral(" "); 694 Write(errorMessage); 695 WriteLiteral("\n </div>\n </div>\n <input type=\"hidden\" name=\"EcomOrderVoucherCode\" id=\"EcomOrderVoucherCode\""); 696 BeginWriteAttribute("value", " value=\"", 60868, "\"", 60888, 1); 697 WriteAttributeValue("", 60876, voucherCode, 60876, 12, false); 698 EndWriteAttribute(); 699 WriteLiteral(">\n <label for=\"EcomOrderVoucherCodeField\" class=\"visually-hidden\">"); 700 Write(Translate("Add voucher here")); 701 WriteLiteral("</label>\n </form>\n\n"); 702 if (!string.IsNullOrWhiteSpace(voucherCode) && vouchersAppliedAsDiscounts) { WriteLiteral(" <div class=\"d-flex flex-wrap gap-2 pt-3\">\n\n"); 703 foreach (string code in codes) { WriteLiteral(" <form method=\"post\">\n <input type=\"hidden\" name=\"EcomOrderVoucherCode\""); 704 BeginWriteAttribute("value", " value=\"", 61386, "\"", 61472, 1); 705 WriteAttributeValue("", 61394, voucherCode.Replace(code + ",", "").Replace("," + code, "").Replace(code, ""), 61394, 78, false); 706 EndWriteAttribute(); 707 WriteLiteral(@"> <span class=""badge fw-normal d-inline-flex align-items-center justify-content-center opacity-50 opacity-100-hover"" style=""background-color:var(--swift-foreground-color);color:var(--swift-background-color);""> <span class=""icon-2""> "); 708 Write(ReadFile(iconPath + "tag.svg")); 709 WriteLiteral("\n </span>\n <span class=\"mx-2\">"); 710 Write(code); 711 WriteLiteral("</span>\n <button type=\"submit\" class=\"text-reset bg-transparent border-0 p-0\""); 712 BeginWriteAttribute("aria-label", " aria-label=\"", 62037, "\"", 62078, 1); 713 WriteAttributeValue("", 62050, Translate("Remove voucher"), 62050, 28, false); 714 EndWriteAttribute(); 715 WriteLiteral(" id=\"RemoveVoucherButton\">\n <span class=\"icon-2\">\n "); 716 Write(ReadFile(iconPath + "x.svg")); 717 WriteLiteral("\n </span>\n </button>\n </span>\n </form>\n"); 718 } WriteLiteral(" </div>\n"); 719 } WriteLiteral(" "); 720 Write(voucherCodeError); 721 WriteLiteral("\n\n </div>\n"); 722 return string.Empty; } string RenderOrderSummaryToggleButton() { string iconPath = "/Files/Icons/"; WriteLiteral(@" <button class=""toggle-order-summary btn text-reset w-100 d-block d-lg-none px-0"" type=""button"" data-bs-toggle=""collapse"" data-bs-target=""#orderSummary"" aria-expanded=""false"" aria-controls=""orderSummary"" id=""OrderSummaryToggleButton""> <span class=""d-flex align-items-center justify-content-between""> <span class=""d-flex align-items-center gap-2""> <span class=""fs-7 lh-1""> <span class=""toggle-order-summary-text"" id=""OrderSummaryToggleButtonLabel"">"); 723 Write(Translate("Show order summary")); 724 WriteLiteral("</span>\n </span>\n <span class=\"icon-2\" id=\"OrderSummaryToggleButtonIcon\" style=\"transition: all 0.25s ease-in-out;\">\n "); 725 Write(ReadFile(iconPath + "chevron-down.svg")); 726 WriteLiteral("\n </span>\n </span>\n <span class=\"fw-bold\"><span class=\"text-price\">"); 727 Write(GetString("Ecom:Order.Price")); 728 WriteLiteral("</span>\n </span>\n </span>\n </button>\n"); 729 WriteLiteral(@" <script> const orderSummaryToggleButton = document.getElementById(""OrderSummaryToggleButton""); const orderSummaryToggleButtonLabel = document.getElementById(""OrderSummaryToggleButtonLabel""); const orderSummaryToggleButtonIcon = document.getElementById(""OrderSummaryToggleButtonIcon""); const orderSummaryToggleText = '"); 730 Write(Translate("Show order summary")); 731 WriteLiteral("\';\n\n\t\torderSummaryToggleButton.addEventListener(\'click\', function handleClick() {\n\t\t\tif (orderSummaryToggleButtonLabel.textContent.toLowerCase().includes(orderSummaryToggleText.toLowerCase())) {\n\t\t\t\torderSummaryToggleButtonLabel.textContent = \'"); 732 Write(Translate("Hide order summary")); 733 WriteLiteral("\';\n\t\t\t\torderSummaryToggleButtonIcon.classList.add(\"rotate-180\");\n\t\t\t} else {\n\t\t\t\torderSummaryToggleButtonLabel.textContent = orderSummaryToggleText;\n\t\t\t\torderSummaryToggleButtonIcon.classList.remove(\"rotate-180\");\n\t\t\t}\n\t\t});\n\t</script>\n"); 734 return string.Empty; } public string RenderDeliveryAddressInline() { List<List<string>> addressFormat = Dynamicweb.Ecommerce.International.Country.GetDisplayAddress(GetString("Ecom:Order.Delivery.Country.Code")); var result = new StringBuilder(); foreach (List<string> addressLine in addressFormat) { for (var i = 0; i < addressLine.Count; i++) { addressLine[i] = Regex.Replace(addressLine[i], "{name}", GetString("Ecom:Order.Delivery.Name"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{firstName}", GetString("Ecom:Order.Delivery.FirstName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{lastName}", GetString("Ecom:Order.Delivery.Surname"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{company}", GetString("Ecom:Order.Delivery.Company"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address}", GetString("Ecom:Order.Delivery.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address1}", GetString("Ecom:Order.Delivery.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address2}", GetString("Ecom:Order.Delivery.Address2"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{zip}", GetString("Ecom:Order.Delivery.Zip"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{city}", GetString("Ecom:Order.Delivery.City"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{regionCode}", GetString("Ecom:Order.Delivery.Region"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{region}", GetDeliveryRegionName(), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{countryCode}", GetString("Ecom:Order.Delivery.Country.Code"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{country}", GetString("Ecom:Order.Delivery.Country"), RegexOptions.IgnoreCase); // Remove any bad placeholders the user may have submitted addressLine[i] = Regex.Replace(addressLine[i], "{phone}", "", RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{email}", "", RegexOptions.IgnoreCase); } var completeLine = string.Join(string.Empty, addressLine.ToArray()); if (!string.IsNullOrWhiteSpace(completeLine)) { result.Append($"<span>{completeLine}</span>"); if (addressLine != addressFormat.Last()) { result.Append(" "); } } } return result.ToString(); } public string GetDeliveryAddressString() { List<List<string>> addressFormat = Dynamicweb.Ecommerce.International.Country.GetDisplayAddress(GetString("Ecom:Order.Delivery.Country.Code")); List<string> completeAddress = new List<string>(); foreach (var addressLine in addressFormat) { for (var i = 0; i < addressLine.Count; i++) { addressLine[i] = Regex.Replace(addressLine[i], "{name}", GetString("Ecom:Order.Delivery.Name"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{firstName}", GetString("Ecom:Order.Delivery.FirstName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{lastName}", GetString("Ecom:Order.Delivery.LastName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{company}", GetString("Ecom:Order.Delivery.Company"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address}", GetString("Ecom:Order.Delivery.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address1}", GetString("Ecom:Order.Delivery.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address2}", GetString("Ecom:Order.Delivery.Address2"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{zip}", GetString("Ecom:Order.Delivery.Zip"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{city}", GetString("Ecom:Order.Delivery.City"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{regionCode}", GetString("Ecom:Order.Delivery.Region"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{region}", GetDeliveryRegionName(), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{countryCode}", GetString("Ecom:Order.Delivery.Country.Code"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{country}", GetString("Ecom:Order.Delivery.Country"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{phone}", GetString("Ecom:Order.Delivery.Phone"), RegexOptions.IgnoreCase); // Remove any bad placeholders the user may have submitted addressLine[i] = Regex.Replace(addressLine[i], "{phone}", "", RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{email}", "", RegexOptions.IgnoreCase); } var completeLine = string.Join(string.Empty, addressLine.ToArray()); if (!string.IsNullOrWhiteSpace(completeLine)) { completeAddress.Add(completeLine); } } return string.Join(", ", completeAddress.ToArray()); } public string GetDeliveryRegionName() { foreach (LoopItem region in GetLoop("DeliveryRegions")) { if (region.GetBoolean("Ecom:DeliveryRegion.IsDeliveryRegion")) { return region.GetString("Ecom:DeliveryRegion.Name"); } } return GetString("Ecom:Order.Delivery.Region"); } public string RenderUserItemAddressInline(LoopItem address) { string regionCode = GetRegionCode(address.GetString("UserManagement:User.UserAddress.CountryCode"), address.GetString("UserManagement:User.UserAddress.State")); string regionName = GetRegionName(address.GetString("UserManagement:User.UserAddress.CountryCode"), address.GetString("UserManagement:User.UserAddress.State")); List<List<string>> addressFormat = Dynamicweb.Ecommerce.International.Country.GetDisplayAddress(address.GetString("UserManagement:User.UserAddress.CountryCode")); var result = new StringBuilder(); foreach (List<string> addressLine in addressFormat) { for (var i = 0; i < addressLine.Count; i++) { addressLine[i] = Regex.Replace(addressLine[i], "{name}", address.GetString("UserManagement:User.UserAddress.Name"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{firstName}", address.GetString("UserManagement:User.UserAddress.FirstName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{lastName}", address.GetString("UserManagement:User.UserAddress.lastName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{company}", address.GetString("UserManagement:User.UserAddress.Company"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address}", address.GetString("UserManagement:User.UserAddress.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address1}", address.GetString("UserManagement:User.UserAddress.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address2}", address.GetString("UserManagement:User.UserAddress.Address2"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{zip}", address.GetString("UserManagement:User.UserAddress.Zip"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{city}", address.GetString("UserManagement:User.UserAddress.City"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{regionCode}", regionCode, RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{region}", regionName, RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{countryCode}", address.GetString("UserManagement:User.UserAddress.Culture.CountryCode"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{country}", address.GetString("UserManagement:User.UserAddress.Culture.CountryName"), RegexOptions.IgnoreCase); // Remove any bad placeholders the user may have submitted addressLine[i] = Regex.Replace(addressLine[i], "{phone}", "", RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{email}", "", RegexOptions.IgnoreCase); } var completeLine = string.Join(string.Empty, addressLine.ToArray()); if (!string.IsNullOrWhiteSpace(completeLine)) { result.Append($"<span>{completeLine}</span> "); } } return result.ToString(); } public string GetUserAddressString() { List<List<string>> addressFormat = Dynamicweb.Ecommerce.International.Country.GetDisplayAddress(GetString("UserManagement:User.CountryCode")); string regionCode = GetRegionCode(GetString("UserManagement:User.CountryCode"), GetString("UserManagement:User.State")); string regionName = GetRegionName(GetString("UserManagement:User.CountryCode"), GetString("UserManagement:User.State")); List<string> completeAddress = new List<string>(); foreach (var addressLine in addressFormat) { for (var i = 0; i < addressLine.Count; i++) { addressLine[i] = Regex.Replace(addressLine[i], "{name}", GetString("UserManagement:User.Name"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{firstName}", GetString("UserManagement:User.FirstName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{lastName}", GetString("UserManagement:User.LastName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{company}", GetString("UserManagement:User.Company"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address}", GetString("UserManagement:User.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address1}", GetString("UserManagement:User.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address2}", GetString("UserManagement:User.Address2"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{zip}", GetString("UserManagement:User.Zip"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{city}", GetString("UserManagement:User.City"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{regionCode}", regionCode, RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{region}", regionName, RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{countryCode}", GetString("UserManagement:User.CountryCode"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{country}", GetString("UserManagement:User.Culture.CountryName"), RegexOptions.IgnoreCase); // Remove any bad placeholders the user may have submitted addressLine[i] = Regex.Replace(addressLine[i], "{phone}", "", RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{email}", "", RegexOptions.IgnoreCase); } var completeLine = string.Join(string.Empty, addressLine.ToArray()); if (!string.IsNullOrWhiteSpace(completeLine)) { completeAddress.Add(completeLine); } } return string.Join(" ", completeAddress.ToArray()); } public string GetRegionName(string countryCode, string regionValue) { return GetRegionNameOrCode(countryCode, regionValue); } public string GetRegionCode(string countryCode, string regionValue) { return GetRegionNameOrCode(countryCode, regionValue, "code"); } public string GetRegionNameOrCode(string countryCode, string regionValue, string nameOrCode = "name") { CountryCollection allCountryRegions = Dynamicweb.Ecommerce.Services.Countries.GetRegions(countryCode); Country matchedRegion = allCountryRegions.FirstOrDefault(r => r.RegionCode == regionValue || r.GetName(Dynamicweb.Ecommerce.Common.Context.LanguageID) == regionValue); if (matchedRegion == null) return regionValue; return nameOrCode == "name" ? matchedRegion.GetName(Dynamicweb.Ecommerce.Common.Context.LanguageID) : matchedRegion.RegionCode; } } 735 } 736 #pragma warning restore 1591 737
1 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb @using Dynamicweb.Rendering @using System.IO @using Dynamicweb.Environment @{ string googleTagManagerID = Pageview.AreaSettings.GetString("GoogleTagManagerID"); string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID"); bool allowTracking = true; if (CookieManager.IsCookieManagementActive) { var cookieOptInLevel = CookieManager.GetCookieOptInLevel(); allowTracking = cookieOptInLevel == CookieOptInLevel.All || (cookieOptInLevel == CookieOptInLevel.Functional && CookieManager.GetCookieOptInCategories().Contains("Statistical")); } List<string> addressList = new List<string>(); if (!string.IsNullOrEmpty(GetString("UserManagement:User.Address"))) { addressList.Add(GetString("UserManagement:User.Address")); } if (!string.IsNullOrEmpty(GetString("UserManagement:User.Zip"))) { addressList.Add(GetString("UserManagement:User.Zip")); } if (!string.IsNullOrEmpty(GetString("UserManagement:User.City"))) { addressList.Add(GetString("UserManagement:User.City")); } string addressString = (string.Join(",", addressList.Select(x => x.ToString()).ToArray())); var themeRaw = Pageview.CurrentParagraph.Item["Theme"]?.ToString(); string theme = !string.IsNullOrEmpty(themeRaw) ? " theme " + themeRaw.Replace(" ", "").Trim().ToLower() : ""; } <div class="grid gap-0 h-100"> <div class="g-col-12 g-col-lg-8 p-3 p-lg-4 pe-xl-5 ps-xl-6 ps-xxl-8 order-last order-lg-first@(theme)"> <form name="ordersubmit" id="ordersubmit" method="post" autocomplete="off" style="max-width: 65rem; margin-left: auto;"> @{ @RenderLogo() @RenderStepsBreadcrumbs() @RenderErrors() @RenderStepSummary() } <input type="hidden" id="CurrentStep"> <input type="hidden" name="EcomOrderCustomerEmail" value="@GetString("UserManagement:User.Email")"> <input type="hidden" name="EcomOrderCustomerPhone" value="@GetString("UserManagement:User.Phone")"> <input type="hidden" name="EcomOrderCustomerCompany" value="@GetString("UserManagement:User.Company")"> <input type="hidden" name="EcomOrderCustomerAddress" value="@GetString("UserManagement:User.Address")"> <input type="hidden" name="EcomOrderCustomerZip" value="@GetString("UserManagement:User.Zip")"> <input type="hidden" name="EcomOrderCustomerCity" value="@GetString("UserManagement:User.City")"> <input type="hidden" name="EcomOrderCustomerRegion" value="@GetString("UserManagement:User.State")"> <input type="hidden" name="EcomOrderCustomerCountry" value="@GetString("UserManagement:User.CountryCode")"> @{ @RenderAddressUser() } @if (!string.IsNullOrWhiteSpace(addressString)) { {@RenderStepsNavigation()} } </form> </div> @{@RenderSummarySidebar()} </div> <script> function submitForm() { document.querySelector("#CurrentStep").name = "@GetString("CartV2.CurrentStepButtonName")"; swift.PageUpdater.Update(document.querySelector("#ordersubmit")); } </script> @if ((!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) || !string.IsNullOrWhiteSpace(googleTagManagerID)) && allowTracking) { <script> gtag("event", "begin_checkout", { currency: "@GetString("Ecom:Order.CurrencyCode")", value: @GetDouble("Ecom:Order.Price.Price.Value").ToString("0.00", System.Globalization.CultureInfo.InvariantCulture), items: [ @foreach (LoopItem orderline in GetLoop("OrderLines")) { <text> { item_id: "@orderline.GetString("Ecom:Order:OrderLine.ProductID")", item_name: "@Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(orderline.GetString("Ecom:Order:OrderLine.ProductName"))", currency: "@orderline.GetString("Ecom:Order:OrderLine.UnitPrice.CurrencyCode")", price: @orderline.GetDouble("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.Price.Value").ToString("0.00", System.Globalization.CultureInfo.InvariantCulture), quantity: @orderline.GetDouble("Ecom:Order:OrderLine.Quantity").ToString("0.00", System.Globalization.CultureInfo.InvariantCulture) }, </text> } ] }); </script> } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using System.IO @functions { string RenderLogo() { string logoLink = Pageview.CurrentParagraph.Item["LogoLink"] != null ? Pageview.CurrentParagraph.Item["LogoLink"].ToString() : ""; <div class="mb-4 text-center"> @if (!string.IsNullOrWhiteSpace(logoLink)) { <a href="@logoLink" class="text-decoration-none" title="@Translate("Leave checkout")"> @RenderLogoImage() </a> } else { <text>@RenderLogoImage()</text> } </div> return string.Empty; } string RenderLogoImage() { string logoImage = Pageview.CurrentParagraph.Item["Logo"] != null ? Pageview.CurrentParagraph.Item["Logo"].ToString() : ""; string maxWidth = Pageview.CurrentParagraph.Item["MaxWidth"] != null ? "max-width: " + Pageview.CurrentParagraph.Item["MaxWidth"].ToString() + "px" : ""; string title = Pageview.CurrentParagraph.Item["Title"] != null ? Pageview.CurrentParagraph.Item["Title"].ToString() : Pageview.Area.Name; maxWidth = maxWidth == "max-width: 0px" ? "" : maxWidth; if (logoImage != "") { if (Path.GetExtension(logoImage).ToLower() == ".svg") { <div class="icon-auto" style="@maxWidth"> @ReadFile(logoImage) </div> } else { string imageWidth = Pageview.CurrentParagraph.Item["MaxWidth"] != null ? Pageview.CurrentParagraph.Item["MaxWidth"].ToString() : "400"; string imagePath = "/Admin/Public/GetImage.ashx?width=" + imageWidth + "&image=" + logoImage; <picture class="mx-auto d-block"> <img src="@logoImage" alt="@title" style="@maxWidth"> </picture> } } else { <div class="fs-3 p-0">@title</div> } return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb.Ecommerce.Cart @functions { string RenderStepsBreadcrumbs() { bool isPaymentStep = GetLoop("StepButtons").Count == 0; <nav aria-label="breadcrumb" class="mb-3 mb-md-4 fs-8" id="StepsBreadcrumbs"> <ol class="breadcrumb"> @foreach (LoopItem step in GetLoop("StepButtons")) { if (step.GetString("Step.Name").ToLower() != "checkout") { if (step.GetBoolean("Step.Current")) { <li class="breadcrumb-item fw-bold" aria-current="location">@Translate(step.GetString("Step.Name"))</li> } else { <li class="breadcrumb-item">@Translate(step.GetString("Step.Name"))</li> } } } @if (isPaymentStep) { var cartSettings = new ModuleSettings(Pageview.CurrentParagraph.ModuleProperties); foreach (CartStepInfo step in cartSettings.Steps) { if (step.IsCheckout) { <li class="breadcrumb-item fw-bold" aria-current="location">@Translate(step.Name)</li> break; } else { <li class="breadcrumb-item">@Translate(step.Name)</li> } } } </ol> </nav> return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb.Ecommerce.Orders @functions { string RenderErrors(){ if (GetLoop("ValidationErrors").Count() != 0) { <div class="alert alert-warning" role="alert"> <ul class="m-0 list-unstyled"> @foreach (LoopItem item in GetLoop("ValidationErrors")) { <li>@item.GetValue("Ecom:Cart.ValidationError.ErrorMessage")</li> } </ul> </div> } return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions{ string RenderStepSummary() { bool isPaymentStep = GetLoop("StepButtons").Count == 0; int currentStep = !isPaymentStep ? 1 : 4; int currentUserId = Dynamicweb.Core.Converter.ToInt32(GetGlobalValue("Global:Extranet.UserID")); foreach (LoopItem step in GetLoop("StepButtons")) { if (step.GetBoolean("Step.Current")) { currentStep = step.GetInteger("Step.Number"); } } if (!string.IsNullOrEmpty(GetString("UserManagement:User.Address")) || !string.IsNullOrEmpty(GetString("Ecom:Order.ShippingMethodID")) || !string.IsNullOrEmpty(GetString("Ecom:Order.PaymentMethodID")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Name")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Company")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Address")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Address2")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Zip")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.City")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Email")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Phone")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Name")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Company")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Address")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Address2")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Zip")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.City")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Email")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Phone")) || !string.IsNullOrEmpty(GetString("Ecom:Order.ShippingMethod")) || !string.IsNullOrEmpty(GetString("Ecom:Order.ShippingDate")) || !string.IsNullOrEmpty(GetString("Ecom:Order.PaymentMethod"))) { @* User *@ if (currentUserId != 0) { <div class="list-group mb-5"> @{ @RenderStepSummaryOrderCustomer() @RenderStepSummaryUser() } @if (currentStep != 1) { { @RenderStepSummaryOrderDelivery() @RenderStepSummaryDeliveryMethod() @RenderStepSummaryDeliveryDate() } } </div> } @* Anonymous *@ else { if (currentStep != 1) { <div class="list-group"> @{ @RenderStepSummaryOrderCustomer() @RenderStepSummaryOrderDelivery() } @if (currentStep > 2) { { @RenderStepSummaryDeliveryMethod() @RenderStepSummaryDeliveryDate() } } @if (currentStep > 3) { { @RenderStepSummaryPaymentMethod() @RenderStepSummaryOrderReference() } } </div> } } } return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderStepSummaryOrderCustomer() { var hideEditBillingAddress = Pageview.CurrentParagraph?.Item["HideEditBillingAddress"] != null ? Convert.ToBoolean(Pageview.CurrentParagraph.Item["HideEditBillingAddress"].ToString()) : false; int currentUserId = Dynamicweb.Core.Converter.ToInt32(GetGlobalValue("Global:Extranet.UserID")); List<string> contact = new List<string>(); if (!string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Email")) || !string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Phone"))) { if (!string.IsNullOrEmpty(GetString("Ecom:Order.Customer.Email"))) { contact.Add(GetString("Ecom:Order.Customer.Email")); } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Phone"))) { contact.Add(GetString("Ecom:Order.Delivery.Phone")); } } string contactString = (string.Join(",", contact.Select(x => x.ToString()).ToArray())).Replace(",", ", "); string userAccountPage = Pageview.CurrentParagraph.Item["UserAccountPageLink"] != null ? Pageview.CurrentParagraph.Item["UserAccountPageLink"].ToString() + "&GoBackToPage=" + Pageview.Page.ID : ""; if (!string.IsNullOrEmpty(contactString)) { <div class="list-group-item py-2 fs-7" style="background-color: rgba(var(--swift-foreground-color-rgb), 0.05)" id="ContactGroup"> <dl class="grid gap-1 gap-sm-3 mb-0"> <dt class="g-col-8 g-col-sm-4 fw-normal">@Translate("Contact")</dt> <dd class="g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0">@contactString</dd> @if (!hideEditBillingAddress) { <dd class="g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end"> @if (currentUserId == 0) { <button type="submit" class="btn btn-small btn-link fs-8 p-0" name="CartV2.GotoStep0" id="EditBillingAddressButton"> <span class="text-uppercase">@Translate("Edit")</span> </button> } else { <a href="@userAccountPage" class="btn btn-small btn-link fs-8 p-0" id="EditBillingAddressButton"> <span class="text-uppercase">@Translate("Edit")</span> </a> } </dd> } </dl> </div> } return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderStepSummaryOrderDelivery() { var hideEditBillingAddress = Pageview.CurrentParagraph?.Item["HideEditBillingAddress"] != null ? Convert.ToBoolean(Pageview.CurrentParagraph.Item["HideEditBillingAddress"].ToString()) : false; int fieldCount = 0; //Helps us render addresses that contains more than just the auto set country bool isStandardSwiftTemplates = Pageview.AreaSettings.GetString("AddressFieldsBasedOn", "swift") == "swift"; string addressString = ""; if (isStandardSwiftTemplates) { List<string> address = new List<string>(); if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Company"))) { address.Add(GetString("Ecom:Order.Delivery.Company")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Name"))) { address.Add(GetString("Ecom:Order.Delivery.Name")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Address"))) { address.Add(GetString("Ecom:Order.Delivery.Address")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Address2"))) { address.Add(GetString("Ecom:Order.Delivery.Address2")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Zip"))) { address.Add(GetString("Ecom:Order.Delivery.Zip")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.City"))) { address.Add(GetString("Ecom:Order.Delivery.City")); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Region"))) { string regionName = GetString("Ecom:Order.Delivery.Region"); foreach (LoopItem region in GetLoop("DeliveryRegions")) { if (region.GetString("Ecom:DeliveryRegion.IsDeliveryRegion") == "true") { regionName = region.GetString("Ecom:DeliveryRegion.Name"); } } address.Add(regionName); fieldCount++; } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Country"))) { address.Add(GetString("Ecom:Order.Delivery.Country")); fieldCount++; } addressString = (string.Join(",", address.Select(x => x.ToString()).ToArray())).Replace(",", ", "); } else { addressString = GetDeliveryAddressString(); } string editStep = "CartV2.GotoStep0"; if (!string.IsNullOrEmpty(addressString) && ((isStandardSwiftTemplates && fieldCount > 1) || !isStandardSwiftTemplates)) { <div class="list-group-item py-2 fs-7" style="background-color: rgba(var(--swift-foreground-color-rgb), 0.05)"> <dl class="grid gap-1 gap-sm-3 mb-0"> <dt class="g-col-8 g-col-sm-4 fw-normal">@Translate("Send to")</dt> <dd class="g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0">@addressString</dd> @if (!hideEditBillingAddress) { <dd class="g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end"> <button class="btn btn-small btn-link fs-8 p-0" type="submit" name="@editStep" id="EditDeliveryAddressButton"> <span class="text-uppercase">@Translate("Edit")</span> </button> </dd> } </dl> </div> } return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb @functions { string RenderStepSummaryUser() { var hideEditBillingAddress = Pageview.CurrentParagraph?.Item["HideEditBillingAddress"] != null ? Convert.ToBoolean(Pageview.CurrentParagraph.Item["HideEditBillingAddress"].ToString()) : false; int fieldCount = 0; //Helps us render addresses that contains more than just the auto set country bool isStandardSwiftTemplates = Pageview.AreaSettings.GetString("AddressFieldsBasedOn", "swift") == "swift"; string addressString = ""; if (isStandardSwiftTemplates) { Dynamicweb.Security.UserManagement.User user = Pageview.User; List<string> address = new List<string>(); if (!string.IsNullOrEmpty(user.Company)) { address.Add(user.Company); fieldCount++; } if (!string.IsNullOrEmpty(user.Name)) { address.Add(user.Name); fieldCount++; } if (!string.IsNullOrEmpty(user.Address)) { address.Add(user.Address); fieldCount++; } if (!string.IsNullOrEmpty(user.Address2)) { address.Add(user.Address2); fieldCount++; } if (!string.IsNullOrEmpty(user.Zip)) { address.Add(user.Zip); fieldCount++; } if (!string.IsNullOrEmpty(user.City)) { address.Add(user.City); fieldCount++; } if (!string.IsNullOrEmpty(user.State)) { var countryCode = user.CountryCode; string stateName = Dynamicweb.Ecommerce.Services.Countries.GetRegion(countryCode, user.State)?.GetName(Dynamicweb.Ecommerce.Common.Context.LanguageID) ?? string.Empty; address.Add(stateName); fieldCount++; } if (!string.IsNullOrEmpty(user.CountryCode)) { string country = user.Region.DisplayName; address.Add(country); fieldCount++; } addressString = (string.Join(",", address.Select(x => x.ToString()).ToArray())).Replace(",", ", "); } else { addressString = GetUserAddressString(); } string editStep = Pageview.CurrentParagraph.Item["UserAccountPageLink"] != null ? Pageview.CurrentParagraph.Item["UserAccountPageLink"].ToString() + "&GoBackToPage=" + Pageview.Page.ID : ""; if (!string.IsNullOrEmpty(addressString) && ((isStandardSwiftTemplates && fieldCount > 1) || !isStandardSwiftTemplates)) { <div class="list-group-item py-2 fs-7" style="background-color: rgba(var(--swift-foreground-color-rgb), 0.05)"> <dl class="grid gap-1 gap-sm-3 mb-0"> <dt class="g-col-8 g-col-sm-4 fw-normal">@Translate("Billing address")</dt> <dd class="g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0">@addressString</dd> @if (!hideEditBillingAddress) { <dd class="g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end"> <a href="@editStep" class="btn btn-small btn-link fs-8 p-0" id="EditBillingAddressButton"> <span class="text-uppercase">@Translate("Edit")</span> </a> </dd> } </dl> </div> } return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderStepSummaryDeliveryMethod() { string shippingMethod = GetString("Ecom:Order.ShippingMethod"), editStep = "CartV2.GotoStep1"; if (!string.IsNullOrEmpty(shippingMethod)) { <div class="list-group-item py-2 fs-7" style="background-color: rgba(var(--swift-foreground-color-rgb), 0.05)"> <dl class="grid gap-1 gap-sm-3 mb-0"> <dt class="g-col-8 g-col-sm-4 fw-normal">@Translate("Delivery")</dt> <dd class="g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0">@shippingMethod</dd> <dd class="g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end"> <button class="btn btn-small btn-link fs-8 p-0" type="submit" name="@editStep" id="EditDeliveryButton"> <span class="text-uppercase">@Translate("Edit")</span> </button> </dd> </dl> </div> } return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderStepSummaryPaymentMethod() { string PaymentMethodID = GetString("Ecom:Order.ShippingMethodID"); string paymentMethod = GetString("Ecom:Order.PaymentMethod"); string editStep = "CartV2.GotoStep2"; if (!string.IsNullOrEmpty(PaymentMethodID)) { <div class="list-group-item d-flex gap-3 align-items-baseline py-2 fs-7" style="background-color: rgba(var(--swift-foreground-color-rgb), 0.05)"> <div class="flex-grow-1"> <dl class="grid mb-0"> <dt class="g-col-12 g-col-md-4 mb-lg-0 lh-base fw-normal">@Translate("Payment")</dt> <dd class="g-col-12 g-col-md-8 mb-0"> @paymentMethod </dd> </dl> </div> <button class="btn btn-small btn-link fs-8" type="submit" name="@editStep" id="EditPaymentButton"> <span class="text-uppercase">@Translate("Edit")</span> </button> </div> } return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderStepSummaryDeliveryDate() { string shippingDate = GetString("Ecom:Order.ShippingDate"), shippingDateFormatted = GetDate("Ecom:Order.ShippingDate").ToShortDateString(), editStep = "CartV2.GotoStep1"; if (!string.IsNullOrEmpty(shippingDate)) { <div class="list-group-item py-2 fs-7" style="background-color: rgba(var(--swift-foreground-color-rgb), 0.05)"> <dl class="grid gap-1 gap-sm-3 mb-0"> <dt class="g-col-8 g-col-sm-4 fw-normal">@Translate("Delivery date")</dt> <dd class="g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0">@shippingDateFormatted</dd> <dd class="g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end"> <button class="btn btn-small btn-link fs-8 p-0" type="submit" name="@editStep" id="EditDeliveryDateButton"> <span class="text-uppercase">@Translate("Edit")</span> </button> </dd> </dl> </div> } return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderStepSummaryOrderReference() { string orderReference = !string.IsNullOrWhiteSpace(GetString("Ecom:Order.Reference")) ? GetString("Ecom:Order.Reference") : "", editStep = "CartV2.GotoStep2"; if (!string.IsNullOrEmpty(orderReference)) { <div class="list-group-item py-2 fs-7" style="background-color: rgba(var(--swift-foreground-color-rgb), 0.05)"> <dl class="grid gap-1 gap-sm-3 mb-0"> <dt class="g-col-8 g-col-sm-4 fw-normal">@Translate("Order reference")</dt> <dd class="g-col-12 g-col-sm-7 order-2 order-sm-1 mb-0">@orderReference</dd> <dd class="g-col-4 g-col-sm-1 order-1 order-sm-2 mb-0 text-end"> <button class="btn btn-small btn-link fs-8 p-0" type="submit" name="@editStep" id="EditorderReferenceButton"> <span class="text-uppercase">@Translate("Edit")</span> </button> </dd> </dl> </div> } return string.Empty; } } @helper RenderAddressUser() { var hideEditShippingAddress = Pageview.CurrentParagraph?.Item["HideEditShippingAddress"] != null ? Convert.ToBoolean(Pageview.CurrentParagraph.Item["HideEditShippingAddress"].ToString()) : false; string userAccountPage = Pageview.CurrentParagraph.Item["UserAccountPageLink"] != null ? Pageview.CurrentParagraph.Item["UserAccountPageLink"].ToString() + "&GoBackToPage=" + Pageview.Page.ID : ""; string userAddressesPage = Pageview.CurrentParagraph.Item["UserAddressesPageLink"] != null ? Pageview.CurrentParagraph.Item["UserAddressesPageLink"].ToString() + "&GoBackToPage=" + Pageview.Page.ID : ""; string userId = GetString("UserManagement:User.ID"); var userAddressLoop = GetLoop("UserManagement:User.UserAddresses"); bool userHasDefaultAddress = false; bool userAddressSelected = false; foreach (LoopItem userAddress in userAddressLoop) { if (userAddress.GetBoolean("UserManagement:User.UserAddress.Default")) { userHasDefaultAddress = true; } if (userAddress.GetBoolean("UserManagement:User.UserAddress.SelectedForDeliveryFields")) { userAddressSelected = true; } } List<string> address = new List<string>(); if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Address"))) { address.Add(GetString("Ecom:Order.Delivery.Address")); } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Address2"))) { address.Add(GetString("Ecom:Order.Delivery.Address2")); } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Zip"))) { address.Add(GetString("Ecom:Order.Delivery.Zip")); } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.City"))) { address.Add(GetString("Ecom:Order.Delivery.City")); } if (!string.IsNullOrEmpty(GetString("Ecom:Order.Delivery.Country"))) { address.Add(GetString("Ecom:Order.Delivery.Country")); } string deliveryAddressString = (string.Join(",", address.Select(x => x.ToString()).ToArray())); List<string> addressList = new List<string>(); if (!string.IsNullOrEmpty(GetString("UserManagement:User.Address"))) { addressList.Add(GetString("UserManagement:User.Address")); } if (!string.IsNullOrEmpty(GetString("UserManagement:User.Address2"))) { addressList.Add(GetString("UserManagement:User.Address2")); } if (!string.IsNullOrEmpty(GetString("UserManagement:User.Zip"))) { addressList.Add(GetString("UserManagement:User.Zip")); } if (!string.IsNullOrEmpty(GetString("UserManagement:User.City"))) { addressList.Add(GetString("UserManagement:User.City")); } if (!string.IsNullOrEmpty(GetString("UserManagement:User.State"))) { var countryCode = !string.IsNullOrEmpty(GetString("UserManagement:User.CountryCode")) ? GetString("UserManagement:User.CountryCode") : Pageview.Area.EcomCountryCode; string stateName = Dynamicweb.Ecommerce.Services.Countries.GetRegion(countryCode, GetString("UserManagement:User.State"))?.GetName(Dynamicweb.Ecommerce.Common.Context.LanguageID) ?? string.Empty; addressList.Add(stateName); } if (!string.IsNullOrEmpty(GetString("UserManagement:User.Country"))) { addressList.Add(GetString("UserManagement:User.Country")); } string selectedAddress = Dynamicweb.Context.Current.Request.Form.Get("EcomOrderDeliverySelectedAddressId") ?? ""; string addressString = (string.Join(",", addressList.Select(x => x.ToString()).ToArray())); string useBillingIsChecked = !userAddressSelected || selectedAddress == "" || selectedAddress == "-1" ? "checked" : ""; string disabled = addressString == deliveryAddressString || string.IsNullOrEmpty(deliveryAddressString) || string.IsNullOrEmpty(addressString) ? "" : "disabled"; disabled = userAddressSelected && userHasDefaultAddress ? "disabled" : disabled; bool isStandardSwiftTemplates = Pageview.AreaSettings.GetString("AddressFieldsBasedOn", "swift") == "swift"; //Billing address is missing if (string.IsNullOrWhiteSpace(addressString)) { <div class="text-center border p-5"> <h3 class="mb-4">@Translate("You do not have any address yet")</h3> <a href="@userAccountPage" class="btn btn-primary" id="CreateNewAddressButton">@Translate("Create new address")</a> </div> } else { <div class="mt-4"> <div class="d-flex justify-content-between mb-3"> <h3 class="fs-6 fw-normal m-0">@Translate("Select delivery address")</h3> @if (!hideEditShippingAddress) { <a href="@userAddressesPage" class="m-0 h6 fw-normal d-none d-md-block" id="ManageAddressesButton">@Translate("Manage your addresses")</a> } </div> </div> <div class="list-group" id="SelectDeliveryAddressGroup"> <label class="list-group-item list-group-item-action"> <div class="form-check"> <input class="form-check-input" type="radio" name="EcomOrderDeliverySelectedAddressId" id="EcomOrderDeliverySelectedAddressId_@GetString("UserManagement:User.ID")" value="-1" @useBillingIsChecked onclick="useBillingAddress()"> <span class="form-check-label">@Translate("Same as the billing address")</span> <input @disabled type="hidden" name="EcomOrderDeliveryName" value="@GetString("UserManagement:User.Name")"> <input @disabled type="hidden" name="EcomOrderDeliveryEmail" value="@GetString("UserManagement:User.Email")"> <input @disabled type="hidden" name="EcomOrderDeliveryPhone" value="@GetString("UserManagement:User.Phone")"> <input @disabled type="hidden" name="EcomOrderDeliveryCompany" value="@GetString("UserManagement:User.Company")"> <input @disabled type="hidden" name="EcomOrderDeliveryAddress" value="@GetString("UserManagement:User.Address")"> <input @disabled type="hidden" name="EcomOrderDeliveryAddress2" value="@GetString("UserManagement:User.Address2")"> <input @disabled type="hidden" name="EcomOrderDeliveryZip" value="@GetString("UserManagement:User.Zip")"> <input @disabled type="hidden" name="EcomOrderDeliveryCity" value="@GetString("UserManagement:User.City")"> <input @disabled type="hidden" name="àEcomOrderDeliveryRegion" value="@GetString("UserManagement:User.State")"> <input @disabled type="hidden" name="EcomOrderDeliveryCountry" value="@GetString("UserManagement:User.CountryCode")"> </div> </label> @foreach (LoopItem userAddress in userAddressLoop) { string addressId = userAddress.GetString("UserManagement:User.UserAddress.ID"); List<string> userAddressList = new List<string>(); if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.Address"))) { userAddressList.Add(userAddress.GetString("UserManagement:User.UserAddress.Address")); } if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.Address2"))) { userAddressList.Add(userAddress.GetString("UserManagement:User.UserAddress.Address2")); } if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.Zip"))) { userAddressList.Add(userAddress.GetString("UserManagement:User.UserAddress.Zip")); } if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.City"))) { userAddressList.Add(userAddress.GetString("UserManagement:User.UserAddress.City")); } if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.State"))) { var countryCode = userAddress.GetString("UserManagement:User.UserAddress.CountryCode"); string stateName = Dynamicweb.Ecommerce.Services.Countries.GetRegion(countryCode, GetString("UserManagement:User.UserAddress.State"))?.GetName(Dynamicweb.Ecommerce.Common.Context.LanguageID) ?? string.Empty; userAddressList.Add(stateName); } if (!string.IsNullOrEmpty(userAddress.GetString("UserManagement:User.UserAddress.CountryCode"))) { userAddressList.Add(userAddress.GetString("UserManagement:User.UserAddress.Culture.CountryName")); } string userAddressString = (string.Join(",", userAddressList.Select(x => x.ToString()).ToArray())).Replace(",", ", "); string isChecked = userAddress.GetBoolean("UserManagement:User.UserAddress.SelectedForDeliveryFields") ? "checked" : ""; isChecked = userAddressSelected == false && userAddress.GetBoolean("UserManagement:User.UserAddress.Default") && selectedAddress != "-1" ? "checked" : isChecked; <label class="list-group-item list-group-item-action"> <div class="grid"> <div class="g-col-12 g-col-md-4 d-flex"> <div class="form-check"> <input class="form-check-input" type="radio" name="EcomOrderDeliverySelectedAddressId" id="EcomOrderDeliverySelectedAddressId_@addressId" value="@addressId" @isChecked onclick="useUserAddress()"> <span class="form-check-label">@userAddress.GetString("UserManagement:User.UserAddress.Description")</span> </div> </div> <div class="g-col-12 g-col-md-7 fs-7"> @{ if (isStandardSwiftTemplates) { @userAddressString } else { @RenderUserItemAddressInline(userAddress) } } </div> </div> </label> } </div> <script> useBillingAddress = function () { document.querySelectorAll("input[name^='EcomOrderDelivery']").forEach(function (field) { field.removeAttribute("disabled"); }); submitForm(); } useUserAddress = function () { document.querySelectorAll("input[name^='EcomOrderDelivery']").forEach(function (field) { if (field.name != "EcomOrderDeliverySelectedAddressId") { field.setAttribute("disabled", "true"); } }); submitForm(); } </script> } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderStepsNavigation() { string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; int currentStep = 1; string nextButtonName = Translate("Next"); string previousButtonName = Translate("Back"); bool isPaymentStep = GetLoop("StepButtons").Count == 0; bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsWebServiceConnectionAvailable"]); string erpDownCartBehavior = Pageview.AreaSettings.GetRawValueString("ErpDownCartBehavior", "none"); foreach (LoopItem step in GetLoop("StepButtons")) { if (step.GetBoolean("Step.Current")) { currentStep = step.GetInteger("Step.Number"); } if (step.GetInteger("Step.Number") == currentStep + 1) { nextButtonName = Translate(step.GetString("Step.Name")); } if (step.GetInteger("Step.Number") == currentStep + step.GetInteger("Step.Index")) { previousButtonName = Translate("Back to") + " " + Translate(step.GetString("Step.Name")); } } if (currentStep == GetLoop("StepButtons").Count - 1 && Pageview.CurrentParagraph.Item.SystemName != "Swift_QuoteCheckoutApp") { nextButtonName = Translate("Place Order"); @RenderTermsAndConditionsCheckbox() } else if (isPaymentStep) { nextButtonName = Translate("Pay"); } <div class="mt-4 d-flex flex-column flex-md-row justify-content-end gap-3 mt-lg-4" id="StepsNavigation"> @if (currentStep == 1) { var cartLink = $"Default.aspx?id={Pageview.CurrentParagraph.Page.Parent.ID}"; <a href="@cartLink" class="btn btn-link link-secondary text-decoration-none order-last order-md-first" id="BackToCartButton"> <div class="d-flex align-items-center justify-content-center position-relative"> <span class="icon-2 me-1 position-absolute position-md-static start-0"> @ReadFile(iconPath + "chevron-left.svg") </span> <span>@Translate("Back to cart")</span> </div> </a> } else { <button name="@GetString("CartV2.PreviousStepButtonName")" id="@GetString("CartV2.PreviousStepButtonName")" class="btn btn-link link-secondary text-decoration-none"> <div class="d-flex align-items-center justify-content-center position-relative"> <span class="icon-2 me-1 position-absolute position-md-static start-0"> @ReadFile(iconPath + "chevron-left.svg") </span> <span>@previousButtonName</span> </div> </button> } @if (!(currentStep == GetLoop("StepButtons").Count - 1 && isErpConnectionDown && erpDownCartBehavior == "disable")) { var buttonId = GetLoop("StepButtons").Count == 0 ? "PayButton" : GetString("CartV2.NextStepButtonName"); <button type="submit" name="@GetString("CartV2.NextStepButtonName")" id="@buttonId" class="btn btn-primary order-first order-md-last"> <div class="d-flex align-items-center justify-content-center position-relative"> <span>@nextButtonName</span> <span class="icon-2 ms-1 position-absolute position-md-static end-0"> @ReadFile(iconPath + "chevron-right.svg") </span> </div> </button> } else { <button class="btn btn-primary pe-none disabled">@Translate("Payment is temporarily disabled")</button> } <script> if (window.history.replaceState) { window.history.replaceState(null, null, window.location.href); } </script> </div> return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions{ string RenderTermsAndConditionsCheckbox() { string termsAndConditionsCheckboxValue = GetBoolean("Ecom:Order.Customer.Accepted").ToString(); string termsAndConditionsPageLink = Pageview.CurrentParagraph.Item["TermsAndConditionsPageLink"] != null ? Pageview.CurrentParagraph.Item["TermsAndConditionsPageLink"].ToString() : ""; if (!string.IsNullOrEmpty(termsAndConditionsPageLink)) { <div class="mt-4" id="TermsAndConditions"> <h3 class="fs-6 fw-normal mb-0">@Translate("Terms and conditions")</h3> <p class="fs-8 mb-3">@Translate("Agree to terms and conditions and that your informations are correct")</p> <div class="list-group"> <label class="list-group-item list-group-item-action d-flex justify-content-between" for="EcomOrderCustomerAccepted"> <span class="d-flex justify-content-between align-items-center gap-3"> <input class="form-check-input m-0" type="checkbox" name="EcomOrderCustomerAccepted" id="EcomOrderCustomerAccepted" value="@termsAndConditionsCheckboxValue" @if (GetString("Ecom:Order.Customer.Accepted") == "true") { <text>checked="checked"</text> }> <span>@Translate("I accept the") <a href='@termsAndConditionsPageLink' target='_blank' rel='noopener' id="TermsAndConditionsButton">@Translate("terms and conditions")</a></span> </span> </label> </div> </div> } return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderSummarySidebar() { <div class="g-col-12 g-col-lg-4 py-2 p-3 p-lg-4 p-xl-5" id="summarySidebar"> @RenderOrderSummaryToggleButton() @RenderOrderSummaryContent() </div> return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderOrderSummaryContent() { <div class="d-lg-block h-lg-auto collapse pt-2 pt-lg-0" id="orderSummary"> <div class="d-flex flex-column gap-2 gap-lg-3 pb-2 pb-lg-3"> @foreach (LoopItem orderline in GetLoop("OrderLines")) { @RenderOrderSummaryOrderLineItem(orderline) } </div> @RenderOrderSummary() </div> return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @functions { 5 6 private static string GetPrimaryImage(LoopItem orderline, string shopId) 7 { 8 bool isProduct = orderline.GetBoolean("Ecom:Order:OrderLine.IsProduct") || (orderline.GetInteger("Ecom:Order:OrderLine.Type") == 3 && !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.ProductNumber"))); 9 string productId = orderline.GetString("Ecom:Order:OrderLine.ProductID"); 10 string variantId = orderline.GetString("Ecom:Order:OrderLine.ProductVariantID"); 11 12 if (!isProduct || string.IsNullOrEmpty(productId)) return ""; 13 14 ProductViewModelSettings productSetting = new ProductViewModelSettings 15 { 16 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 17 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 18 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 19 ShopId = shopId 20 }; 21 ProductViewModel product = ViewModelFactory.CreateView(productSetting, productId, variantId); 22 return product.DefaultImage.Value; 23 } 24 25 26 string RenderOrderSummaryOrderLineItem(LoopItem orderline) 27 { 28 29 string name = orderline.GetString("Ecom:Order:OrderLine.ProductName"); 30 // string image = "/Admin/Public/GetImage.ashx?width=" + 180 + "&height=" + 180 + "&crop=5&fillcanvas=true&Background=ffffff&image=" + orderline.GetString("Ecom:Product.PrimaryImage") + "&format=webp"; 31 32 string image = "/Admin/Public/GetImage.ashx?width=" + 180 + "&height=" + 180 + "&image=" + orderline.GetString("Ecom:Product.PrimaryImage") + "&format=webp"; 33 34 35 string removeFromBasketLink = orderline.GetString("Ecom:Order:OrderLine.DeleteLink"); 36 string priceTotalWithDiscounts = orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceFormatted"); 37 string priceBefore = orderline.GetString("Ecom:Product.InformativePrice.PriceFormatted"); 38 string unitPrice = orderline.GetString("Ecom:Order:OrderLine.UnitPrice.PriceFormatted"); 39 string discountPrice = orderline.GetString("Ecom:Order:OrderLine.UnitPriceWithProductDiscount.PriceFormatted"); 40 string discountTotal = orderline.GetString("Ecom:Order:OrderLine.TotalDiscount.PriceFormatted"); 41 string variantText = orderline.GetString("Ecom:Order:OrderLine.ProductVariantText"); 42 var orderlineId = orderline.GetValue("Ecom:Order:OrderLine.Id"); 43 var quantity = orderline.GetDouble("Ecom:Order:OrderLine.Quantity"); 44 var unitName = orderline.GetString("Ecom:Order:OrderLine.UnitName"); 45 string primaryGroupId = orderline.GetString("Ecom:Order:OrderLine.PrimaryOrDefaultGroupId"); 46 string productId = orderline.GetString("Ecom:Order:OrderLine.ProductID"); 47 string variantId = orderline.GetString("Ecom:Order:OrderLine.ProductVariantID"); 48 49 string link = "Default.aspx?ID=" + GetPageIdByNavigationTag("Shop"); 50 link += $"&GroupID={primaryGroupId}"; 51 link += $"&ProductID={productId}"; 52 link += !string.IsNullOrEmpty(variantId) ? $"&VariantID={variantId}" : ""; 53 54 bool isProduct = orderline.GetBoolean("Ecom:Order:OrderLine.IsProduct") || (orderline.GetInteger("Ecom:Order:OrderLine.Type") == 3 && !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.ProductNumber"))); 55 56 if (isProduct) 57 { 58 <article class="grid grid-12"> 59 60 <div class="g-col-2"> 61 <a href="@link" class="ratio ratio-1x1 d-block " title="@name"> 62 <img src="@image" style="object-fit: contain;" alt="@name"> 63 </a> 64 </div> 65 66 <div class="g-col-10"> 67 68 <div class="d-flex flex-column gap-1"> 69 @* Title *@ 70 <h3 class="h6 fs-7 m-0"> 71 72 <a href="@link" class="text-decoration-none" title="@name">@name</a> 73 </h3> 74 75 @* Variants *@ 76 @if (!string.IsNullOrEmpty(variantText)) 77 { 78 <p class="fs-8 m-0">@variantText</p> 79 } 80 81 @if (orderline.GetInteger("Ecom:Order:OrderLine.Type") == 3 && !string.IsNullOrEmpty(orderline.GetString("Ecom:Order:OrderLine.ProductNumber"))) 82 { 83 @* Free product notice *@ 84 <p class="fs-8 m-0">@Translate("Free product")</p> 85 } 86 else 87 { 88 @* Unit price *@ 89 <p class="fs-8 m-0"> 90 @if (!string.IsNullOrEmpty(unitName)) 91 { 92 <span>@unitName: </span> 93 } 94 @if (discountPrice == unitPrice) 95 { 96 <span class="text-price">@unitPrice</span> 97 } 98 else 99 { 100 <span class="text-price">@discountPrice</span> 101 <span class="text-decoration-line-through"> 102 <span class="text-price">@unitPrice</span> 103 </span> 104 } 105 </p> 106 } 107 <div class="d-flex flex-row justify-content-between"> 108 @* Quantity *@ 109 <span class="fs-8 d-block">@Translate("Qty"): @quantity</span> 110 111 <div class="text-end flex-fill"> 112 @* Total *@ 113 <span class="h6 d-block fs-7 m-0"> 114 <span class="text-price">@priceTotalWithDiscounts</span> 115 </span> 116 @if (orderline.GetDouble("Ecom:Order:OrderLine.TotalDiscount.Price.Value") != 0.0) 117 { 118 <span class="d-block fs-8"> 119 <span class="text-price">@discountTotal</span> 120 </span> 121 } 122 </div> 123 </div> 124 </div> 125 </div> 126 </article> 127 } 128 129 return string.Empty; 130 } 131 } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderOrderSummary(bool renderVoucher = true) { double totalPriceWithoutOrderDiscountsFeesAndTaxesValue = GetDouble("Ecom:Order.TotalPriceWithoutDiscountsFeesAndTaxes.Price.Value") + GetDouble("Ecom:Order.TotalProductDiscount.Price.Value"); var currencyCode = string.IsNullOrWhiteSpace(GetString("Ecom:Order.Currency.Code")) ? "DKK" : GetString("Ecom:Order.Currency.Code"); var orderCurrency = Dynamicweb.Ecommerce.Services.Currencies.GetCurrency(currencyCode); string totalPriceWithoutOrderDiscountsFeesAndTaxes = Dynamicweb.Ecommerce.Services.Currencies.Format(orderCurrency, totalPriceWithoutOrderDiscountsFeesAndTaxesValue); string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower(); bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); bool disableVouchers = Pageview.CurrentParagraph.Item["DisableVouchers"] != null ? (Boolean)Pageview.CurrentParagraph.Item["DisableVouchers"] : false; <div class="d-flex flex-column gap-2 gap-lg-3 pb-3 bottom-0 sticky-receipt theme" id="orderSummaryFooter"> @if (renderVoucher && !disableVouchers && Pageview.CurrentParagraph.Item.SystemName != "Swift_QuoteCheckoutApp") { // @RenderVoucherForm() } <div class="fs-8 border-top pt-2 pt-lg-3"> @* Subtotal *@ <div class="d-flex justify-content-between fw-bold"> <span>@Translate("Subtotal")</span> <span class="text-end"> <span class="d-block"> @if (GetDouble("Ecom:Order.TotalPriceWithoutDiscountsFeesAndTaxes.Price.Value") != totalPriceWithoutOrderDiscountsFeesAndTaxesValue) { <span class="text-price fw-normal text-decoration-line-through">@GetString("Ecom:Order.TotalPriceWithoutDiscountsFeesAndTaxes.PriceFormatted")</span> } <span class="text-price">@totalPriceWithoutOrderDiscountsFeesAndTaxes</span> </span> @if (!neverShowVat && showPricesWithVat == "false") { <span class="fs-8 fw-normal d-block">@Translate("Excl. VAT")</span> } else if (!neverShowVat) { <span class="fs-8 fw-normal d-block">@Translate("Incl. VAT")</span> } </span> </div> @* Discounts (only order discounts) *@ @foreach (LoopItem orderline in GetLoop("OrderLines")) { bool isDiscount = orderline.GetBoolean("Ecom:Order:OrderLine.IsDiscount"); bool isOrderDiscount = orderline.GetInteger("Ecom:Order:OrderLine.Type") == 1; if (isDiscount && isOrderDiscount) { <div class="d-flex justify-content-between"><span>@orderline.GetString("Ecom:Order:OrderLine.ProductName")</span><span class="text-price">@orderline.GetString("Ecom:Order:OrderLine.TotalPriceWithProductDiscounts.PriceFormatted")</span></div> } } @* Delivery *@ @if (!string.IsNullOrEmpty(GetString("Ecom:Order.ShippingMethodID"))) { if (GetDouble("Ecom:Order.ShippingFee.Price.Value") != 0.0) { <div class="d-flex justify-content-between"> <span>@Translate("Delivery")</span> <span>@GetString("Ecom:Order.ShippingFee.PriceFormatted")</span> </div> } } else { <div class="d-flex justify-content-between"> <span>@Translate("Delivery")</span> <span>@Translate("Calculated in next step")</span> </div> } @* Payment *@ @if (!string.IsNullOrEmpty(GetString("Ecom:Order.PaymentMethodID"))) { if (GetDouble("Ecom:Order.PaymentFee.Price.Value") != 0) { <div class="d-flex justify-content-between"> <span>@Translate("Payment")</span> <span class="text-price">@GetString("Ecom:Order.PaymentFee.PriceFormatted")</span> </div> } } else { <div class="d-flex justify-content-between"> <span>@Translate("Payment")</span> <span>@Translate("Calculated in next step")</span> </div> } @* Taxes *@ @if (GetDouble("Ecom:Order.Taxes.Total.Price.Value") != 0) { <div class="d-flex justify-content-between mb-2"> <span>@Translate("Sales tax")</span> <span>@GetString("Ecom:Order.Taxes.Total.PriceFormatted")</span> </div> } </div> <div class="fs-8 border-top pt-2 pt-lg-3"> <div class="d-flex justify-content-between fs-6 fw-bold"> <span>@Translate("Total")</span> @if (!neverShowVat && showPricesWithVat == "false") { <span class="text-price text-end"> <span class="fs-5 d-block">@GetString("Ecom:Order.Price.PriceFormatted")</span> <span class="fs-8 fw-normal d-block">@Translate("Excl. VAT")</span> </span> } else if (!neverShowVat && showPricesWithVat == "true") { <span class="text-price text-end"> <span class="fs-5 d-block">@GetString("Ecom:Order.Price.PriceFormatted")</span> <span class="fs-8 fw-normal d-block">@Translate("Incl. VAT")</span> </span> } else { <span class="text-price fs-5">@GetString("Ecom:Order.Price.PriceFormatted")</span> } </div> @if (!neverShowVat) { <div class="d-flex justify-content-between"><span>@Translate("VAT")</span><span class="text-price">@GetString("Ecom:Order.Price.VATFormatted")</span></div> if (showPricesWithVat == "false") { <div class="d-flex justify-content-between"><span>@Translate("Total incl. VAT")</span><span class="text-price">@GetString("Ecom:Order.OrderLines.Total.PriceWithVAT")</span></div> } } @if (GetDouble("Ecom:Order.TotalDiscount.Price.Value") != 0) { <div class="d-flex justify-content-between"><span>@Translate("Discount")</span><span class="text-price">@GetString("Ecom:Order.TotalDiscount.PriceFormatted")</span></div> } </div> </div> return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Dynamicweb.Ecommerce.Orders @functions { string RenderVoucherForm() { string iconPath = "/Files/Templates/Designs/Swift/Assets/icons/"; string voucherCode = GetString("Ecom:Order.Customer.VoucherCode"); string voucherCodeError = GetString("Ecom:Cart.ValidationError.EcomOrderVoucherCode.ErrorMessage"); var errors = new List<string>(); string validState = ""; bool vouchersAppliedAsDiscounts = false; IEnumerable<string> codes = new List<string>(); Order order = new OrderService().GetById(GetString("Ecom:Order.ID")); if (!string.IsNullOrWhiteSpace(voucherCode)) { if (order.VoucherUseType.HasFlag(VoucherUseCategoryType.Discount)) { codes = voucherCode.Split(new string[] { ",", ";", " " }, StringSplitOptions.RemoveEmptyEntries); vouchersAppliedAsDiscounts = true; } else { codes = new string[] { voucherCode.Trim() }; } } if (!vouchersAppliedAsDiscounts) { foreach (string code in codes) { Dynamicweb.Ecommerce.Orders.Vouchers.Voucher vouch = Dynamicweb.Ecommerce.Services.Vouchers.GetVoucherByCode(code); if (vouch == null) { validState = "is-invalid"; errors.Add(Translate("Voucher") + " <span class='fw-bold'>" + code + "</span> " + Translate("not found")); continue; } if (vouch.DateUsed.HasValue) { validState = "is-invalid"; errors.Add(Translate("Voucher") + " <span class='fw-bold'>" + code + "</span> " + Translate("already used")); continue; } } } <div class="py-3 border-top" id="orderVoucherForm"> <form method="post" id="VoucherForm"> <div class="input-group input-primary-button-group has-validation"> <input type="text" class="form-control @(validState)" name="EcomOrderVoucherCodeField" placeholder="@Translate("Add voucher here")" id="EcomOrderVoucherCodeField" value="" aria-label="@Translate("Voucher input")" onkeyup="document.querySelector('#EcomOrderVoucherCode').value = this.value;"> <button class="btn btn-sm btn-primary d-inline-flex align-items-center justify-content-center" type="submit" id="EcomOrderVoucherApply" style="min-width: 100px;"> <span>@Translate("Apply")</span> </button> <div class="invalid-feedback"> @{ var errorMessage = string.Join(",", errors); } @errorMessage </div> </div> <input type="hidden" name="EcomOrderVoucherCode" id="EcomOrderVoucherCode" value="@voucherCode"> <label for="EcomOrderVoucherCodeField" class="visually-hidden">@Translate("Add voucher here")</label> </form> @if (!string.IsNullOrWhiteSpace(voucherCode) && vouchersAppliedAsDiscounts) { <div class="d-flex flex-wrap gap-2 pt-3"> @foreach (string code in codes) { <form method="post"> <input type="hidden" name="EcomOrderVoucherCode" value="@voucherCode.Replace(code + ",", "").Replace("," + code, "").Replace(code, "")"> <span class="badge fw-normal d-inline-flex align-items-center justify-content-center opacity-50 opacity-100-hover" style="background-color:var(--swift-foreground-color);color:var(--swift-background-color);"> <span class="icon-2"> @ReadFile(iconPath + "tag.svg") </span> <span class="mx-2">@code</span> <button type="submit" class="text-reset bg-transparent border-0 p-0" aria-label="@Translate("Remove voucher")" id="RemoveVoucherButton"> <span class="icon-2"> @ReadFile(iconPath + "x.svg") </span> </button> </span> </form> } </div> } @voucherCodeError </div> return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @functions { string RenderOrderSummaryToggleButton() { string iconPath = "/Files/Icons/"; <button class="toggle-order-summary btn text-reset w-100 d-block d-lg-none px-0" type="button" data-bs-toggle="collapse" data-bs-target="#orderSummary" aria-expanded="false" aria-controls="orderSummary" id="OrderSummaryToggleButton"> <span class="d-flex align-items-center justify-content-between"> <span class="d-flex align-items-center gap-2"> <span class="fs-7 lh-1"> <span class="toggle-order-summary-text" id="OrderSummaryToggleButtonLabel">@Translate("Show order summary")</span> </span> <span class="icon-2" id="OrderSummaryToggleButtonIcon" style="transition: all 0.25s ease-in-out;"> @ReadFile(iconPath + "chevron-down.svg") </span> </span> <span class="fw-bold"><span class="text-price">@GetString("Ecom:Order.Price")</span> </span> </span> </button> <script> const orderSummaryToggleButton = document.getElementById("OrderSummaryToggleButton"); const orderSummaryToggleButtonLabel = document.getElementById("OrderSummaryToggleButtonLabel"); const orderSummaryToggleButtonIcon = document.getElementById("OrderSummaryToggleButtonIcon"); const orderSummaryToggleText = '@Translate("Show order summary")'; orderSummaryToggleButton.addEventListener('click', function handleClick() { if (orderSummaryToggleButtonLabel.textContent.toLowerCase().includes(orderSummaryToggleText.toLowerCase())) { orderSummaryToggleButtonLabel.textContent = '@Translate("Hide order summary")'; orderSummaryToggleButtonIcon.classList.add("rotate-180"); } else { orderSummaryToggleButtonLabel.textContent = orderSummaryToggleText; orderSummaryToggleButtonIcon.classList.remove("rotate-180"); } }); </script> return string.Empty; } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using System.Text.RegularExpressions @using System.Text @functions { public string RenderDeliveryAddressInline() { List<List<string>> addressFormat = Dynamicweb.Ecommerce.International.Country.GetDisplayAddress(GetString("Ecom:Order.Delivery.Country.Code")); var result = new StringBuilder(); foreach (List<string> addressLine in addressFormat) { for (var i = 0; i < addressLine.Count; i++) { addressLine[i] = Regex.Replace(addressLine[i], "{name}", GetString("Ecom:Order.Delivery.Name"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{firstName}", GetString("Ecom:Order.Delivery.FirstName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{lastName}", GetString("Ecom:Order.Delivery.Surname"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{company}", GetString("Ecom:Order.Delivery.Company"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address}", GetString("Ecom:Order.Delivery.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address1}", GetString("Ecom:Order.Delivery.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address2}", GetString("Ecom:Order.Delivery.Address2"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{zip}", GetString("Ecom:Order.Delivery.Zip"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{city}", GetString("Ecom:Order.Delivery.City"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{regionCode}", GetString("Ecom:Order.Delivery.Region"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{region}", GetDeliveryRegionName(), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{countryCode}", GetString("Ecom:Order.Delivery.Country.Code"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{country}", GetString("Ecom:Order.Delivery.Country"), RegexOptions.IgnoreCase); // Remove any bad placeholders the user may have submitted addressLine[i] = Regex.Replace(addressLine[i], "{phone}", "", RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{email}", "", RegexOptions.IgnoreCase); } var completeLine = string.Join(string.Empty, addressLine.ToArray()); if (!string.IsNullOrWhiteSpace(completeLine)) { result.Append($"<span>{completeLine}</span>"); if (addressLine != addressFormat.Last()) { result.Append(" "); } } } return result.ToString(); } public string GetDeliveryAddressString() { List<List<string>> addressFormat = Dynamicweb.Ecommerce.International.Country.GetDisplayAddress(GetString("Ecom:Order.Delivery.Country.Code")); List<string> completeAddress = new List<string>(); foreach (var addressLine in addressFormat) { for (var i = 0; i < addressLine.Count; i++) { addressLine[i] = Regex.Replace(addressLine[i], "{name}", GetString("Ecom:Order.Delivery.Name"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{firstName}", GetString("Ecom:Order.Delivery.FirstName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{lastName}", GetString("Ecom:Order.Delivery.LastName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{company}", GetString("Ecom:Order.Delivery.Company"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address}", GetString("Ecom:Order.Delivery.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address1}", GetString("Ecom:Order.Delivery.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address2}", GetString("Ecom:Order.Delivery.Address2"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{zip}", GetString("Ecom:Order.Delivery.Zip"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{city}", GetString("Ecom:Order.Delivery.City"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{regionCode}", GetString("Ecom:Order.Delivery.Region"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{region}", GetDeliveryRegionName(), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{countryCode}", GetString("Ecom:Order.Delivery.Country.Code"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{country}", GetString("Ecom:Order.Delivery.Country"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{phone}", GetString("Ecom:Order.Delivery.Phone"), RegexOptions.IgnoreCase); // Remove any bad placeholders the user may have submitted addressLine[i] = Regex.Replace(addressLine[i], "{phone}", "", RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{email}", "", RegexOptions.IgnoreCase); } var completeLine = string.Join(string.Empty, addressLine.ToArray()); if (!string.IsNullOrWhiteSpace(completeLine)) { completeAddress.Add(completeLine); } } return string.Join(", ", completeAddress.ToArray()); } public string GetDeliveryRegionName() { foreach (LoopItem region in GetLoop("DeliveryRegions")) { if (region.GetBoolean("Ecom:DeliveryRegion.IsDeliveryRegion")) { return region.GetString("Ecom:DeliveryRegion.Name"); } } return GetString("Ecom:Order.Delivery.Region"); } } @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using System.Collections.Generic @using System.Text.RegularExpressions @using Dynamicweb.Ecommerce.International @using System.Text @functions { public string RenderUserItemAddressInline(LoopItem address) { string regionCode = GetRegionCode(address.GetString("UserManagement:User.UserAddress.CountryCode"), address.GetString("UserManagement:User.UserAddress.State")); string regionName = GetRegionName(address.GetString("UserManagement:User.UserAddress.CountryCode"), address.GetString("UserManagement:User.UserAddress.State")); List<List<string>> addressFormat = Dynamicweb.Ecommerce.International.Country.GetDisplayAddress(address.GetString("UserManagement:User.UserAddress.CountryCode")); var result = new StringBuilder(); foreach (List<string> addressLine in addressFormat) { for (var i = 0; i < addressLine.Count; i++) { addressLine[i] = Regex.Replace(addressLine[i], "{name}", address.GetString("UserManagement:User.UserAddress.Name"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{firstName}", address.GetString("UserManagement:User.UserAddress.FirstName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{lastName}", address.GetString("UserManagement:User.UserAddress.lastName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{company}", address.GetString("UserManagement:User.UserAddress.Company"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address}", address.GetString("UserManagement:User.UserAddress.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address1}", address.GetString("UserManagement:User.UserAddress.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address2}", address.GetString("UserManagement:User.UserAddress.Address2"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{zip}", address.GetString("UserManagement:User.UserAddress.Zip"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{city}", address.GetString("UserManagement:User.UserAddress.City"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{regionCode}", regionCode, RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{region}", regionName, RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{countryCode}", address.GetString("UserManagement:User.UserAddress.Culture.CountryCode"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{country}", address.GetString("UserManagement:User.UserAddress.Culture.CountryName"), RegexOptions.IgnoreCase); // Remove any bad placeholders the user may have submitted addressLine[i] = Regex.Replace(addressLine[i], "{phone}", "", RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{email}", "", RegexOptions.IgnoreCase); } var completeLine = string.Join(string.Empty, addressLine.ToArray()); if (!string.IsNullOrWhiteSpace(completeLine)) { result.Append($"<span>{completeLine}</span> "); } } return result.ToString(); } public string GetUserAddressString() { List<List<string>> addressFormat = Dynamicweb.Ecommerce.International.Country.GetDisplayAddress(GetString("UserManagement:User.CountryCode")); string regionCode = GetRegionCode(GetString("UserManagement:User.CountryCode"), GetString("UserManagement:User.State")); string regionName = GetRegionName(GetString("UserManagement:User.CountryCode"), GetString("UserManagement:User.State")); List<string> completeAddress = new List<string>(); foreach (var addressLine in addressFormat) { for (var i = 0; i < addressLine.Count; i++) { addressLine[i] = Regex.Replace(addressLine[i], "{name}", GetString("UserManagement:User.Name"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{firstName}", GetString("UserManagement:User.FirstName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{lastName}", GetString("UserManagement:User.LastName"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{company}", GetString("UserManagement:User.Company"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address}", GetString("UserManagement:User.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address1}", GetString("UserManagement:User.Address"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{address2}", GetString("UserManagement:User.Address2"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{zip}", GetString("UserManagement:User.Zip"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{city}", GetString("UserManagement:User.City"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{regionCode}", regionCode, RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{region}", regionName, RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{countryCode}", GetString("UserManagement:User.CountryCode"), RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{country}", GetString("UserManagement:User.Culture.CountryName"), RegexOptions.IgnoreCase); // Remove any bad placeholders the user may have submitted addressLine[i] = Regex.Replace(addressLine[i], "{phone}", "", RegexOptions.IgnoreCase); addressLine[i] = Regex.Replace(addressLine[i], "{email}", "", RegexOptions.IgnoreCase); } var completeLine = string.Join(string.Empty, addressLine.ToArray()); if (!string.IsNullOrWhiteSpace(completeLine)) { completeAddress.Add(completeLine); } } return string.Join(" ", completeAddress.ToArray()); } public string GetRegionName(string countryCode, string regionValue) { return GetRegionNameOrCode(countryCode, regionValue); } public string GetRegionCode(string countryCode, string regionValue) { return GetRegionNameOrCode(countryCode, regionValue, "code"); } public string GetRegionNameOrCode(string countryCode, string regionValue, string nameOrCode = "name") { CountryCollection allCountryRegions = Dynamicweb.Ecommerce.Services.Countries.GetRegions(countryCode); Country matchedRegion = allCountryRegions.FirstOrDefault(r => r.RegionCode == regionValue || r.GetName(Dynamicweb.Ecommerce.Common.Context.LanguageID) == regionValue); if (matchedRegion == null) return regionValue; return nameOrCode == "name" ? matchedRegion.GetName(Dynamicweb.Ecommerce.Common.Context.LanguageID) : matchedRegion.RegionCode; } }