Error compiling template "Designs/Swift/Paragraph/Custom__AddToCartForCustomProducts.cshtml" Line 91: The name 'Dna' does not exist in the current context Line 120: The name 'Dna' 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.Collections.Generic; 9 using System.Linq; 10 using Dynamicweb.Core; 11 using Dynamicweb.Ecommerce.ProductCatalog; 12 internal class RazorEngine_f2bfc5c5adf14a34bdc7c8584e926c1c : Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 13 { 14 #pragma warning disable 1998 15 public async override global::System.Threading.Tasks.Task ExecuteAsync() 16 { 17 WriteLiteral("\r\n"); 18 19 ProductViewModel product = null; 20 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 21 { 22 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 23 } 24 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 25 { 26 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 27 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 28 29 if (productList?.Products is object) 30 { 31 product = productList.Products[0]; 32 } 33 } 34 35 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 36 37 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 38 bool anonymousUser = Pageview.User == null; 39 bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser; 40 hideAddToCart = !Pageview.IsVisualEditorMode && hideAddToCart; 41 42 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 43 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 44 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 45 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 46 WriteLiteral("\r\n"); 47 if (product is object && !hideAddToCart) { 48 bool quantitySelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowQuantitySelector")) && Model.Item.GetBoolean("ShowQuantitySelector"); 49 50 string buttonSize = Model.Item.GetRawValueString("ButtonSize", "regular"); 51 string inputSize = string.Empty; 52 53 switch (buttonSize) 54 { 55 case "small": 56 inputSize = " input-group-sm"; 57 buttonSize = " btn-sm"; 58 break; 59 case "regular": 60 buttonSize = string.Empty; 61 break; 62 case "large": 63 inputSize = " input-group-lg"; 64 buttonSize = " btn-lg"; 65 break; 66 } 67 68 string iconPath = "/Files/icons/"; 69 string url = "/Default.aspx?ID=" + (GetPageIdByNavigationTag("CartService")); 70 if (!url.Contains("LayoutTemplate")) 71 { 72 url += url.Contains("?") ? "&LayoutTemplate=Swift_MiniCart.cshtml" : "?LayoutTemplate=Swift_MiniCart.cshtml"; 73 } 74 75 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 76 string addToCartIcon = Model.Item.GetRawValueString("Icon", iconPath + "shopping-cart.svg"); 77 string addToCartLabel = !addToCartIcon.Contains("_none") ? $"<span class=\"icon-2\">{ReadFile(addToCartIcon)}</span>" : ""; 78 addToCartLabel += !addToCartIcon.Contains("_none") && !Model.Item.GetBoolean("HideButtonText") ? " " : ""; 79 addToCartLabel += !Model.Item.GetBoolean("HideButtonText") ? $"<span class=\"d-none d-md-inline\">{Translate("Add to cart")}</span><span class=\"d-inline d-md-none\">{Translate("Add")}</span>" : ""; 80 81 bool userHasPendingQuote = Dynamicweb.Ecommerce.Common.Context.Cart != null && Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote; 82 83 string minQty = product.PurchaseMinimumQuantity != 1 ? $"min=\"{product.PurchaseMinimumQuantity.ToString()}\"" : "min=\"1\""; 84 string stepQty = product.PurchaseQuantityStep > 1 ? product.PurchaseQuantityStep.ToString() : "1"; 85 string valueQty = product.PurchaseMinimumQuantity > product.PurchaseQuantityStep ? product.PurchaseMinimumQuantity.ToString() : stepQty; 86 87 var uniqueId = $"{Pageview.CurrentParagraph.ID}_{product.Id}_{product.VariantId}"; 88 89 var cartPage = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Cart"); 90 var showUserContactInformation = Model.Item.GetBoolean("ShowUserContactInformation"); 91 var realUser = Dna.Extensions.Users.GetRealUser(); 92 93 WriteLiteral("\t<script type=\"module\" src=\"/Files/Templates/Designs/Swift/Assets/custom-js/custom-js-module/addToCartForCustomProducts.js\"></script>\r\n"); 94 WriteLiteral("\t<div"); 95 BeginWriteAttribute("class", " class=\"", 4036, "\"", 4081, 2); 96 WriteAttributeValue("", 4044, "item_", 4044, 5, true); 97 WriteAttributeValue("", 4049, Model.Item.SystemName.ToLower(), 4049, 32, false); 98 EndWriteAttribute(); 99 WriteLiteral(">\t\r\n\r\n\t\t<form method=\"post\" enctype=\"multipart/form-data\""); 100 BeginWriteAttribute("action", " action=\"", 4139, "\"", 4152, 1); 101 WriteAttributeValue("", 4148, url, 4148, 4, false); 102 EndWriteAttribute(); 103 WriteLiteral(" style=\"z-index: 1\" data-cart-page=\""); 104 Write(cartPage); 105 WriteLiteral("\">\r\n\t\t\t<input type=\"hidden\" name=\"redirect\" value=\"false\">\r\n\t\t\t<input type=\"hidden\" name=\"ProductId\""); 106 BeginWriteAttribute("value", " value=\"", 4298, "\"", 4317, 1); 107 WriteAttributeValue("", 4306, product.Id, 4306, 11, false); 108 EndWriteAttribute(); 109 WriteLiteral(">\r\n\t\t\t<input type=\"hidden\" name=\"VariantId\""); 110 BeginWriteAttribute("value", " value=\"", 4361, "\"", 4387, 1); 111 WriteAttributeValue("", 4369, product.VariantId, 4369, 18, false); 112 EndWriteAttribute(); 113 WriteLiteral(">\r\n\t\t\t<input type=\"hidden\" name=\"cartcmd\" value=\"add\">\r\n\t\t\t\r\n\t\t\t<div class=\"row\">\r\n\t\t\t\t<div class=\"col-12\">\r\n\t\t\t\t\t<div class=\"form-floating\">\r\n\t\t\t\t\t\t<textarea"); 114 BeginWriteAttribute("id", " id=\"", 4546, "\"", 4594, 2); 115 WriteAttributeValue("", 4551, "OrderLineCustomProductDescription_", 4551, 34, true); 116 WriteAttributeValue("", 4585, uniqueId, 4585, 9, false); 117 EndWriteAttribute(); 118 WriteLiteral(" class=\"form-control\""); 119 BeginWriteAttribute("name", " name=\"", 4616, "\"", 4690, 1); 120 WriteAttributeValue("", 4623, Dna.Keystone.Cart.Constants.RequestFields.CustomProductDescription, 4623, 67, false); 121 EndWriteAttribute(); 122 BeginWriteAttribute("placeholder", " placeholder=\"", 4691, "\"", 4730, 1); 123 WriteAttributeValue("", 4705, Translate("Description"), 4705, 25, false); 124 EndWriteAttribute(); 125 WriteLiteral(" required=\"required\"></textarea>\r\n\t\t\t\t\t\t<label"); 126 BeginWriteAttribute("for", " for=\"", 4777, "\"", 4826, 2); 127 WriteAttributeValue("", 4783, "OrderLineCustomProductDescription_", 4783, 34, true); 128 WriteAttributeValue("", 4817, uniqueId, 4817, 9, false); 129 EndWriteAttribute(); 130 WriteLiteral(" class=\"form-label\">"); 131 Write(Translate("Description")); 132 WriteLiteral("</label>\r\n\t\t\t\t\t</div>\r\n\t\t\t\t\t<div class=\"invalid-feedback invalid-feedback-description\">\r\n\t\t\t\t\t\t"); 133 Write(Translate("Please add a description")); 134 WriteLiteral("\r\n\t\t\t\t\t</div>\r\n\t\t\t\t</div>\r\n\t\t\t\t\r\n"); 135 if (showUserContactInformation) 136 { 137 WriteLiteral("\t\t\t\t\t<div class=\"col-12 col-md-6 mt-3\">\r\n\t\t\t\t\t\t<div class=\"form-floating\">\r\n\t\t\t\t\t\t\t<input"); 138 BeginWriteAttribute("id", " id=\"", 5172, "\"", 5222, 2); 139 WriteAttributeValue("", 5177, "OrderLineCustomProductContactPerson_", 5177, 36, true); 140 WriteAttributeValue("", 5213, uniqueId, 5213, 9, false); 141 EndWriteAttribute(); 142 WriteLiteral(" class=\"form-control\" type=\"text\""); 143 BeginWriteAttribute("placeholder", " placeholder=\"", 5256, "\"", 5298, 1); 144 WriteAttributeValue("", 5270, Translate("Contact person"), 5270, 28, false); 145 EndWriteAttribute(); 146 WriteLiteral(" disabled=\"disabled\""); 147 BeginWriteAttribute("value", " value=\"", 5319, "\"", 5341, 1); 148 WriteAttributeValue("", 5327, realUser.Name, 5327, 14, false); 149 EndWriteAttribute(); 150 WriteLiteral(">\r\n\t\t\t\t\t\t\t<label"); 151 BeginWriteAttribute("for", " for=\"", 5358, "\"", 5409, 2); 152 WriteAttributeValue("", 5364, "OrderLineCustomProductContactPerson_", 5364, 36, true); 153 WriteAttributeValue("", 5400, uniqueId, 5400, 9, false); 154 EndWriteAttribute(); 155 WriteLiteral(" class=\"form-label\">"); 156 Write(Translate("Contact person")); 157 WriteLiteral("</label>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n"); 158 WriteLiteral("\t\t\t\t\t<div class=\"col-12 col-md-6 mt-3\">\r\n\t\t\t\t\t\t<div class=\"form-floating\">\r\n\t\t\t\t\t\t\t<input"); 159 BeginWriteAttribute("id", " id=\"", 5591, "\"", 5633, 2); 160 WriteAttributeValue("", 5596, "OrderLineCustomProductPhone_", 5596, 28, true); 161 WriteAttributeValue("", 5624, uniqueId, 5624, 9, false); 162 EndWriteAttribute(); 163 WriteLiteral(" class=\"form-control\" type=\"text\""); 164 BeginWriteAttribute("placeholder", " placeholder=\"", 5667, "\"", 5700, 1); 165 WriteAttributeValue("", 5681, Translate("Phone"), 5681, 19, false); 166 EndWriteAttribute(); 167 WriteLiteral(" disabled=\"disabled\""); 168 BeginWriteAttribute("value", " value=\"", 5721, "\"", 5744, 1); 169 WriteAttributeValue("", 5729, realUser.Phone, 5729, 15, false); 170 EndWriteAttribute(); 171 WriteLiteral(">\r\n\t\t\t\t\t\t\t<label"); 172 BeginWriteAttribute("for", " for=\"", 5761, "\"", 5804, 2); 173 WriteAttributeValue("", 5767, "OrderLineCustomProductPhone_", 5767, 28, true); 174 WriteAttributeValue("", 5795, uniqueId, 5795, 9, false); 175 EndWriteAttribute(); 176 WriteLiteral(">"); 177 Write(Translate("Phone")); 178 WriteLiteral("</label>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n"); 179 WriteLiteral("\t\t\t\t\t<div class=\"col-12 col-md-6 mt-3\">\r\n\t\t\t\t\t\t<div class=\"form-floating\">\r\n\t\t\t\t\t\t\t<input"); 180 BeginWriteAttribute("id", " id=\"", 5958, "\"", 5998, 2); 181 WriteAttributeValue("", 5963, "OrderLineCustomProductFax_", 5963, 26, true); 182 WriteAttributeValue("", 5989, uniqueId, 5989, 9, false); 183 EndWriteAttribute(); 184 WriteLiteral(" class=\"form-control\" type=\"text\""); 185 BeginWriteAttribute("placeholder", " placeholder=\"", 6032, "\"", 6063, 1); 186 WriteAttributeValue("", 6046, Translate("Fax"), 6046, 17, false); 187 EndWriteAttribute(); 188 WriteLiteral(" disabled=\"disabled\""); 189 BeginWriteAttribute("value", " value=\"", 6084, "\"", 6105, 1); 190 WriteAttributeValue("", 6092, realUser.Fax, 6092, 13, false); 191 EndWriteAttribute(); 192 WriteLiteral(">\r\n\t\t\t\t\t\t\t<label"); 193 BeginWriteAttribute("for", " for=\"", 6122, "\"", 6163, 2); 194 WriteAttributeValue("", 6128, "OrderLineCustomProductFax_", 6128, 26, true); 195 WriteAttributeValue("", 6154, uniqueId, 6154, 9, false); 196 EndWriteAttribute(); 197 WriteLiteral(">"); 198 Write(Translate("Fax")); 199 WriteLiteral("</label>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n"); 200 WriteLiteral("\t\t\t\t\t<div class=\"col-12 col-md-6 mt-3\">\r\n\t\t\t\t\t\t<div class=\"form-floating\">\r\n\t\t\t\t\t\t\t<input"); 201 BeginWriteAttribute("id", " id=\"", 6315, "\"", 6357, 2); 202 WriteAttributeValue("", 6320, "OrderLineCustomProductEmail_", 6320, 28, true); 203 WriteAttributeValue("", 6348, uniqueId, 6348, 9, false); 204 EndWriteAttribute(); 205 WriteLiteral(" class=\"form-control\" type=\"email\""); 206 BeginWriteAttribute("placeholder", " placeholder=\"", 6392, "\"", 6425, 1); 207 WriteAttributeValue("", 6406, Translate("Email"), 6406, 19, false); 208 EndWriteAttribute(); 209 WriteLiteral(" disabled=\"disabled\""); 210 BeginWriteAttribute("value", " value=\"", 6446, "\"", 6469, 1); 211 WriteAttributeValue("", 6454, realUser.Email, 6454, 15, false); 212 EndWriteAttribute(); 213 WriteLiteral(">\r\n\t\t\t\t\t\t\t<label"); 214 BeginWriteAttribute("for", " for=\"", 6486, "\"", 6529, 2); 215 WriteAttributeValue("", 6492, "OrderLineCustomProductEmail_", 6492, 28, true); 216 WriteAttributeValue("", 6520, uniqueId, 6520, 9, false); 217 EndWriteAttribute(); 218 WriteLiteral(">"); 219 Write(Translate("Email")); 220 WriteLiteral("</label>\r\n\t\t\t\t\t\t</div>\r\n\t\t\t\t\t</div>\r\n"); 221 } 222 WriteLiteral("\r\n\t\t\t\t<div class=\"col-12 mt-3\">\r\n\t\t\t\t\t<input class=\"form-control OrderLineCustomProductFileInput\" type=\"file\""); 223 BeginWriteAttribute("id", " id=\"", 6703, "\"", 6744, 2); 224 WriteAttributeValue("", 6708, "OrderLineCustomProductFile_", 6708, 27, true); 225 WriteAttributeValue("", 6735, uniqueId, 6735, 9, false); 226 EndWriteAttribute(); 227 WriteLiteral(" name=\"EcomOrderLineFieldInput_OrderLineCustomProductFile\">\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t\r\n\t\t\t<div"); 228 BeginWriteAttribute("class", " class=\"", 6840, "\"", 6902, 6); 229 WriteAttributeValue("", 6848, "d-flex", 6848, 6, true); 230 WriteAttributeValue(" ", 6854, horizontalAlign, 6855, 16, false); 231 WriteAttributeValue(" ", 6871, fullWidth, 6872, 10, false); 232 WriteAttributeValue(" ", 6882, "flex-row", 6883, 9, true); 233 WriteAttributeValue(" ", 6891, "w-100", 6892, 6, true); 234 WriteAttributeValue(" ", 6897, "mt-3", 6898, 5, true); 235 EndWriteAttribute(); 236 WriteLiteral(">\r\n\t\t\t\t<div"); 237 BeginWriteAttribute("class", " class=\"", 6914, "\"", 6984, 4); 238 WriteAttributeValue("", 6922, "input-group", 6922, 11, true); 239 WriteAttributeValue(" ", 6933, "input-primary-button-group", 6934, 27, true); 240 WriteAttributeValue(" ", 6960, "flex-nowrap", 6961, 12, true); 241 WriteAttributeValue("", 6972, inputSize, 6972, 12, false); 242 EndWriteAttribute(); 243 WriteLiteral(">\r\n"); 244 if (quantitySelector) 245 { 246 WriteLiteral("\t\t\t\t\t\t<input"); 247 BeginWriteAttribute("id", " id=\"", 7037, "\"", 7083, 4); 248 WriteAttributeValue("", 7042, "Quantity_", 7042, 9, true); 249 WriteAttributeValue("", 7051, product.Id, 7051, 13, false); 250 WriteAttributeValue("", 7064, "_", 7064, 1, true); 251 WriteAttributeValue("", 7065, product.VariantId, 7065, 18, false); 252 EndWriteAttribute(); 253 WriteLiteral(" name=\"Quantity\""); 254 BeginWriteAttribute("value", " value=\"", 7100, "\"", 7117, 1); 255 WriteAttributeValue("", 7108, valueQty, 7108, 9, false); 256 EndWriteAttribute(); 257 BeginWriteAttribute("step", " step=\"", 7118, "\"", 7133, 1); 258 WriteAttributeValue("", 7125, stepQty, 7125, 8, false); 259 EndWriteAttribute(); 260 WriteLiteral(" "); 261 Write(minQty); 262 WriteLiteral(" class=\"form-control swift_quantity-field\" style=\"min-width: 60px; max-width: 100px; z-index: 1\" type=\"number\" onchange=\"swift.Cart.UpdateOnEnterKey(event)\" onkeyup=\"swift.Cart.UpdateOnEnterKey(event)\">\r\n"); 263 } 264 else 265 { 266 WriteLiteral("\t\t\t\t\t\t<input"); 267 BeginWriteAttribute("id", " id=\"", 7385, "\"", 7431, 4); 268 WriteAttributeValue("", 7390, "Quantity_", 7390, 9, true); 269 WriteAttributeValue("", 7399, product.Id, 7399, 13, false); 270 WriteAttributeValue("", 7412, "_", 7412, 1, true); 271 WriteAttributeValue("", 7413, product.VariantId, 7413, 18, false); 272 EndWriteAttribute(); 273 WriteLiteral(" name=\"Quantity\" value=\"1\""); 274 BeginWriteAttribute("step", " step=\"", 7458, "\"", 7473, 1); 275 WriteAttributeValue("", 7465, stepQty, 7465, 8, false); 276 EndWriteAttribute(); 277 WriteLiteral(" "); 278 Write(minQty); 279 WriteLiteral(" class=\"form-control swift_quantity-field\" style=\"min-width: 60px; max-width: 100px; z-index: 1\" type=\"hidden\">\r\n"); 280 } 281 WriteLiteral("\r\n\t\t\t\t\t<button type=\"button\" onclick=\"AddToCartForCustomProducts.BeforeSubmitAddToCartForCustomProductsForm(event);\""); 282 BeginWriteAttribute("class", "\r\n\t\t\t\t\t class=\"", 7719, "\"", 7780, 4); 283 WriteAttributeValue("", 7741, "btn", 7741, 3, true); 284 WriteAttributeValue(" ", 7744, "btn-primary", 7745, 12, true); 285 WriteAttributeValue(" ", 7756, buttonSize, 7757, 13, false); 286 WriteAttributeValue(" ", 7770, flexFill, 7771, 9, false); 287 EndWriteAttribute(); 288 WriteLiteral("\r\n\t\t\t\t\t style=\"white-space: nowrap\""); 289 BeginWriteAttribute("title", "\r\n\t\t\t\t\t title=\"", 7823, "\"", 7870, 1); 290 WriteAttributeValue("", 7845, Translate("Add to cart"), 7845, 25, false); 291 EndWriteAttribute(); 292 BeginWriteAttribute("id", "\r\n\t\t\t\t\t id=\"", 7871, "\"", 7948, 4); 293 WriteAttributeValue("", 7890, "AddToCartButton", 7890, 15, true); 294 WriteAttributeValue("", 7905, product.Id, 7905, 13, false); 295 WriteAttributeValue("", 7918, "_", 7918, 1, true); 296 WriteAttributeValue("", 7919, Pageview.CurrentParagraph.ID, 7919, 29, false); 297 EndWriteAttribute(); 298 WriteLiteral("\r\n\t\t\t\t\t data-cart-is-quote=\""); 299 Write(Converter.ToString(userHasPendingQuote).ToLowerInvariant()); 300 WriteLiteral("\"\r\n\t\t\t\t\t data-cart-is-quote-message=\""); 301 Write(Translate("You need to complete your current quote or empty the cart before adding this product to cart")); 302 WriteLiteral("\">\r\n\t\t\t\t\t\t\r\n"); 303 if (!Model.Item.GetBoolean("HideButtonText")) 304 { 305 WriteLiteral("\t\t\t\t\t\t\t<span class=\"text-nowrap d-flex align-items-center justify-content-center gap-2\">\r\n\t\t\t\t\t\t\t\t"); 306 Write(addToCartLabel); 307 WriteLiteral("\r\n\t\t\t\t\t\t\t</span>\r\n"); 308 } 309 else 310 { 311 Write(addToCartLabel); 312 313 } 314 WriteLiteral("\t\t\t\t\t\t\r\n\t\t\t\t\t</button>\r\n\t\t\t\t</div>\r\n\t\t\t</div>\r\n\t\t</form>\r\n\t</div>\r\n"); 315 } 316 else if (Pageview.IsVisualEditorMode) 317 { 318 WriteLiteral("\t<div class=\"alert alert-dark m-0\">"); 319 Write(Translate("Add to cart for custom products")); 320 WriteLiteral("</div>\r\n"); 321 } 322 } 323 #pragma warning restore 1998 324 } 325 } 326 #pragma warning restore 1591 327
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Core 3 @using Dynamicweb.Ecommerce.ProductCatalog 4 5 @{ 6 ProductViewModel product = null; 7 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 8 { 9 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 10 } 11 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 12 { 13 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 14 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 15 16 if (productList?.Products is object) 17 { 18 product = productList.Products[0]; 19 } 20 } 21 22 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 23 24 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 25 bool anonymousUser = Pageview.User == null; 26 bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser; 27 hideAddToCart = !Pageview.IsVisualEditorMode && hideAddToCart; 28 29 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 30 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 31 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 32 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 33 } 34 35 @if (product is object && !hideAddToCart) { 36 bool quantitySelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowQuantitySelector")) && Model.Item.GetBoolean("ShowQuantitySelector"); 37 38 string buttonSize = Model.Item.GetRawValueString("ButtonSize", "regular"); 39 string inputSize = string.Empty; 40 41 switch (buttonSize) 42 { 43 case "small": 44 inputSize = " input-group-sm"; 45 buttonSize = " btn-sm"; 46 break; 47 case "regular": 48 buttonSize = string.Empty; 49 break; 50 case "large": 51 inputSize = " input-group-lg"; 52 buttonSize = " btn-lg"; 53 break; 54 } 55 56 string iconPath = "/Files/icons/"; 57 string url = "/Default.aspx?ID=" + (GetPageIdByNavigationTag("CartService")); 58 if (!url.Contains("LayoutTemplate")) 59 { 60 url += url.Contains("?") ? "&LayoutTemplate=Swift_MiniCart.cshtml" : "?LayoutTemplate=Swift_MiniCart.cshtml"; 61 } 62 63 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 64 string addToCartIcon = Model.Item.GetRawValueString("Icon", iconPath + "shopping-cart.svg"); 65 string addToCartLabel = !addToCartIcon.Contains("_none") ? $"<span class=\"icon-2\">{ReadFile(addToCartIcon)}</span>" : ""; 66 addToCartLabel += !addToCartIcon.Contains("_none") && !Model.Item.GetBoolean("HideButtonText") ? " " : ""; 67 addToCartLabel += !Model.Item.GetBoolean("HideButtonText") ? $"<span class=\"d-none d-md-inline\">{Translate("Add to cart")}</span><span class=\"d-inline d-md-none\">{Translate("Add")}</span>" : ""; 68 69 bool userHasPendingQuote = Dynamicweb.Ecommerce.Common.Context.Cart != null && Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote; 70 71 string minQty = product.PurchaseMinimumQuantity != 1 ? $"min=\"{product.PurchaseMinimumQuantity.ToString()}\"" : "min=\"1\""; 72 string stepQty = product.PurchaseQuantityStep > 1 ? product.PurchaseQuantityStep.ToString() : "1"; 73 string valueQty = product.PurchaseMinimumQuantity > product.PurchaseQuantityStep ? product.PurchaseMinimumQuantity.ToString() : stepQty; 74 75 var uniqueId = $"{Pageview.CurrentParagraph.ID}_{product.Id}_{product.VariantId}"; 76 77 var cartPage = "/Default.aspx?ID=" + GetPageIdByNavigationTag("Cart"); 78 var showUserContactInformation = Model.Item.GetBoolean("ShowUserContactInformation"); 79 var realUser = Dna.Extensions.Users.GetRealUser(); 80 81 <script type="module" src="/Files/Templates/Designs/Swift/Assets/custom-js/custom-js-module/addToCartForCustomProducts.js"></script> 82 83 <div class="item_@Model.Item.SystemName.ToLower()"> 84 85 <form method="post" enctype="multipart/form-data" action="@url" style="z-index: 1" data-cart-page="@cartPage"> 86 <input type="hidden" name="redirect" value="false"> 87 <input type="hidden" name="ProductId" value="@product.Id"> 88 <input type="hidden" name="VariantId" value="@product.VariantId"> 89 <input type="hidden" name="cartcmd" value="add"> 90 91 <div class="row"> 92 <div class="col-12"> 93 <div class="form-floating"> 94 <textarea id="OrderLineCustomProductDescription_@uniqueId" class="form-control" name="@Dna.Keystone.Cart.Constants.RequestFields.CustomProductDescription" placeholder="@Translate("Description")" required="required"></textarea> 95 <label for="OrderLineCustomProductDescription_@uniqueId" class="form-label">@Translate("Description")</label> 96 </div> 97 <div class="invalid-feedback invalid-feedback-description"> 98 @Translate("Please add a description") 99 </div> 100 </div> 101 102 @if (showUserContactInformation) 103 { 104 <div class="col-12 col-md-6 mt-3"> 105 <div class="form-floating"> 106 <input id="OrderLineCustomProductContactPerson_@uniqueId" class="form-control" type="text" placeholder="@Translate("Contact person")" disabled="disabled" value="@realUser.Name"> 107 <label for="OrderLineCustomProductContactPerson_@uniqueId" class="form-label">@Translate("Contact person")</label> 108 </div> 109 </div> 110 111 <div class="col-12 col-md-6 mt-3"> 112 <div class="form-floating"> 113 <input id="OrderLineCustomProductPhone_@uniqueId" class="form-control" type="text" placeholder="@Translate("Phone")" disabled="disabled" value="@realUser.Phone"> 114 <label for="OrderLineCustomProductPhone_@uniqueId">@Translate("Phone")</label> 115 </div> 116 </div> 117 118 <div class="col-12 col-md-6 mt-3"> 119 <div class="form-floating"> 120 <input id="OrderLineCustomProductFax_@uniqueId" class="form-control" type="text" placeholder="@Translate("Fax")" disabled="disabled" value="@realUser.Fax"> 121 <label for="OrderLineCustomProductFax_@uniqueId">@Translate("Fax")</label> 122 </div> 123 </div> 124 125 <div class="col-12 col-md-6 mt-3"> 126 <div class="form-floating"> 127 <input id="OrderLineCustomProductEmail_@uniqueId" class="form-control" type="email" placeholder="@Translate("Email")" disabled="disabled" value="@realUser.Email"> 128 <label for="OrderLineCustomProductEmail_@uniqueId">@Translate("Email")</label> 129 </div> 130 </div> 131 } 132 133 <div class="col-12 mt-3"> 134 <input class="form-control OrderLineCustomProductFileInput" type="file" id="OrderLineCustomProductFile_@uniqueId" name="EcomOrderLineFieldInput_OrderLineCustomProductFile"> 135 </div> 136 </div> 137 138 <div class="d-flex @horizontalAlign @fullWidth flex-row w-100 mt-3"> 139 <div class="input-group input-primary-button-group flex-nowrap@(inputSize)"> 140 @if (quantitySelector) 141 { 142 <input id="Quantity_@(product.Id)_@product.VariantId" name="Quantity" value="@valueQty" step="@stepQty" @minQty class="form-control swift_quantity-field" style="min-width: 60px; max-width: 100px; z-index: 1" type="number" onchange="swift.Cart.UpdateOnEnterKey(event)" onkeyup="swift.Cart.UpdateOnEnterKey(event)"> 143 } 144 else 145 { 146 <input id="Quantity_@(product.Id)_@product.VariantId" name="Quantity" value="1" step="@stepQty" @minQty class="form-control swift_quantity-field" style="min-width: 60px; max-width: 100px; z-index: 1" type="hidden"> 147 } 148 149 <button type="button" onclick="AddToCartForCustomProducts.BeforeSubmitAddToCartForCustomProductsForm(event);" 150 class="btn btn-primary @(buttonSize) @flexFill" 151 style="white-space: nowrap" 152 title="@Translate("Add to cart")" 153 id="AddToCartButton@(product.Id)_@Pageview.CurrentParagraph.ID" 154 data-cart-is-quote="@(Converter.ToString(userHasPendingQuote).ToLowerInvariant())" 155 data-cart-is-quote-message="@Translate("You need to complete your current quote or empty the cart before adding this product to cart")"> 156 157 @if (!Model.Item.GetBoolean("HideButtonText")) 158 { 159 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 160 @addToCartLabel 161 </span> 162 } 163 else 164 { 165 @addToCartLabel 166 } 167 168 </button> 169 </div> 170 </div> 171 </form> 172 </div> 173 } 174 else if (Pageview.IsVisualEditorMode) 175 { 176 <div class="alert alert-dark m-0">@Translate("Add to cart for custom products")</div> 177 } 178