Komponent editor til: Product list detail

Error executing template "Designs/Swift/Paragraph/Swift_ProductHeader.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_ec01e5b34a20471398c732c118a71dc7.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_ProductHeader.cshtml:line 30
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @{ 5 ProductViewModel product = new ProductViewModel(); 6 7 ProductViewModelSettings productSetting = new ProductViewModelSettings 8 { 9 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 10 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 11 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 12 ShopId = Pageview.Area.EcomShopId 13 }; 14 15 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 16 { 17 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 18 } 19 else if (Pageview.Item["DummyProduct"] != null) 20 { 21 string dummyProductId = ""; 22 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 23 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 24 if (productList.Products != null) 25 { 26 foreach (var p in productList.Products) { dummyProductId = p.Id; } 27 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 28 product = dummyProduct; 29 } else { 30 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 31 } 32 } else if (Pageview.Item["DummyProduct"] == null) { 33 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 34 } 35 36 string titleFontSize = Model.Item.GetRawValueString("FontSize", "fs-6"); 37 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 38 horizontalAlign = horizontalAlign == "center" ? "text-center" : horizontalAlign; 39 horizontalAlign = horizontalAlign == "end" ? "text-end" : horizontalAlign; 40 41 string headingLevel = Model.Item.GetString("HeadingLevel", "h2"); 42 string headingLevelStart = $"<{headingLevel} class=\"{titleFontSize} {horizontalAlign} m-0 item_{Model.Item.SystemName.ToLower()}\" itemprop=\"name\">"; 43 string headingLevelStop = $"</{headingLevel}>"; 44 } 45 46 47 @if (product.Id != null) { 48 @headingLevelStart 49 @product.Name 50 @headingLevelStop 51 } else if (Pageview.IsVisualEditorMode) { 52 <div class="alert alert-dark m-0">@Translate("No products available")</div> 53 } 54
Error executing template "Designs/Swift/Paragraph/Swift_ProductNumber.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_f149ebd7cea2404d9782db6e94f10e16.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_ProductNumber.cshtml:line 28
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @{ 5 ProductViewModel product = new ProductViewModel(); 6 7 ProductViewModelSettings productSetting = new ProductViewModelSettings 8 { 9 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 10 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 11 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 12 ShopId = Pageview.Area.EcomShopId 13 }; 14 15 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 16 { 17 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 18 } else if (Pageview.Item["DummyProduct"] != null) { 19 string dummyProductId = ""; 20 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 21 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 22 if (productList.Products != null) 23 { 24 foreach (var p in productList.Products) { dummyProductId = p.Id; } 25 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 26 product = dummyProduct; 27 } else { 28 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 29 } 30 } else if (Pageview.Item["DummyProduct"] == null) { 31 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 32 } 33 34 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 35 horizontalAlign = horizontalAlign == "center" ? "text-center" : horizontalAlign; 36 horizontalAlign = horizontalAlign == "end" ? "text-end" : horizontalAlign; 37 } 38 39 @if (!Model.Item.GetBoolean("HideProductNumber") && product.Id != null) { 40 <div class="fs-7 opacity-85 @horizontalAlign item_@Model.Item.SystemName.ToLower()" itemprop="sku">@product.Number</div> 41 } else if (Pageview.IsVisualEditorMode) { 42 <div class="alert alert-warning">@Translate("No products available")</div> 43 } 44
Error executing template "Designs/Swift/Paragraph/Swift_ProductPriceTable.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_0ab5cad257b54ad18fa2048b404dd01d.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_ProductPriceTable.cshtml:line 33
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @{ 5 bool isVisualEditor = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) ? Convert.ToBoolean(Dynamicweb.Context.Current.Request.QueryString.Get("VisualEdit")) : false; 6 7 ProductViewModel product = new ProductViewModel(); 8 9 ProductViewModelSettings productSetting = new ProductViewModelSettings 10 { 11 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 12 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 13 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 14 ShopId = Pageview.Area.EcomShopId 15 }; 16 17 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 18 19 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 20 { 21 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 22 } else if (Pageview.Item["DummyProduct"] != null) { 23 24 string dummyProductId = ""; 25 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 26 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 27 if (productList.Products != null) 28 { 29 foreach (var p in productList.Products) { dummyProductId = p.Id; } 30 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 31 product = dummyProduct; 32 } else { 33 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 34 } 35 } else if (Pageview.Item["DummyProduct"] == null) { 36 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 37 } 38 39 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 40 bool anonymousUser = Pageview.User == null; 41 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser; 42 hidePrice = Pageview.IsVisualEditorMode ? false : hidePrice; 43 44 if (Pageview.IsVisualEditorMode && product.Prices.Count == 0) { 45 product.Prices.Add(new PriceListViewModel { Price = new PriceViewModel { Price = 95, PriceFormatted = "€95" }, Quantity = 1 }); 46 product.Prices.Add(new PriceListViewModel { Price = new PriceViewModel { Price = 85, PriceFormatted = "€85" }, Quantity = 2 }); 47 } 48 49 string layout = Model.Item.GetRawValueString("Layout", "list"); 50 } 51 52 @if (!hidePrice && product.Prices.Count > 0 && product.Id != null) { 53 if (isLazyLoadingForProductInfoEnabled) { 54 <div class="product-prices-container d-none" data-show-if="LiveProductInfo.product.Prices.length > 0"> 55 @if (layout == "list") { 56 <div class="product-prices item_@Model.Item.SystemName.ToLower() list"> 57 <small class="d-block opacity-75 product-prices-template"><span><span class="js-text-price-quantity"></span> @Translate("PCS")</span> - <span class="fw-bold"><span class="js-text-price-price"></span> <span class="d-none" data-show-if="LiveProductInfo.productPrice.Quantity > 1">@Translate("pr. PCS")</span></span></small> 58 </div> 59 } else if (layout == "table") { 60 <div class="item_@Model.Item.SystemName.ToLower() grid"> 61 <table class="table table-sm mt-3 g-col-12 g-col-lg-6"> 62 <thead> 63 <tr> 64 <td>@Translate("QTY")</td> 65 <td>@Translate("pr. PCS")</td> 66 </tr> 67 </thead> 68 <tbody class="product-prices"> 69 <tr class="product-prices-template"> 70 <td class="js-text-price-quantity"></td> 71 <td class="js-text-price-price"></td> 72 </tr> 73 </tbody> 74 </table> 75 </div> 76 } 77 </div> 78 } 79 else 80 { 81 if (layout == "list") { 82 <div class="item_@Model.Item.SystemName.ToLower() list"> 83 @foreach (PriceListViewModel quantityPrice in product.Prices) 84 { 85 string quantityLabel = Translate("PCS"); 86 string quantityPriceSuffix = quantityPrice.Quantity > 1 ? Translate("pr. PCS") : ""; 87 88 <small class="d-block opacity-75"><span>@quantityPrice.Quantity @quantityLabel</span> - <span class="fw-bold">@quantityPrice.Price.PriceFormatted @quantityPriceSuffix</span></small> 89 } 90 </div> 91 } else if (layout == "table") { 92 <div class="item_@Model.Item.SystemName.ToLower() grid"> 93 <table class="table table-sm mt-3 g-col-12 g-col-lg-6"> 94 <thead> 95 <tr> 96 <td>@Translate("QTY")</td> 97 <td>@Translate("pr. PCS")</td> 98 </tr> 99 </thead> 100 <tbody> 101 @foreach (PriceListViewModel quantityPrice in product.Prices) 102 { 103 <tr> 104 <td>@quantityPrice.Quantity</td> 105 <td>@quantityPrice.Price.PriceFormatted</td> 106 </tr> 107 } 108 </tbody> 109 </table> 110 </div> 111 } 112 } 113 } else if (isVisualEditor) { 114 <div class="alert alert-dark m-0" role="alert"> 115 <span>@Translate("No products available")</span> 116 </div> 117 } 118
Error executing template "Designs/Swift/Paragraph/Swift_ProductVariantSelector.cshtml"
System.Exception: Product id is requred to find a product.
   at Dynamicweb.Core.Ensure.That[TException](Boolean condition, String message)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewModelFactory.CreateView(ProductViewModelSettings settings, String productId, String variantId, String groupId)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewModelFactory.CreateView(ProductViewModelSettings settings, String productId)
   at CompiledRazorTemplates.Dynamic.RazorEngine_a069232f56e4460e882e8522915aad31.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_ProductVariantSelector.cshtml:line 111
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Collections.Generic 3 @using System.Linq 4 @using Dynamicweb.Ecommerce.ProductCatalog 5 @using Dynamicweb.Ecommerce.Variants 6 7 @functions { 8 //Find contrast color (white, black) 9 public static string GetContrastColor(string hexString) 10 { 11 System.Drawing.Color bg = System.Drawing.ColorTranslator.FromHtml(hexString); 12 13 int nThreshold = 105; 14 int bgDelta = Convert.ToInt32((bg.R * 0.299) + (bg.G * 0.587) + 15 (bg.B * 0.114)); 16 17 string foreColor = (255 - bgDelta < nThreshold) ? "#333" : "#fff"; 18 return foreColor; 19 } 20 21 public string GetLayoutForVariantGroup(string variantGroupId) 22 { 23 string showVariantGroups = !string.IsNullOrEmpty(Model.Item.GetString("ShowVariantGroupOptions")) ? Model.Item.GetString("ShowVariantGroupOptions") : "all"; 24 string defaultVariantGroupLayout = Model.Item.GetRawValueString("DefaultVariantGroupLayout", "button"); 25 var selectedVariantGroupsList = !string.IsNullOrEmpty(Model.Item.GetRawValueString("VariantGroups")) ? Model.Item.GetItems("VariantGroups") : new List<Dynamicweb.Frontend.ItemViewModel>(); 26 27 if (showVariantGroups == "all" || selectedVariantGroupsList == null || !selectedVariantGroupsList.Any()) return defaultVariantGroupLayout; 28 29 foreach (var selectedVariantGroupListItem in selectedVariantGroupsList) 30 { 31 var variantGroups = selectedVariantGroupListItem.GetRawValueString("VariantGroups").Split(','); 32 if (variantGroups.Any(s => s.Equals(variantGroupId))) return selectedVariantGroupListItem.GetRawValueString("VariantGroupLayout"); 33 } 34 35 return defaultVariantGroupLayout; 36 } 37 38 //Collect all variant images 39 public static Dictionary<string, string> GetVariantImages(List<VariantInfoViewModel> variantInfo, Dictionary<string, string> list) 40 { 41 foreach (var variantGroup in variantInfo) 42 { 43 if (variantGroup.Image?.Value != null && !list.ContainsKey(variantGroup.OptionID)) { 44 list.Add(variantGroup.OptionID, variantGroup.Image.Value); 45 } 46 47 if (variantGroup.VariantInfo != null) { 48 GetVariantImages(variantGroup.VariantInfo, list); 49 } 50 } 51 52 return list; 53 } 54 55 private string GetDefaultOrVariantGroupValue(string variantGroupId, string itemField, string itemFieldDefaultValue, Dictionary<string, string> fieldValueMapping) 56 { 57 string horizontalTextAlign = Model.Item.GetRawValueString(itemField, itemFieldDefaultValue); 58 horizontalTextAlign = fieldValueMapping.ContainsKey(horizontalTextAlign) ? fieldValueMapping[horizontalTextAlign] : horizontalTextAlign; 59 60 // If no variantGroup (i.e. Visual Editor), return default value 61 if (string.IsNullOrEmpty(variantGroupId)) return horizontalTextAlign; 62 63 string showVariantGroups = Model.Item.GetString("ShowVariantGroupOptions", "all"); 64 var selectedVariantGroupsList = !string.IsNullOrEmpty(Model.Item.GetRawValueString("VariantGroups")) ? Model.Item.GetItems("VariantGroups") : new List<Dynamicweb.Frontend.ItemViewModel>(); 65 // If no exceptions or settings are all the same, return default value 66 if (showVariantGroups == "all" || selectedVariantGroupsList == null || !selectedVariantGroupsList.Any()) return horizontalTextAlign; 67 68 // Get specific value for variant group 69 foreach (var selectedVariantGroupListItem in selectedVariantGroupsList) 70 { 71 var variantGroups = selectedVariantGroupListItem.GetRawValueString("VariantGroups").Split(','); 72 if (!variantGroups.Any(s => s.Equals(variantGroupId))) continue; 73 74 horizontalTextAlign = selectedVariantGroupListItem.GetRawValueString(itemField, itemFieldDefaultValue); 75 horizontalTextAlign = fieldValueMapping.ContainsKey(horizontalTextAlign) ? fieldValueMapping[horizontalTextAlign] : horizontalTextAlign; 76 } 77 78 return horizontalTextAlign; 79 } 80 } 81 82 @{ 83 ProductViewModel product = new ProductViewModel(); 84 85 ProductViewModelSettings productSetting = new ProductViewModelSettings 86 { 87 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 88 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 89 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 90 ShopId = Pageview.Area.EcomShopId 91 }; 92 93 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 94 { 95 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 96 } 97 else if (Pageview.Item["DummyProduct"] != null) 98 { 99 100 string dummyProductId = ""; 101 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 102 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 103 if (productList.Products != null) 104 { 105 foreach (var p in productList.Products) { dummyProductId = p.Id; } 106 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 107 product = dummyProduct; 108 } 109 else 110 { 111 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault()?.Id); 112 } 113 } 114 else if (Pageview.Item["DummyProduct"] == null) 115 { 116 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault()?.Id); 117 } 118 119 bool hideGroupHeaders = Model.Item.GetBoolean("HideGroupHeaders"); 120 } 121 122 @if (product.Id != null) 123 { 124 var productVariantGroups = product.VariantGroups(); 125 126 if (productVariantGroups.Any()) 127 { 128 string[] variantId = product.VariantId.Split('.'); 129 int groupNumber = 1; 130 131 string baseUrl = $"Default.aspx?ID={GetPageIdByNavigationTag("Shop")}&GroupID={product.PrimaryOrDefaultGroup.Id}&ProductID={product.Id}"; 132 string variantUrl = ""; 133 if (!string.IsNullOrEmpty(product.VariantId)) 134 { 135 variantUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl($"Default.aspx?ID={GetPageIdByNavigationTag("Shop")}&GroupID={product.PrimaryOrDefaultGroup.Id}&ProductID={product.Id}&VariantID={product.VariantId}"); 136 } 137 138 Dictionary<string, string> variantImages = new Dictionary<string, string>(); 139 variantImages = GetVariantImages(product.VariantInfo.VariantInfo, variantImages); 140 141 <form class="d-flex flex-column gap-2 js-variant-selector item_@Model.Item.SystemName.ToLower()" data-combinations="@string.Join(",", product.VariantCombinations())" data-base-url="@baseUrl" data-friendly-url="@variantUrl" > 142 @foreach (var variantGroup in productVariantGroups) 143 { 144 VariantGroupViewModel group = variantGroup; 145 string variantGroupLayout = GetLayoutForVariantGroup(variantGroup.Id); 146 string horizontalAlign = GetDefaultOrVariantGroupValue(variantGroup.Id, "HorizontalAlignment", "", new Dictionary<string, string> { { "center", "justify-content-center" }, { "end", "justify-content-end" } }); 147 string horizontalTextAlign = GetDefaultOrVariantGroupValue(variantGroup.Id, "HorizontalAlignment", "", new Dictionary<string, string> { { "center", "text-center" }, { "end", "text-end" } }); 148 149 <div> 150 @if (!hideGroupHeaders) 151 { 152 <h3 class="h6 @horizontalTextAlign">@group.Name</h3> 153 } 154 <div class="d-flex gap-2 @horizontalAlign flex-wrap js-variant-group" data-group-id="@groupNumber"> 155 @if (variantGroupLayout == "button") 156 { 157 foreach (var option in group.Options) 158 { 159 string active = variantId != null && variantId.Contains(option.Id) ? "active" : ""; 160 string buttonId = $"{product.Id}_{option.Id}_{Pageview.CurrentParagraph.ID}"; 161 string contrastColor = string.Empty; 162 string optionLayout = optionLayout = GetDefaultOrVariantGroupValue(variantGroup.Id, "ButtonLayout", "rounded-circle", new Dictionary<string, string> { { "round", "rounded-circle" }, { "square", "" } }); 163 var displayType = group.DisplayType; 164 165 switch (displayType) 166 { 167 case VariantGroupDisplayType.VariantColor: 168 contrastColor = GetContrastColor(option.Color); 169 <button type="button" class="btn colorbox @optionLayout d-inline-block variant-option border js-variant-option @active" style="background-color: @option.Color; --variantoption-check-color: @contrastColor" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="@option.Id" id="@buttonId"> 170 <span class="visually-hidden">@option.Color</span> 171 </button> 172 break; 173 case VariantGroupDisplayType.VariantImage: 174 string variantImage = string.Empty; 175 if (variantImages.TryGetValue(option.Id, out variantImage)) 176 { 177 <button type="button" class="btn p-0 d-inline-block @optionLayout variant-option js-variant-option @active" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="@option.Id" id="@(product.Id)_@(option.Id)_@Pageview.CurrentParagraph.ID"> 178 <img class="@optionLayout" src="/Admin/Public/GetImage.ashx?image=@(variantImage)&width=42&Format=WebP&Quality=70"> 179 </button> 180 } else { 181 <button type="button" class="btn btn-secondary d-inline-block variant-option js-variant-option @active" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="@option.Id" id="@(product.Id)_@(option.Id)_@Pageview.CurrentParagraph.ID"> 182 @option.Name 183 </button> 184 } 185 186 break; 187 case VariantGroupDisplayType.VariantName: 188 <button type="button" class="btn btn-secondary d-inline-block variant-option js-variant-option @active" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="@option.Id" id="@buttonId"> 189 @option.Name 190 </button> 191 break; 192 case VariantGroupDisplayType.VariantOptionImage: 193 <button type="button" class="btn p-0 d-inline-block @optionLayout variant-option js-variant-option @active" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="@option.Id" id="@(product.Id)_@(option.Id)_@Pageview.CurrentParagraph.ID"> 194 <img class="@optionLayout" src="/Admin/Public/GetImage.ashx?image=@(option.OptionImage.Value)&width=42&Format=WebP&Quality=70"> 195 </button> 196 break; 197 default: 198 if (!string.IsNullOrEmpty(option.Color)) 199 { 200 contrastColor = GetContrastColor(option.Color); 201 <button type="button" class="btn colorbox @optionLayout d-inline-block variant-option border js-variant-option @active" style="background-color: @option.Color; --variantoption-check-color: @contrastColor" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="@option.Id" id="@buttonId"> 202 <span class="visually-hidden">@option.Color</span> 203 </button> 204 } 205 else if (!string.IsNullOrEmpty(option.Color) && !string.IsNullOrEmpty(option.Image.Value)) 206 { 207 <button type="button" class="btn p-0 d-inline-block @optionLayout variant-option js-variant-option @active" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="@option.Id" id="@buttonId"> 208 <img src="/Admin/Public/GetImage.ashx?image=@(option.Image.Value)&width=42&Format=WebP&Quality=70"> 209 </button> 210 } 211 else 212 { 213 <button type="button" class="btn btn-secondary d-inline-block variant-option js-variant-option @active" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="@option.Id" id="@buttonId"> 214 @option.Name 215 </button> 216 } 217 break; 218 } 219 } 220 } 221 else 222 { 223 <select class="form-select" id="VariantDropdown_@variantGroup.Id" aria-label="@variantGroup.Name" onchange="swift.VariantSelector.OptionClick(event)"> 224 @if (string.IsNullOrEmpty(product.VariantId)) { 225 <option value="" class="variant-option js-variant-option" data-variant-id="">@Translate("Nothing selected")</option> 226 } 227 228 @foreach (var option in variantGroup.Options) 229 { 230 string active = variantId != null && variantId.Contains(option.Id) ? "active" : ""; 231 var selected = variantId != null && variantId.Contains(option.Id) ? "selected" : ""; 232 var value = $"{product.Id}_{option.Id}"; 233 234 <option value="@(value)" class="variant-option js-variant-option @active" data-variant-id="@option.Id" id="@(value)_@(Pageview.CurrentParagraph.ID)" @selected>@option.Name</option> 235 } 236 </select> 237 } 238 </div> 239 </div> 240 241 242 groupNumber++; 243 } 244 </form> 245 246 <script type="module"> 247 swift.VariantSelector.init(); 248 </script> 249 } 250 else if (Pageview.IsVisualEditorMode) 251 { 252 string horizontalAlign = GetDefaultOrVariantGroupValue("", "HorizontalAlignment", "", new Dictionary<string, string> { { "center", "justify-content-center" }, { "end", "justify-content-end" } }); 253 string horizontalTextAlign = GetDefaultOrVariantGroupValue("", "HorizontalAlignment", "", new Dictionary<string, string> { { "center", "text-center" }, { "end", "text-end" } }); 254 255 <form class="d-flex flex-column js-variant-selector item_@Model.Item.SystemName.ToLower()" data-combinations="VO1,VO2,VO3,VO4"> 256 <div> 257 @if (!hideGroupHeaders) 258 { 259 <h3 class="h6 @horizontalTextAlign">@Translate("Sizes")</h3> 260 } 261 <div class="mb-3 @horizontalAlign js-variant-group" data-group-id="0"> 262 <button type="button" class="btn btn-secondary d-inline-block mb-2 variant-option js-variant-option" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="VO1" id="@(product.Id)_VO1_@Pageview.CurrentParagraph.ID">S</button> 263 <button type="button" class="btn btn-secondary d-inline-block mb-2 variant-option js-variant-option" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="VO2" id="@(product.Id)_VO2_@Pageview.CurrentParagraph.ID">M</button> 264 <button type="button" class="btn btn-secondary d-inline-block mb-2 variant-option js-variant-option" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="VO3" id="@(product.Id)_VO3_@Pageview.CurrentParagraph.ID">L</button> 265 <button type="button" class="btn btn-secondary d-inline-block mb-2 variant-option js-variant-option" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="VO4" id="@(product.Id)_VO4_@Pageview.CurrentParagraph.ID">XL</button> 266 </div> 267 </div> 268 </form> 269 270 <script type="module"> 271 swift.VariantSelector.init(); 272 </script> 273 } 274 } 275 else if (Pageview.IsVisualEditorMode) 276 { 277 <div class="alert alert-dark m-0" role="alert"> 278 <span>@Translate("No products available")</span> 279 </div> 280 } 281
Error executing template "Designs/Swift/Paragraph/Swift_ProductAddToCart.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_87c6f7370b154fe598ec7350ecc9f5cf.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_ProductAddToCart.cshtml:line 30
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 5 @{ 6 ProductViewModel product = new ProductViewModel(); 7 8 ProductViewModelSettings productSetting = new ProductViewModelSettings 9 { 10 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 11 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 12 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 13 ShopId = Pageview.Area.EcomShopId 14 }; 15 16 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 17 { 18 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 19 } else if (Pageview.Item["DummyProduct"] != null) { 20 21 string dummyProductId = ""; 22 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 23 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 24 if (productList.Products != null) 25 { 26 foreach (var p in productList.Products) { dummyProductId = p.Id; } 27 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 28 product = dummyProduct; 29 } else { 30 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 31 } 32 } else if (Pageview.Item["DummyProduct"] == null) { 33 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 34 } 35 36 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 37 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 38 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 39 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 40 41 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 42 bool anonymousUser = Pageview.User == null; 43 bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsWebServiceConnectionAvailable"]); 44 bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHideAddToCart") && isErpConnectionDown; 45 hideAddToCart = Pageview.IsVisualEditorMode ? false : hideAddToCart; 46 bool favoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowAddToFavorites")) ? Model.Item.GetBoolean("ShowAddToFavorites") : false; 47 bool quantitySelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowQuantitySelector")) ? Model.Item.GetBoolean("ShowQuantitySelector") : false; 48 bool unitsSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowUnitsSelector")) ? Model.Item.GetBoolean("ShowUnitsSelector") : false; 49 bool hideInventory = !string.IsNullOrEmpty(Model.Item.GetString("HideInventory")) ? Model.Item.GetBoolean("HideInventory") : false; 50 bool hideStockState = !string.IsNullOrEmpty(Model.Item.GetString("HideStockState")) ? Model.Item.GetBoolean("HideStockState") : false; 51 52 string buttonSize = Model.Item.GetRawValueString("ButtonSize", "regular"); 53 string inputSize = string.Empty; 54 55 switch (buttonSize) 56 { 57 case "small": 58 inputSize = " input-group-sm"; 59 buttonSize = " btn-sm"; 60 break; 61 case "regular": 62 buttonSize = string.Empty; 63 break; 64 case "large": 65 inputSize = " input-group-lg"; 66 buttonSize = " btn-lg"; 67 break; 68 } 69 } 70 71 @if (!hideAddToCart && product.Id != null) { 72 string iconPath = "/Files/icons/"; 73 string url = "/Default.aspx?ID=" + (GetPageIdByNavigationTag("CartService")); 74 if (!url.Contains("LayoutTemplate")) 75 { 76 url += url.Contains("?") ? "&LayoutTemplate=Swift_MiniCart.cshtml" : "?LayoutTemplate=Swift_MiniCart.cshtml"; 77 } 78 79 string disableAddToCart = (product.StockLevel <= 0) ? "disabled" : ""; 80 bool isNeverOutOfStock = product.NeverOutOfstock; 81 disableAddToCart = isNeverOutOfStock ? "" : disableAddToCart; 82 83 string whenVariantsExist = Model.Item.GetRawValueString("WhenVariantsExist", "hide"); 84 85 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 86 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 87 string addToCartIcon = Model.Item.GetRawValueString("Icon", iconPath + "shopping-cart.svg"); 88 string addToCartLabel = !addToCartIcon.Contains("_none") ? "<span class=\"icon-2\">" + ReadFile(addToCartIcon) + "</span>" : ""; 89 addToCartLabel += !addToCartIcon.Contains("_none") && !Model.Item.GetBoolean("HideButtonText") ? " " : ""; 90 addToCartLabel += !Model.Item.GetBoolean("HideButtonText") ? Translate("Add to cart") : ""; 91 92 if (product.VariantInfo.VariantInfo == null || whenVariantsExist == "disable") { 93 string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : product.DefaultUnitId; 94 if (string.IsNullOrEmpty(unitId) && product?.UnitOptions != null) { 95 if (product.UnitOptions.FirstOrDefault<UnitOptionViewModel>() != null) { 96 unitId = product.UnitOptions.FirstOrDefault<UnitOptionViewModel>().Id; 97 } 98 } 99 100 string minQty = product.PurchaseMinimumQuantity != 1 ? "min=\"" + product.PurchaseMinimumQuantity.ToString() + "\"" : "min=\"1\""; 101 string stepQty = product.PurchaseQuantityStep > 1 ? product.PurchaseQuantityStep.ToString() : "1"; 102 string valueQty = product.PurchaseMinimumQuantity > product.PurchaseQuantityStep ? product.PurchaseMinimumQuantity.ToString() : stepQty; 103 disableAddToCart = product.VariantInfo.VariantInfo != null && string.IsNullOrEmpty(product.VariantId) ? "disabled" : disableAddToCart; 104 105 var reserveMode = Dynamicweb.Ecommerce.Frontend.Cart.ProductReserve.Mode; 106 107 if (unitsSelector && product.UnitOptions.Count > 0) { 108 <form method="post" action="/Default.aspx?ID=@(Pageview.Page.ID)&ProductId=@product.Id" id="UnitSelectorForm_@(product.Id)_@(product.VariantId)_@Model.ID"> 109 <input type="hidden" name="redirect" value="false"> 110 <input type="hidden" name="VariantID" value="@product.VariantId"> 111 <input type="hidden" name="UnitID" class="js-unit-id" value="@unitId"> 112 </form> 113 } 114 115 <div class="d-flex @horizontalAlign @fullWidth js-input-group item_@Model.Item.SystemName.ToLower()"> 116 <form method="post" action="@url" class="@fullWidth" style="z-index: 1"> 117 <input type="hidden" name="redirect" value="false"> 118 <input type="hidden" name="ProductId" value="@product.Id"> 119 <input type="hidden" name="ProductName" value="@product.Name"> 120 <input type="hidden" name="ProductVariantName" value="@product.VariantName"> 121 <input type="hidden" name="ProductCurrency" value="@Dynamicweb.Ecommerce.Common.Context.Currency.Code"> 122 <input type="hidden" name="ProductPrice" value="@PriceViewModelExtensions.ToStringInvariant(product.Price)"> 123 <input type="hidden" name="ProductReferer" value="component_ProductAddToCart"> 124 <input type="hidden" name="cartcmd" value="add"> 125 126 @if (reserveMode == Dynamicweb.Ecommerce.Frontend.Cart.ProductReserveMode.AddToCart) 127 { 128 <input type="hidden" name="GetReservedAmount" value="true"> 129 } 130 131 @if (!string.IsNullOrEmpty(product.VariantId)) 132 { 133 <input type="hidden" name="VariantId" value="@product.VariantId"> 134 } 135 136 @if (!product.NeverOutOfstock) 137 { 138 <input type="hidden" name="Stock" value="@product.StockLevel"> 139 140 <template class="js-out-of-stock-notice"> 141 <div class="modal-header"> 142 <h1 class="modal-title fs-5">@Translate("Stock limit")</h1> 143 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 144 </div> 145 <div class="modal-body"> 146 @Translate("There are not enough products in stock. The product might be sold out or discontinued. Please adjust the quantity.") 147 </div> 148 </template> 149 } 150 151 @if (stepQty != "1") 152 { 153 <template class="js-step-quantity-warning"> 154 <div class="modal-header"> 155 <h1 class="modal-title fs-5">@Translate("The quantity is not valid")</h1> 156 </div> 157 <div class="modal-body"> 158 @Translate("Please select a quantity that is dividable by") @stepQty 159 </div> 160 </template> 161 } 162 @if (product.PurchaseMinimumQuantity != 1) 163 { 164 <template class="js-min-quantity-warning"> 165 <div class="modal-header"> 166 <h1 class="modal-title fs-5">@Translate("The product could not be added to the cart")</h1> 167 </div> 168 <div class="modal-body"> 169 @Translate("The quantity is not valid. You must buy at least") @product.PurchaseMinimumQuantity 170 </div> 171 </template> 172 } 173 174 @if (quantitySelector || (!anonymousUser && product.VariantInfo.VariantInfo != null) || (!anonymousUser && favoritesSelector)) 175 { 176 <input type="hidden" id="Unit_@(product.Id)_@product.VariantId" name="UnitID" value="@unitId" /> 177 } 178 179 <div class="d-flex flex-row w-100"> 180 @if (!anonymousUser && favoritesSelector) 181 { 182 @RenderPartial("Components/ToggleFavorite.cshtml", product) 183 } 184 185 @if (!quantitySelector) 186 { 187 <input id="Quantity_@(product.Id)_@product.VariantId" name="Quantity" value="@valueQty" type="hidden" @disableAddToCart> 188 } 189 190 <div class="input-group input-primary-button-group flex-nowrap@(inputSize)"> 191 @if (quantitySelector) 192 { 193 <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)" @disableAddToCart> 194 } 195 196 @if (unitsSelector && product.UnitOptions.Count > 0) 197 { 198 string selectedUnitName = !string.IsNullOrEmpty(unitId) && product?.UnitOptions != null ? unitId : product.UnitOptions.FirstOrDefault<UnitOptionViewModel>().Name; 199 200 foreach (var unitOption in product.UnitOptions) 201 { 202 if (unitOption.Id == unitId) 203 { 204 selectedUnitName = unitOption.Name; 205 } 206 } 207 208 <button class="btn btn-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> 209 @selectedUnitName 210 </button> 211 <ul class="dropdown-menu swift_unit-field"> 212 @foreach (var unitOption in product.UnitOptions) 213 { 214 var selectedUnit = unitOption.Id == unitId ? "selected" : ""; 215 216 <li> 217 <button type="button" class="btn dropdown-item" data-value="@unitOption.Id" onclick="document.querySelector('#UnitSelectorForm_@(product.Id)_@(product.VariantId)_@Model.ID').querySelector('.js-unit-id').value = this.getAttribute('data-value'); 218 document.querySelector('#Unit_@(product.Id)_@product.VariantId').value = this.getAttribute('data-value'); 219 swift.PageUpdater.Update(document.querySelector('#UnitSelectorForm_@(product.Id)_@(product.VariantId)_@Model.ID'))"> 220 <span>@unitOption.Name</span> 221 <span> 222 @if (unitOption.StockLevel > 0) 223 { 224 if (!Model.Item.GetBoolean("HideInventory")) 225 { 226 <span class="small text-success">@unitOption.StockLevel @Translate("In stock")</span> 227 } 228 else 229 { 230 <span class="small text-success">@Translate("In stock")</span> 231 } 232 } 233 else 234 { 235 <span class="small text-danger">@Translate("Out of Stock")</span> 236 } 237 </span> 238 </button> 239 </li> 240 } 241 </ul> 242 } 243 244 <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-primary @(buttonSize) @flexFill js-add-to-cart-button" style="white-space: nowrap" @disableAddToCart title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)_@Pageview.CurrentParagraph.ID"> 245 @if (!Model.Item.GetBoolean("HideButtonText")) 246 { 247 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 248 @addToCartLabel 249 </span> 250 } 251 else 252 { 253 @addToCartLabel 254 } 255 </button> 256 257 </div> 258 </div> 259 </form> 260 </div> 261 } else if (whenVariantsExist == "modal") { 262 string buttonText = Translate("Select"); 263 264 string variantSelectorServicePageId = !string.IsNullOrEmpty(Model.Item.GetString("VariantSelectorServicePageId")) ? Model.Item.GetLink("VariantSelectorServicePageId").PageId.ToString() : ""; 265 variantSelectorServicePageId = variantSelectorServicePageId != "" ? variantSelectorServicePageId : GetPageIdByNavigationTag("VariantSelectorService").ToString(); 266 267 <div class="d-flex @horizontalAlign w-100 item_@Model.Item.SystemName.ToLower()"> 268 @if (!anonymousUser && favoritesSelector) 269 { 270 @RenderPartial("Components/ToggleFavorite.cshtml", product) 271 } 272 <form action="/Default.aspx?ID=@variantSelectorServicePageId" data-response-target-element="DynamicModalContent" data-preloader="inline" style="z-index: 1" class="@fullWidth"> 273 <input type="hidden" name="ProductID" value="@product.Id"> 274 <input type="hidden" name="QuantitySelector" value="@quantitySelector.ToString()"> 275 <input type="hidden" name="HideInventory" value="@hideInventory.ToString()"> 276 <input type="hidden" name="HideStockState" value="@hideStockState.ToString()"> 277 <input type="hidden" name="VariantSelectorServicePage" value="@variantSelectorServicePageId"> 278 <input type="hidden" name="ViewType" value="ModalContent"> 279 <button type="button" onclick="swift.PageUpdater.Update(event)" class="btn btn-primary@(buttonSize) @fullWidth" title="@Translate("Select")" data-bs-toggle="modal" data-bs-target="#DynamicModal" id="OpenVariantSelectorModal@(product.Id)_@Pageview.CurrentParagraph.ID">@buttonText</button> 280 </form> 281 </div> 282 } 283 } else if (Pageview.IsVisualEditorMode) { 284 <div class="alert alert-dark m-0">@Translate("No products available")</div> 285 } 286
Ved at klikke 'Acceptér Alle' så giver til tilladelse til at vi må indsamle information om dig til forskellige formål, hvilket inkluderer: Funktionalitet, statistik og marketing