Error executing template "Designs/Swift/eCom/ProductCatalog/ProductViewDetail.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.Ecommerce.DynamicwebLiveIntegration_ZB.Products.ProductPriceProvider.PreparePrices(PriceContext context, IEnumerable`1 selections)
   at Dynamicweb.Ecommerce.Prices.PriceManager.PreparePrices(PriceContext context, IEnumerable`1 selections)
   at Dynamicweb.Ecommerce.Prices.PriceManager.PreparePrices(PriceContext context, IEnumerable`1 products, Int64 stockLocationId)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.PreparePrices(PriceContext context, Boolean& pricesHasBeenPrepared, Object lock, IList`1 products, Int64 stockLocationId)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetPrice(PriceViewModelSettings settings, IList`1 products, Boolean& pricesHasBeenPrepared, Object lock, Lazy`1 priceInfo)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass15_2.<BulkCreateView>b__50()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_8107764f35e54c20a8efb52dedb364e3.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits ViewModelTemplate<ProductViewModel> @using Dynamicweb.Rendering @using Dynamicweb.Ecommerce.ProductCatalog @using Dynamicweb.Core @{ string metaDescription = string.IsNullOrEmpty(Model.MetaDescription) ? Model.Name : Model.MetaDescription; Pageview.Meta.AddTag($"<meta property=\"og:image\" content=\"{Dynamicweb.Context.Current.Request.Url.Scheme}://{Dynamicweb.Context.Current.Request.Url.Host}{Model.DefaultImage.Value}\">"); Pageview.Meta.AddTag($"<meta property=\"og:image:alt\" content=\"{Model.Name}\">"); Pageview.Meta.AddTag($"<meta property=\"og:description\" content=\"{metaDescription}\">"); Pageview.Meta.AddTag("twitter:image", Model.DefaultImage.Value); Pageview.Meta.AddTag("twitter:image:alt", Model.Name); Pageview.Meta.AddTag("twitter:description", metaDescription); } @{ if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) { Dynamicweb.Context.Current.Items["ProductDetails"] = Model; } else { Dynamicweb.Context.Current.Items.Add("ProductDetails", Model); } bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); if (isLazyLoadingForProductInfoEnabled) { string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower(); bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); bool hasVariantId = !string.IsNullOrEmpty(Model.VariantId); string variantIdParam = hasVariantId ? $"/{Model.VariantId}" : ""; string priceFilledProperties = $"Price,PriceFormatted{(showPricesWithVat == "false" && !neverShowVat ? ",PriceWithVat,PriceWithVatFormatted" : "")}"; string productInfoFeed = $@"/dwapi/ecommerce/products/{Model.Id}{variantIdParam} ?UserId={Converter.ToString(Pageview.User?.ID)} &LanguageId={Pageview.Area.EcomLanguageId}&CurrencyCode={Pageview.Area.EcomCurrencyId}&CountryCode={Pageview.Area.EcomCountryCode}&ShopId={Pageview.Area.EcomShopId} &FilledProperties=Id,Price,PriceBeforeDiscount,StockLevel,VariantInfo,NeverOutOfstock,Prices &PriceSettings.ShowPricesWithVat={Pageview.Area.EcomPricesWithVat} &PriceSettings.FilledProperties={priceFilledProperties} &getproductinfo=true"; Dynamicweb.Context.Current.Items["ProductInfoFeed"] = productInfoFeed; <script type="module"> swift.LiveProductInfo.init(); </script> } } <script> gtag("event", "view_item", { currency: "@Model.Price.CurrencyCode", value: @Model.Price.ToStringInvariant(), items: [ { item_id: "@Model.Number", item_name: "@Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(Model.Name)", currency: "@Model.Price.CurrencyCode", price: @Model.Price.ToStringInvariant(), discount: @Model.Discount.ToStringInvariant() } ] }); </script> <script> window.addEventListener('load', function (event) { swift.Video.init(); }); </script>

12-14 X 1-1/2 SLOT FLAT T/S ZINC

12P150TSF0Z
Error executing template "/Designs/Swift/Paragraph/Custom_Swift_ProductPrice.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.Ecommerce.DynamicwebLiveIntegration_ZB.Products.ProductPriceProvider.PreparePrices(PriceContext context, IEnumerable`1 selections)
   at Dynamicweb.Ecommerce.Prices.PriceManager.PreparePrices(PriceContext context, IEnumerable`1 selections)
   at Dynamicweb.Ecommerce.Prices.PriceManager.PreparePrices(PriceContext context, IEnumerable`1 products, Int64 stockLocationId)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.PreparePrices(PriceContext context, Boolean& pricesHasBeenPrepared, Object lock, IList`1 products, Int64 stockLocationId)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.GetPrice(PriceViewModelSettings settings, IList`1 products, Boolean& pricesHasBeenPrepared, Object lock, Lazy`1 priceInfo)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass15_2.<BulkCreateView>b__50()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
   at System.Lazy`1.CreateValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_b2e89288b6424502a8485c567d1198a0.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   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 = null; 6 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 7 { 8 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 9 } 10 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 11 { 12 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 13 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 14 15 if (productList?.Products is object) 16 { 17 product = productList.Products[0]; 18 } 19 } 20 21 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 22 bool anonymousUser = Pageview.User == null; 23 bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsWebServiceConnectionAvailable"]); 24 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHidePrices") && isErpConnectionDown; 25 26 bool productIsDiscontinued = product is object && product.Discontinued; 27 bool doNotShowPriceIfProductIsDiscontinued = Model.Item.GetBoolean("DoNotShowPriceIfProductIsDiscontinued"); 28 var isDiscontinued = productIsDiscontinued && doNotShowPriceIfProductIsDiscontinued; 29 } 30 31 @if (product is object && !hidePrice && !isDiscontinued) { 32 bool showInformativePrice = Model.Item.GetBoolean("ShowInformativePrice"); 33 string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : string.Empty; 34 35 string priceFontSize = Model.Item.GetRawValueString("PriceSize", "fs-2"); 36 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 37 string layout = Model.Item.GetRawValueString("Layout", "horizontal"); 38 string textAlign = horizontalAlign == "center" ? "text-center" : string.Empty; 39 textAlign = horizontalAlign == "end" ? "text-end" : textAlign; 40 41 horizontalAlign = horizontalAlign == "center" && layout == "horizontal" ? "justify-content-center" : horizontalAlign; 42 horizontalAlign = horizontalAlign == "end" && layout == "horizontal" ? "justify-content-end" : horizontalAlign; 43 horizontalAlign = horizontalAlign == "center" && layout == "vertical" ? "align-items-center" : horizontalAlign; 44 horizontalAlign = horizontalAlign == "end" && layout == "vertical" ? "align-items-end" : horizontalAlign; 45 46 string flexDirection = layout == "horizontal" ? string.Empty : "flex-column"; 47 string flexGap = layout == "horizontal" ? "gap-2" : string.Empty; 48 string order = layout == "horizontal" ? string.Empty : "order-2"; 49 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? "theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 50 theme = GetViewParameter("theme") != null ? GetViewParameterString("theme") : theme; 51 52 string contentPadding = Model.Item.GetRawValueString("ContentPadding", ""); 53 contentPadding = contentPadding == "none" ? "p-0" : contentPadding; 54 contentPadding = contentPadding == "small" ? "p-1 px-md-2 py-md-1" : contentPadding; 55 contentPadding = contentPadding == "large" ? "p-2 px-md-3 py-md-2" : contentPadding; 56 57 string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower(); 58 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 59 60 string priceMin = ""; 61 string priceMax = ""; 62 63 string liveInfoClass = ""; 64 string productInfoFeed = ""; 65 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 66 if (isLazyLoadingForProductInfoEnabled) 67 { 68 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 69 { 70 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 71 if (!string.IsNullOrEmpty(productInfoFeed)) 72 { 73 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 74 } 75 } 76 liveInfoClass = "js-live-info"; 77 } 78 string defaultpricestr = product.ProductFields.Values.FirstOrDefault(x => x.SystemName == "Default_price")?.Value.ToString(); 79 double defaultprice = !string.IsNullOrEmpty(defaultpricestr) ? Convert.ToDouble(defaultpricestr) : 0.0; 80 var callforprice = product.ProductFields.Values.FirstOrDefault(x => x.SystemName == "Call_for_Price")?.Value; 81 string callforpricestr=""; 82 if (callforprice != null) 83 { 84 if (callforprice.GetType() == typeof(System.Collections.Generic.List<FieldOptionValueViewModel>)) 85 { 86 var callpriceopt=callforprice as System.Collections.Generic.List<FieldOptionValueViewModel>; 87 foreach(FieldOptionValueViewModel opt in callpriceopt) 88 { 89 callforpricestr=opt.Value.ToString(); 90 } 91 } 92 else 93 { 94 callforpricestr=callforprice.ToString(); 95 } 96 } 97 98 if (callforpricestr != "Yes") 99 { 100 <div class="@textAlign @liveInfoClass item_@Model.Item.SystemName.ToLower()" data-product-id="@product.Id" data-variant-id="@product.VariantId" @productInfoFeed> 101 @if (showInformativePrice && product.PriceInformative.Price != 0) 102 { 103 <div class="opacity-50"> 104 <span>@Translate("RRP") </span> 105 <span class="text-decoration-line-through text-price">@product.PriceInformative.PriceFormatted</span> 106 </div> 107 } 108 <div class="@priceFontSize m-0 d-flex @flexDirection @flexGap @horizontalAlign" style="row-gap: 0 !important" itemprop="offers" itemscope itemtype="https://schema.org/Offer"> 109 @if(defaultprice>0 && defaultprice != product.Price.Price && defaultprice > product.Price.Price) 110 { 111 Dynamicweb.Ecommerce.International.Currency currency =Dynamicweb.Ecommerce.Services.Currencies.GetCurrency(product.Price.CurrencyCode); 112 <div class="cus-user__price text-price">@currency.Symbol @defaultprice.ToString("0.00")</div> 113 <div class="text-price">@product.Price.PriceFormatted</div> 114 } 115 else 116 { 117 <span itemprop="priceCurrency" content="@product.Price.CurrencyCode" class="d-none"></span> 118 119 120 @if (showPricesWithVat == "false" && !neverShowVat) 121 { 122 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 123 { 124 <span itemprop="price" content="" class="d-none"></span> 125 <span class="text-decoration-line-through js-text-decoration-line-through opacity-75 me-3 text-price js-text-price d-none" data-show-if="LiveProductInfo.product.Price.Price != LiveProductInfo.product.PriceBeforeDiscount.Price"></span> 126 } 127 else 128 { 129 string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceWithoutVatFormatted : product.PriceBeforeDiscount.PriceWithoutVatFormatted; 130 131 <span itemprop="price" content="@product.Price.PriceWithoutVat.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)" class="d-none"></span> 132 if (product.Price.Price != product.PriceBeforeDiscount.Price) 133 { 134 <span class="text-decoration-line-through opacity-75 @order">@beforePrice</span> 135 } 136 } 137 } 138 else 139 { 140 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 141 { 142 <span itemprop="price" content="" class="d-none"></span> 143 <span class="text-decoration-line-through js-text-decoration-line-through opacity-75 me-3 text-price js-text-price d-none" data-show-if="LiveProductInfo.product.Price.Price != LiveProductInfo.product.PriceBeforeDiscount.Price"></span> 144 } 145 else 146 { 147 string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceFormatted : product.PriceBeforeDiscount.PriceFormatted; 148 149 <span itemprop="price" content="@product.Price.Price.ToString("0.00", System.Globalization.CultureInfo.InvariantCulture)" class="d-none"></span> 150 151 if (product.Price.Price != product.PriceBeforeDiscount.Price) 152 { 153 <span class="text-decoration-line-through opacity-75 @order"> 154 <span class="text-price">@beforePrice</span> 155 </span> 156 } 157 } 158 } 159 160 @if (showPricesWithVat == "false" && !neverShowVat) 161 { 162 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 163 { 164 <span class="text-price js-text-price"> 165 <span class="spinner-border" role="status"></span> 166 </span> 167 } 168 else 169 { 170 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceWithoutVatFormatted : product.Price.PriceWithoutVatFormatted; 171 172 if (product?.VariantInfo?.VariantInfo != null) 173 { 174 priceMin = product?.VariantInfo?.PriceMin?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithoutVatFormatted : ""; 175 priceMax = product?.VariantInfo?.PriceMax?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithoutVatFormatted : ""; 176 } 177 if (priceMin != priceMax) 178 { 179 price = priceMin + " - " + priceMax; 180 } 181 <span class="@theme @contentPadding"> 182 <span class="text-price">@price</span> 183 </span> 184 } 185 } 186 else 187 { 188 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 189 { 190 <span class="text-price js-text-price"> 191 <span class="spinner-border" role="status"></span> 192 </span> 193 } 194 else 195 { 196 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceFormatted : product.Price.PriceFormatted; 197 198 if (product?.VariantInfo?.VariantInfo != null) 199 { 200 priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted != null ? product.VariantInfo.PriceMin.PriceFormatted : ""; 201 priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted != null ? product.VariantInfo.PriceMax.PriceFormatted : ""; 202 } 203 if (priceMin != priceMax) 204 { 205 price = priceMin + " - " + priceMax; 206 } 207 <span class="@theme @contentPadding"> 208 <span class="text-price">@price</span> 209 </span> 210 } 211 } 212 213 @* Stock state for Schema.org, start *@ 214 @{ 215 Uri url = Dynamicweb.Context.Current.Request.Url; 216 } 217 218 <link itemprop="url" href="@url"> 219 220 @{ 221 bool IsNeverOutOfStock = product.NeverOutOfstock; 222 } 223 224 @if (IsNeverOutOfStock) 225 { 226 <span itemprop="availability" class="d-none">@Translate("Available in stock")</span> 227 } 228 else 229 { 230 if (product.StockLevel > 0) 231 { 232 <span itemprop="availability" class="d-none">InStock</span> 233 } 234 else 235 { 236 <span itemprop="availability" class="d-none">OutOfStock</span> 237 } 238 } 239 @* Stock state for Schema.org, stop *@ 240 } 241 242 </div> 243 244 @if (showPricesWithVat == "false" && !neverShowVat) 245 { 246 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 247 { 248 <small class="opacity-85 fst-normal js-text-price-with-vat d-none" data-suffix="@Translate("Incl. Tax")"></small> 249 } 250 else 251 { 252 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceWithVatFormatted : product.Price.PriceWithVatFormatted; 253 254 if (product?.VariantInfo?.VariantInfo != null) 255 { 256 priceMin = product?.VariantInfo?.PriceMin?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithVatFormatted : ""; 257 priceMax = product?.VariantInfo?.PriceMax?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithVatFormatted : ""; 258 } 259 if (priceMin != priceMax) 260 { 261 price = priceMin + " - " + priceMax; 262 } 263 <small class="opacity-85 fst-normal">@price @Translate("Incl. Tax")</small> 264 } 265 } 266 </div> 267 } 268 269 } 270 else if (Pageview.IsVisualEditorMode) 271 { 272 <div class="alert alert-dark m-0" role="alert"> 273 <span>@Translate("No products available")</span> 274 </div> 275 } 276
1292 In stock
Error executing template "/Designs/Swift/Paragraph/Custom_Swift_ProductAddToQuote.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.Ecommerce.DynamicwebLiveIntegration_ZB.Products.ProductPriceProvider.PreparePrices(PriceContext context, IEnumerable`1 selections)
   at Dynamicweb.Ecommerce.Prices.PriceManager.PreparePrices(PriceContext context, IEnumerable`1 selections)
   at Dynamicweb.Ecommerce.Prices.PriceManager.PreparePrices(PriceContext context, IEnumerable`1 products, Int64 stockLocationId)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.PreparePrices(PriceContext context, Boolean& pricesHasBeenPrepared, Object lock, IList`1 products, Int64 stockLocationId)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.CreateView(VariantInfoViewModelSettings settings, Product product, Dictionary`2 variants, Lazy`1 details, IList`1 products, Boolean& pricesHasBeenPrepared, Boolean& variantPricesHasBeenPrepared, Object lock)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass15_1.<BulkCreateView>b__6()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
   at System.Lazy`1.ExecutionAndPublication(LazyHelper executionAndPublication, Boolean useDefaultConstructor)
   at System.Lazy`1.CreateValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_d7c74fcb9ee04b108a41185a9d630c37.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   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.Core.Encoders 4 @using System.Globalization 5 6 @functions { 7 string DoubleToString(double? value) 8 { 9 if (value.HasValue) 10 { 11 return value.Value.ToString(CultureInfo.InvariantCulture); 12 } 13 return null; 14 } 15 } 16 17 @{ 18 ProductViewModel product = null; 19 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 20 { 21 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 22 } 23 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 24 { 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 28 if (productList?.Products is object) 29 { 30 product = productList.Products[0]; 31 } 32 } 33 34 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 35 bool anonymousUser = Pageview.User == null; 36 bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsWebServiceConnectionAvailable"]); 37 bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHideAddToCart") && isErpConnectionDown; 38 hideAddToCart = Pageview.IsVisualEditorMode ? false : hideAddToCart; 39 } 40 41 @if (product is object && !hideAddToCart) 42 { 43 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 44 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 45 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 46 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 47 48 bool favoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowAddToFavorites")) ? Model.Item.GetBoolean("ShowAddToFavorites") : false; 49 bool quantitySelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowQuantitySelector")) ? Model.Item.GetBoolean("ShowQuantitySelector") : false; 50 bool unitsSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowUnitsSelector")) ? Model.Item.GetBoolean("ShowUnitsSelector") : false; 51 bool hideInventory = !string.IsNullOrEmpty(Model.Item.GetString("HideInventory")) ? Model.Item.GetBoolean("HideInventory") : false; 52 bool hideStockState = !string.IsNullOrEmpty(Model.Item.GetString("HideStockState")) ? Model.Item.GetBoolean("HideStockState") : false; 53 54 string buttonSize = Model.Item.GetRawValueString("ButtonSize", "regular"); 55 string inputSize = string.Empty; 56 57 switch (buttonSize) 58 { 59 case "small": 60 inputSize = " input-group-sm"; 61 buttonSize = " btn-sm"; 62 break; 63 case "regular": 64 buttonSize = string.Empty; 65 break; 66 case "large": 67 inputSize = " input-group-lg"; 68 buttonSize = " btn-lg"; 69 break; 70 } 71 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 whenVariantsExist = Model.Item.GetRawValueString("WhenVariantsExist", "hide"); 80 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 81 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 82 string addToCartIcon = Model.Item.GetRawValueString("Icon", iconPath + "shopping-cart.svg"); 83 string quotePath = Dynamicweb.Context.Current.Server.MapPath("/Files/Templates/Designs/Swift/Assets/icons/document-file.svg"); 84 85 string addToCartLabel = !addToCartIcon.Contains("_none") ? $"<span class=\"icon-2 cus-quote__icon\">{ReadFile(quotePath)}</span>" : ""; 86 addToCartLabel += !addToCartIcon.Contains("_none") && !Model.Item.GetBoolean("HideButtonText") ? " " : ""; 87 addToCartLabel += !Model.Item.GetBoolean("HideButtonText") ? $"<span class=\"d-none d-md-inline\">{Translate("Add to Quote")}</span><span class=\"d-inline d-md-none\">{Translate("QUOTE")}</span>" : ""; 88 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 89 90 bool userHasPendingQuote = Dynamicweb.Ecommerce.Common.Context.Cart != null && Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote; 91 92 if (product.VariantInfo.VariantInfo == null || whenVariantsExist == "disable") 93 { 94 string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : product.DefaultUnitId; 95 if (string.IsNullOrEmpty(unitId) && product?.UnitOptions != null) 96 { 97 if (product.UnitOptions.FirstOrDefault<UnitOptionViewModel>() != null) 98 { 99 unitId = product.UnitOptions.FirstOrDefault<UnitOptionViewModel>().Id; 100 } 101 } 102 103 double? stepQty = product.PurchaseQuantityStep > 0 ? product.PurchaseQuantityStep : 1; 104 double? minQty = product.PurchaseMinimumQuantity > 0 ? product.PurchaseMinimumQuantity : 1; 105 double? valueQty = minQty > stepQty ? minQty : stepQty; 106 string disableAddToCart = null; 107 double? maxQty = null; 108 109 if (product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock && !product.NeverOutOfstock) 110 { 111 disableAddToCart = (product.StockLevel <= 0) || (!product.NeverOutOfstock && isLazyLoadingForProductInfoEnabled) ? "disabled" : disableAddToCart; 112 maxQty = product.StockLevel; 113 } 114 115 disableAddToCart = whenVariantsExist == "disable" && product.VariantInfo.VariantInfo != null && string.IsNullOrEmpty(product.VariantId) ? "disabled" : disableAddToCart; 116 disableAddToCart = product.Discontinued ? "disabled" : disableAddToCart; 117 var callforprice = product.ProductFields.Values.FirstOrDefault(x => x.SystemName == "Call_for_Price")?.Value; 118 string callforpricestr = ""; 119 if (callforprice != null) 120 { 121 if (callforprice.GetType() == typeof(System.Collections.Generic.List<FieldOptionValueViewModel>)) 122 { 123 var callpriceopt = callforprice as System.Collections.Generic.List<FieldOptionValueViewModel>; 124 foreach (FieldOptionValueViewModel opt in callpriceopt) 125 { 126 callforpricestr = opt.Value.ToString(); 127 } 128 } 129 else 130 { 131 callforpricestr = callforprice.ToString(); 132 } 133 } 134 135 if (callforpricestr != "Yes") 136 { 137 if (maxQty > 0) 138 { 139 if (unitsSelector && product.UnitOptions.Count > 0) 140 { 141 <form method="post" action="/Default.aspx?ID=@(Pageview.Page.ID)&ProductId=@product.Id" id="UnitSelectorForm_@(product.Id)_@(product.VariantId.Replace(".", "_"))_@Model.ID"> 142 <input type="hidden" name="redirect" value="false"> 143 <input type="hidden" name="VariantID" value="@product.VariantId"> 144 <input type="hidden" name="UnitID" class="js-unit-id" value="@unitId"> 145 </form> 146 } 147 148 <div class="d-flex @horizontalAlign @fullWidth js-input-group item_@Model.Item.SystemName.ToLower()"> 149 @* @if (!anonymousUser && favoritesSelector) 150 { 151 @RenderPartial("Components/ToggleFavorite.cshtml", product) 152 } 153 154 <form method="post" action="@url" class="@fullWidth" style="z-index: 1"> 155 <input type="hidden" name="redirect" value="false"> 156 <input type="hidden" name="ProductId" value="@product.Id"> 157 <input type="hidden" name="ProductName" value="@HtmlEncoder.HtmlEncode(product.Name)"> 158 <input type="hidden" name="ProductVariantName" value="@product.VariantName"> 159 <input type="hidden" name="ProductCurrency" value="@Dynamicweb.Ecommerce.Common.Context.Currency.Code"> 160 <input type="hidden" name="ProductPrice" value="@product.Price.ToStringInvariant()"> 161 <input type="hidden" name="ProductDiscount" value="@product.Discount.ToStringInvariant()"> 162 <input type="hidden" name="ProductReferer" value="component_ProductAddToCart"> 163 <input type="hidden" name="cartcmd" value="add"> 164 <input type="submit" class="d-none" onclick="event.preventDefault(); swift.Cart.Update(event)"> <!-- Fix for enterKey should not redirect to minicart page --> 165 166 @if (!string.IsNullOrEmpty(product.VariantId)) 167 { 168 <input type="hidden" name="VariantId" value="@product.VariantId"> 169 } 170 171 <template class="js-step-quantity-warning"> 172 <div class="modal-header"> 173 <h1 class="modal-title fs-5">@Translate("The quantity is not valid")</h1> 174 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 175 </div> 176 <div class="modal-body"> 177 @Translate("Please select a quantity that is dividable by") @stepQty 178 </div> 179 </template> 180 181 182 <template class="js-min-quantity-warning"> 183 <div class="modal-header"> 184 <h1 class="modal-title fs-5">@Translate("The product could not be added to the cart")</h1> 185 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 186 </div> 187 <div class="modal-body"> 188 @Translate("The quantity is not valid. You must buy at least") @product.PurchaseMinimumQuantity 189 </div> 190 </template> 191 192 <template class="js-value-missing-warning"> 193 <div class="modal-header"> 194 <h1 class="modal-title fs-5">@Translate("No amount specified")</h1> 195 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 196 </div> 197 <div class="modal-body"> 198 @Translate("Specify an amount to add to the cart") 199 </div> 200 </template> 201 202 203 @if (userHasPendingQuote) 204 { 205 <input type="hidden" name="PendingQuote" value="true"> 206 207 <template class="js-pending-quote-notice"> 208 <div class="modal-header"> 209 <h1 class="modal-title fs-5">@Translate("Pending Quote")</h1> 210 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 211 </div> 212 <div class="modal-body"> 213 @Translate("You need to complete your current quote or empty the cart before adding this product to cart.") 214 </div> 215 </template> 216 } 217 218 @if (quantitySelector || (!anonymousUser && product.VariantInfo.VariantInfo != null) || (!anonymousUser && favoritesSelector)) 219 { 220 <input type="hidden" id="Unit_@(product.Id)_@product.VariantId.Replace(".", "_")" name="UnitID" value="@unitId" /> 221 } 222 223 <div class="d-flex flex-row w-100"> 224 @if (!quantitySelector) 225 { 226 <input id="Quantity_@(product.Id)_@product.VariantId.Replace(".", "_")" class="swift_quantity_field cus-plist__qtybox" name="Quantity" value="@valueQty" type="hidden" @disableAddToCart> 227 } 228 229 @if (unitsSelector && product.UnitOptions.Count > 0) 230 { 231 string selectedUnitName = !string.IsNullOrEmpty(unitId) && product?.UnitOptions != null ? unitId : product.UnitOptions.FirstOrDefault<UnitOptionViewModel>().Name; 232 233 foreach (var unitOption in product.UnitOptions) 234 { 235 if (unitOption.Id == unitId) 236 { 237 selectedUnitName = unitOption.Name; 238 } 239 } 240 241 <div class="d-flex flex-column gap-2 w-100"> 242 <div class="input-group input-primary-button-group flex-nowrap@(inputSize)"> 243 244 @if (quantitySelector) 245 { 246 <input id="Quantity_@(product.Id)_@product.VariantId.Replace(".", "_")" name="Quantity" value="@DoubleToString(valueQty)" step="@DoubleToString(stepQty)" min="@DoubleToString(minQty)" max="@DoubleToString(maxQty)" class="form-control cus-plist__qtybox swift_quantity-field" style="min-width: 60px; max-width: 100px; z-index: 1" type="number" @disableAddToCart> 247 } 248 249 <button class="btn btn-secondary @flexFill dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> 250 @selectedUnitName 251 </button> 252 253 <ul class="dropdown-menu swift_unit-field"> 254 @foreach (var unitOption in product.UnitOptions) 255 { 256 var selectedUnit = unitOption.Id == unitId ? "selected" : ""; 257 258 <li> 259 <button type="button" class="btn dropdown-item" data-value="@unitOption.Id" onclick="document.querySelector('#UnitSelectorForm_@(product.Id)_@(product.VariantId.Replace(".", "_"))_@Model.ID').querySelector('.js-unit-id').value = this.getAttribute('data-value'); 260 document.querySelector('#Unit_@(product.Id)_@product.VariantId.Replace(".", "_")').value = this.getAttribute('data-value'); 261 swift.PageUpdater.Update(document.querySelector('#UnitSelectorForm_@(product.Id)_@(product.VariantId.Replace(".", "_"))_@Model.ID'))"> 262 <span>@unitOption.Name</span> 263 <span> 264 @if (unitOption.StockLevel > 0 || unitOption.NeverOutOfStock) 265 { 266 if (!Model.Item.GetBoolean("HideInventory") && !unitOption.NeverOutOfStock) 267 { 268 <span class="small text-success">@unitOption.StockLevel @Translate("In stock")</span> 269 } 270 else 271 { 272 <span class="small text-success">@Translate("In stock")</span> 273 } 274 } 275 else 276 { 277 <span class="small text-danger">@Translate("Out of Stock")</span> 278 } 279 </span> 280 </button> 281 </li> 282 } 283 </ul> 284 </div> 285 <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-secondary cus-prodtlquote__btn @(buttonSize) js-add-to-cart-button" style="white-space: nowrap" @disableAddToCart title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)_@Pageview.CurrentParagraph.ID"> 286 @if (!Model.Item.GetBoolean("HideButtonText")) 287 { 288 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 289 @addToCartLabel 290 </span> 291 } 292 else 293 { 294 @addToCartLabel 295 } 296 </button> 297 </div> 298 } 299 else 300 { 301 <div class="input-group input-primary-button-group flex-nowrap@(inputSize)"> 302 @if (quantitySelector) 303 { 304 <input id="Quantity_@(product.Id)_@product.VariantId.Replace(".", "_")" name="Quantity" value="@DoubleToString(valueQty)" step="@DoubleToString(stepQty)" min="@DoubleToString(minQty)" max="@DoubleToString(maxQty)" class="form-control cus-plist__qtybox swift_quantity-field" style="min-width: 60px; max-width: 100px; z-index: 1" type="number" @disableAddToCart> 305 } 306 307 <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-secondary cus-prodtlquote__btn @(buttonSize) @flexFill js-add-to-cart-button" style="white-space: nowrap" @disableAddToCart title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)_@Pageview.CurrentParagraph.ID"> 308 @if (!Model.Item.GetBoolean("HideButtonText")) 309 { 310 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 311 @addToCartLabel 312 </span> 313 } 314 else 315 { 316 @addToCartLabel 317 } 318 </button> 319 </div> 320 } 321 </div> 322 </form> *@ 323 </div> 324 } 325 } 326 327 } 328 else if (whenVariantsExist == "modal") 329 { 330 string ButtonShape = Model.Item.GetRawValueString("VariantButtonShape", "square"); 331 string buttonAspectRatio = Model.Item.GetRawValueString("VariantImageAspectRatio", "56%"); 332 333 string buttonText = Translate("Select"); 334 string variantId = !string.IsNullOrWhiteSpace(product.VariantId) ? product.VariantId : product.DefaultVariantId; 335 336 string variantSelectorServicePageId = !string.IsNullOrEmpty(Model.Item.GetString("VariantSelectorServicePageId")) ? Model.Item.GetLink("VariantSelectorServicePageId").PageId.ToString() : ""; 337 variantSelectorServicePageId = variantSelectorServicePageId != "" ? variantSelectorServicePageId : GetPageIdByNavigationTag("VariantSelectorService").ToString(); 338 339 <div class="d-flex @horizontalAlign w-100 item_@Model.Item.SystemName.ToLower()"> 340 @if (!anonymousUser && favoritesSelector) 341 { 342 @RenderPartial("Components/ToggleFavorite.cshtml", product) 343 } 344 <form action="/Default.aspx?ID=@variantSelectorServicePageId" data-response-target-element="DynamicModalContent" data-preloader="inline" style="z-index: 1" class="@fullWidth"> 345 <input type="hidden" name="ProductID" value="@product.Id"> 346 <input type="hidden" name="VariantID" value="@variantId"> 347 <input type="hidden" name="QuantitySelector" value="@quantitySelector.ToString()"> 348 <input type="hidden" name="HideInventory" value="@hideInventory.ToString()"> 349 <input type="hidden" name="HideStockState" value="@hideStockState.ToString()"> 350 <input type="hidden" name="ButtonLayout" value="@ButtonShape"> 351 <input type="hidden" name="ButtonAspectRatio" value="@buttonAspectRatio"> 352 <input type="hidden" name="VariantSelectorServicePage" value="@variantSelectorServicePageId"> 353 <input type="hidden" name="ViewType" value="ModalContent"> 354 @if (isLazyLoadingForProductInfoEnabled) 355 { 356 @* If lazy loading is enabled, bypass it because we're loading a modal window, so render everything as if it was server-side *@ 357 <input type="hidden" name="getproductinfo" value="true"> 358 } 359 <button type="button" onclick="swift.PageUpdater.Update(event)" class="btn btn-secondary@(buttonSize) @fullWidth" title="@Translate("Select")" data-bs-toggle="modal" data-bs-target="#DynamicModal" id="OpenVariantSelectorModal@(product.Id)_@Pageview.CurrentParagraph.ID">@buttonText</button> 360 </form> 361 </div> 362 } 363 } 364 else if (Pageview.IsVisualEditorMode) 365 { 366 <div class="alert alert-dark m-0">@Translate("No products available")</div> 367 } 368
Error executing template "/Designs/Swift/Paragraph/Custom_Swift_ProductAddToCart.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at Dynamicweb.Ecommerce.DynamicwebLiveIntegration_ZB.Products.ProductPriceProvider.PreparePrices(PriceContext context, IEnumerable`1 selections)
   at Dynamicweb.Ecommerce.Prices.PriceManager.PreparePrices(PriceContext context, IEnumerable`1 selections)
   at Dynamicweb.Ecommerce.Prices.PriceManager.PreparePrices(PriceContext context, IEnumerable`1 products, Int64 stockLocationId)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.PreparePrices(PriceContext context, Boolean& pricesHasBeenPrepared, Object lock, IList`1 products, Int64 stockLocationId)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.CreateView(VariantInfoViewModelSettings settings, Product product, Dictionary`2 variants, Lazy`1 details, IList`1 products, Boolean& pricesHasBeenPrepared, Boolean& variantPricesHasBeenPrepared, Object lock)
   at Dynamicweb.Ecommerce.ProductCatalog.ViewEngine.<>c__DisplayClass15_1.<BulkCreateView>b__6()
   at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
--- End of stack trace from previous location ---
   at System.Lazy`1.CreateValue()
   at CompiledRazorTemplates.Dynamic.RazorEngine_d3640d0f343f463292ebc3ed594f0156.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   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.Core.Encoders 4 @using System.Globalization 5 6 @functions { 7 string DoubleToString(double? value) 8 { 9 if (value.HasValue) 10 { 11 return value.Value.ToString(CultureInfo.InvariantCulture); 12 } 13 return null; 14 } 15 } 16 17 @{ 18 ProductViewModel product = null; 19 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 20 { 21 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 22 } 23 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 24 { 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 28 if (productList?.Products is object) 29 { 30 product = productList.Products[0]; 31 } 32 } 33 34 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 35 bool anonymousUser = Pageview.User == null; 36 bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsWebServiceConnectionAvailable"]); 37 bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHideAddToCart") && isErpConnectionDown; 38 hideAddToCart = Pageview.IsVisualEditorMode ? false : hideAddToCart; 39 } 40 41 @if (product is object && !hideAddToCart) 42 { 43 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 44 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 45 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 46 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 47 48 bool favoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowAddToFavorites")) ? Model.Item.GetBoolean("ShowAddToFavorites") : false; 49 bool quantitySelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowQuantitySelector")) ? Model.Item.GetBoolean("ShowQuantitySelector") : false; 50 bool unitsSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowUnitsSelector")) ? Model.Item.GetBoolean("ShowUnitsSelector") : false; 51 bool hideInventory = !string.IsNullOrEmpty(Model.Item.GetString("HideInventory")) ? Model.Item.GetBoolean("HideInventory") : false; 52 bool hideStockState = !string.IsNullOrEmpty(Model.Item.GetString("HideStockState")) ? Model.Item.GetBoolean("HideStockState") : false; 53 54 string buttonSize = Model.Item.GetRawValueString("ButtonSize", "regular"); 55 string inputSize = string.Empty; 56 57 switch (buttonSize) 58 { 59 case "small": 60 inputSize = " input-group-sm"; 61 buttonSize = " btn-sm"; 62 break; 63 case "regular": 64 buttonSize = string.Empty; 65 break; 66 case "large": 67 inputSize = " input-group-lg"; 68 buttonSize = " btn-lg"; 69 break; 70 } 71 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 whenVariantsExist = Model.Item.GetRawValueString("WhenVariantsExist", "hide"); 80 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 81 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 82 string addToCartIcon = Model.Item.GetRawValueString("Icon", iconPath + "shopping-cart.svg"); 83 string addToCartLabel = !addToCartIcon.Contains("_none") ? $"<span class=\"icon-2\">{ReadFile(addToCartIcon)}</span>" : ""; 84 addToCartLabel += !addToCartIcon.Contains("_none") && !Model.Item.GetBoolean("HideButtonText") ? " " : ""; 85 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("CART")}</span>" : ""; 86 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 87 88 bool userHasPendingQuote = Dynamicweb.Ecommerce.Common.Context.Cart != null && Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote; 89 90 if (product.VariantInfo.VariantInfo == null || whenVariantsExist == "disable") 91 { 92 string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : product.DefaultUnitId; 93 if (string.IsNullOrEmpty(unitId) && product?.UnitOptions != null) 94 { 95 if (product.UnitOptions.FirstOrDefault<UnitOptionViewModel>() != null) 96 { 97 unitId = product.UnitOptions.FirstOrDefault<UnitOptionViewModel>().Id; 98 } 99 } 100 101 double? stepQty = product.PurchaseQuantityStep > 0 ? product.PurchaseQuantityStep : 1; 102 double? minQty = product.PurchaseMinimumQuantity > 0 ? product.PurchaseMinimumQuantity : 1; 103 double? valueQty = minQty > stepQty ? minQty : stepQty; 104 string disableAddToCart = null; 105 double? maxQty = null; 106 107 if (product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock && !product.NeverOutOfstock) 108 { 109 disableAddToCart = (product.StockLevel <= 0) || (!product.NeverOutOfstock && isLazyLoadingForProductInfoEnabled) ? "disabled" : disableAddToCart; 110 maxQty = product.StockLevel; 111 } 112 113 disableAddToCart = whenVariantsExist == "disable" && product.VariantInfo.VariantInfo != null && string.IsNullOrEmpty(product.VariantId) ? "disabled" : disableAddToCart; 114 disableAddToCart = product.Discontinued ? "disabled" : disableAddToCart; 115 var callforprice = product.ProductFields.Values.FirstOrDefault(x => x.SystemName == "Call_for_Price")?.Value; 116 string callforpricestr=""; 117 if (callforprice != null) 118 { 119 if (callforprice.GetType() == typeof(System.Collections.Generic.List<FieldOptionValueViewModel>)) 120 { 121 var callpriceopt=callforprice as System.Collections.Generic.List<FieldOptionValueViewModel>; 122 foreach(FieldOptionValueViewModel opt in callpriceopt) 123 { 124 callforpricestr=opt.Value.ToString(); 125 } 126 } 127 else 128 { 129 callforpricestr=callforprice.ToString(); 130 } 131 } 132 if(callforpricestr != "Yes") 133 { 134 if (maxQty > 0) 135 { 136 if (unitsSelector && product.UnitOptions.Count > 0) 137 { 138 <form method="post" action="/Default.aspx?ID=@(Pageview.Page.ID)&ProductId=@product.Id" id="UnitSelectorForm_@(product.Id)_@(product.VariantId.Replace(".", "_"))_@Model.ID"> 139 <input type="hidden" name="redirect" value="false"> 140 <input type="hidden" name="VariantID" value="@product.VariantId"> 141 <input type="hidden" name="UnitID" class="js-unit-id" value="@unitId"> 142 </form> 143 } 144 145 <div class="d-flex @horizontalAlign @fullWidth js-input-group item_@Model.Item.SystemName.ToLower()"> 146 @if (!anonymousUser && favoritesSelector) 147 { 148 @RenderPartial("Components/ToggleFavorite.cshtml", product) 149 } 150 151 <form method="post" action="@url" class="@fullWidth" style="z-index: 1"> 152 <input type="hidden" name="redirect" value="false"> 153 <input type="hidden" name="ProductId" value="@product.Id"> 154 <input type="hidden" name="ProductName" value="@HtmlEncoder.HtmlEncode(product.Name)"> 155 <input type="hidden" name="ProductVariantName" value="@product.VariantName"> 156 <input type="hidden" name="ProductCurrency" value="@Dynamicweb.Ecommerce.Common.Context.Currency.Code"> 157 <input type="hidden" name="ProductPrice" value="@product.Price.ToStringInvariant()"> 158 <input type="hidden" name="ProductDiscount" value="@product.Discount.ToStringInvariant()"> 159 <input type="hidden" name="ProductReferer" value="component_ProductAddToCart"> 160 <input type="hidden" name="cartcmd" value="add"> 161 <input type="submit" class="d-none" onclick="event.preventDefault(); swift.Cart.Update(event)"> @* Fix for enterKey should not redirect to minicart page *@ 162 163 @if (!string.IsNullOrEmpty(product.VariantId)) 164 { 165 <input type="hidden" name="VariantId" value="@product.VariantId"> 166 } 167 168 <template class="js-step-quantity-warning"> 169 <div class="modal-header"> 170 <h1 class="modal-title fs-5">@Translate("The quantity is not valid")</h1> 171 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 172 </div> 173 <div class="modal-body"> 174 @Translate("Please select a quantity that is dividable by") @stepQty 175 </div> 176 </template> 177 178 179 <template class="js-min-quantity-warning"> 180 <div class="modal-header"> 181 <h1 class="modal-title fs-5">@Translate("The product could not be added to the cart")</h1> 182 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 183 </div> 184 <div class="modal-body"> 185 @Translate("The quantity is not valid. You must buy at least") @product.PurchaseMinimumQuantity 186 </div> 187 </template> 188 189 <template class="js-value-missing-warning"> 190 <div class="modal-header"> 191 <h1 class="modal-title fs-5">@Translate("No amount specified")</h1> 192 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 193 </div> 194 <div class="modal-body"> 195 @Translate("Specify an amount to add to the cart") 196 </div> 197 </template> 198 199 200 @if (userHasPendingQuote) 201 { 202 <input type="hidden" name="PendingQuote" value="true"> 203 204 <template class="js-pending-quote-notice"> 205 <div class="modal-header"> 206 <h1 class="modal-title fs-5">@Translate("Pending Quote")</h1> 207 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 208 </div> 209 <div class="modal-body"> 210 @Translate("You need to complete your current quote or empty the cart before adding this product to cart.") 211 </div> 212 </template> 213 } 214 215 @if (quantitySelector || (!anonymousUser && product.VariantInfo.VariantInfo != null) || (!anonymousUser && favoritesSelector)) 216 { 217 <input type="hidden" id="Unit_@(product.Id)_@product.VariantId.Replace(".", "_")" name="UnitID" value="@unitId" /> 218 } 219 220 <div class="d-flex flex-row w-100"> 221 @if (!quantitySelector) 222 { 223 <input id="Quantity_@(product.Id)_@product.VariantId.Replace(".", "_")" class="swift_quantity_field" name="Quantity" value="@valueQty" type="hidden" @disableAddToCart> 224 } 225 226 @if (unitsSelector && product.UnitOptions.Count > 0) 227 { 228 string selectedUnitName = !string.IsNullOrEmpty(unitId) && product?.UnitOptions != null ? unitId : product.UnitOptions.FirstOrDefault<UnitOptionViewModel>().Name; 229 230 foreach (var unitOption in product.UnitOptions) 231 { 232 if (unitOption.Id == unitId) 233 { 234 selectedUnitName = unitOption.Name; 235 } 236 } 237 238 <div class="d-flex flex-column gap-2 w-100"> 239 <div class="input-group input-primary-button-group flex-nowrap@(inputSize)"> 240 241 @if (quantitySelector) 242 { 243 <input id="Quantity_@(product.Id)_@product.VariantId.Replace(".", "_")" name="Quantity" value="@DoubleToString(valueQty)" step="@DoubleToString(stepQty)" min="@DoubleToString(minQty)" max="@DoubleToString(maxQty)" class="form-control swift_quantity-field" style="min-width: 60px; max-width: 100px; z-index: 1" type="number" @disableAddToCart> 244 } 245 246 <button class="btn btn-secondary @flexFill dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> 247 @selectedUnitName 248 </button> 249 250 <ul class="dropdown-menu swift_unit-field"> 251 @foreach (var unitOption in product.UnitOptions) 252 { 253 var selectedUnit = unitOption.Id == unitId ? "selected" : ""; 254 255 <li> 256 <button type="button" class="btn dropdown-item" data-value="@unitOption.Id" onclick="document.querySelector('#UnitSelectorForm_@(product.Id)_@(product.VariantId.Replace(".", "_"))_@Model.ID').querySelector('.js-unit-id').value = this.getAttribute('data-value'); 257 document.querySelector('#Unit_@(product.Id)_@product.VariantId.Replace(".", "_")').value = this.getAttribute('data-value'); 258 swift.PageUpdater.Update(document.querySelector('#UnitSelectorForm_@(product.Id)_@(product.VariantId.Replace(".", "_"))_@Model.ID'))"> 259 <span>@unitOption.Name</span> 260 <span> 261 @if (unitOption.StockLevel > 0 || unitOption.NeverOutOfStock) 262 { 263 if (!Model.Item.GetBoolean("HideInventory") && !unitOption.NeverOutOfStock) 264 { 265 <span class="small text-success">@unitOption.StockLevel @Translate("In stock")</span> 266 } 267 else 268 { 269 <span class="small text-success">@Translate("In stock")</span> 270 } 271 } 272 else 273 { 274 <span class="small text-danger">@Translate("Out of Stock")</span> 275 } 276 </span> 277 </button> 278 </li> 279 } 280 </ul> 281 </div> 282 <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-primary cus-prodtlquote__btn @(buttonSize) js-add-to-cart-button" style="white-space: nowrap" @disableAddToCart title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)_@Pageview.CurrentParagraph.ID"> 283 @if (!Model.Item.GetBoolean("HideButtonText")) 284 { 285 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 286 @addToCartLabel 287 </span> 288 } 289 else 290 { 291 @addToCartLabel 292 } 293 </button> 294 </div> 295 } 296 else 297 { 298 <div class="input-group input-primary-button-group flex-nowrap@(inputSize)"> 299 @if (quantitySelector) 300 { 301 <input id="Quantity_@(product.Id.Replace(".", "_"))_@product.VariantId.Replace(".", "_")" name="Quantity" value="@DoubleToString(valueQty)" step="@DoubleToString(stepQty)" min="@DoubleToString(minQty)" max="@DoubleToString(maxQty)" class="form-control swift_quantity-field" onkeyup="ValidateProductQtyStock(event,'@maxQty','Quantity_@(product.Id.Replace(".", "_"))_@product.VariantId.Replace(".", "_")');" style="min-width: 120px; max-width: 100px; z-index: 1" type="number" @disableAddToCart> 302 } 303 304 <button type="button" onclick="ValidateProductStock('@maxQty','Quantity_@(product.Id.Replace(".", "_"))_@product.VariantId.Replace(".", "_")'); swift.Cart.Update(event);" class="btn btn-primary cus-prodtlquote__btn cus-prodtladd__btn @(buttonSize) @flexFill js-add-to-cart-button" style="white-space: nowrap" @disableAddToCart title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)_@Pageview.CurrentParagraph.ID"> 305 @if (!Model.Item.GetBoolean("HideButtonText")) 306 { 307 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 308 @addToCartLabel 309 </span> 310 } 311 else 312 { 313 @addToCartLabel 314 } 315 </button> 316 </div> 317 } 318 </div> 319 </form> 320 </div> 321 } 322 } 323 324 } 325 else if (whenVariantsExist == "modal") 326 { 327 string ButtonShape = Model.Item.GetRawValueString("VariantButtonShape", "square"); 328 string buttonAspectRatio = Model.Item.GetRawValueString("VariantImageAspectRatio", "56%"); 329 330 string buttonText = Translate("Select"); 331 string variantId = !string.IsNullOrWhiteSpace(product.VariantId) ? product.VariantId : product.DefaultVariantId; 332 333 string variantSelectorServicePageId = !string.IsNullOrEmpty(Model.Item.GetString("VariantSelectorServicePageId")) ? Model.Item.GetLink("VariantSelectorServicePageId").PageId.ToString() : ""; 334 variantSelectorServicePageId = variantSelectorServicePageId != "" ? variantSelectorServicePageId : GetPageIdByNavigationTag("VariantSelectorService").ToString(); 335 336 <div class="d-flex @horizontalAlign w-100 item_@Model.Item.SystemName.ToLower()"> 337 @if (!anonymousUser && favoritesSelector) 338 { 339 @RenderPartial("Components/ToggleFavorite.cshtml", product) 340 } 341 <form action="/Default.aspx?ID=@variantSelectorServicePageId" data-response-target-element="DynamicModalContent" data-preloader="inline" style="z-index: 1" class="@fullWidth"> 342 <input type="hidden" name="ProductID" value="@product.Id"> 343 <input type="hidden" name="VariantID" value="@variantId"> 344 <input type="hidden" name="QuantitySelector" value="@quantitySelector.ToString()"> 345 <input type="hidden" name="HideInventory" value="@hideInventory.ToString()"> 346 <input type="hidden" name="HideStockState" value="@hideStockState.ToString()"> 347 <input type="hidden" name="ButtonLayout" value="@ButtonShape"> 348 <input type="hidden" name="ButtonAspectRatio" value="@buttonAspectRatio"> 349 <input type="hidden" name="VariantSelectorServicePage" value="@variantSelectorServicePageId"> 350 <input type="hidden" name="ViewType" value="ModalContent"> 351 @if (isLazyLoadingForProductInfoEnabled) 352 { 353 @* If lazy loading is enabled, bypass it because we're loading a modal window, so render everything as if it was server-side *@ 354 <input type="hidden" name="getproductinfo" value="true"> 355 } 356 <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> 357 </form> 358 </div> 359 } 360 361 } 362 else if (Pageview.IsVisualEditorMode) 363 { 364 <div class="alert alert-dark m-0">@Translate("No products available")</div> 365 } 366

Specification

Diameter
Drive
SLOT
Finish
ZINC
Grade/Material
STEEL
Head Style
FLAT
Length
1-1/2
Point Style/Type
TAPPING SCREW
Size
12-14 X 1-1/2
System of Measurement
Inch
Thread Direction
RIGHT HAND
Thread Pitch
14

Customers who bought this item also bought

By clicking 'Accept All' you consent that we may collect information about you for various purposes, including: Statistics and Marketing