Branding Stylesheet || ProductId : 52701122120310 VariantId :

Product detail configuration page

Error executing template "Designs/ColoursAndCoating_generated/Paragraph/ProductDetailWidgetImages.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_39f13d54a6334200b12cf648a5728368.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 Bluedesk.DynamicWeb.ItemTypes; 3 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 5 @using System.Text.RegularExpressions; 6 7 @using Dynamicweb.Content.Items; 8 @using Dynamicweb.Content.Items.Annotations; 9 @using Dynamicweb.Content.Items.Activation; 10 @using Dynamicweb.Content.Items.Editors; 11 @using Dynamicweb.Content.Items.Metadata; 12 @using System.Collections.Generic; 13 @using System.Linq; 14 @using Bluedesk.DynamicWeb.ItemTypes.Extensions; 15 @using Dynamicweb.Ecommerce.ProductCatalog; 16 17 @{ 18 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 19 ProductDetailWidgetImages _data = Dynamicweb.Content.Services.Items.GetItem("ProductDetailWidgetImages", Model.ItemId).ToCodeFirstItemCached<ProductDetailWidgetImages>() ?? new ProductDetailWidgetImages(); 20 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj)Dynamicweb.Context.Current.Session["ProductAndVariants"]; 21 22 ProductViewModel product = new ProductViewModel(); 23 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 24 { 25 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 26 } 27 28 bool displayRibbon = _data.DisplayRibbon; 29 bool displayManufacturerLogo = _data.DisplayManufacturerLogo; 30 31 string videoUrl = ProductAndVariants?.ProductDetail?.YoutubeProductVideo ?? ""; 32 string videoId = ""; 33 string origin = Dynamicweb.Environment.Helpers.LinkHelper.GetHttpDomain(); 34 35 if (!string.IsNullOrWhiteSpace(videoUrl)) 36 { 37 // regex for https://youtu.be/{videoid} 38 Regex regex = new Regex(@".be\/(.[^?]*)"); 39 Match match = regex.Match(videoUrl); 40 if (match.Success) 41 { 42 videoId = match.Groups[1].Value; 43 } 44 45 // regex for https://www.youtube.com/watch?v={videoid} 46 regex = new Regex(@"v=([^&]+)"); 47 match = regex.Match(videoUrl); 48 if (match.Success) 49 { 50 videoId = match.Groups[1].Value; 51 } 52 } 53 54 var prod = Dynamicweb.Ecommerce.Services.Products.GetProductById(product.Id, product.VariantId, Pageview.Area.EcomLanguageId); 55 string defaultImage = Dynamicweb.Ecommerce.Services.ProductImages.GetImagePath(prod); 56 var imageLoop = ProductAndVariants.Images?.AssetImages?.Where(x => x.Value != defaultImage).ToList() ?? new List<Image>(); 57 bool hasMultipleImages = imageLoop.Count > 0; 58 } 59 60 <div id="@paragraphID" class="pdp-paragraph w-full @_data.CssClass"> 61 62 <section class="product-detailpage__images pdp__images-container"> 63 <section class="productimages pdp__images"> 64 65 @if (!string.IsNullOrWhiteSpace(defaultImage)) 66 { 67 string colorCode = "color:" + _data.ColorPaginationArrows.GetColorCode(Pageview.AreaID) ?? "transparent"; 68 string displayThumbnails = _data.DisplayThumbnails == false ? "display: none;" : ""; 69 string productRibbon = ProductAndVariants?.ProductDetail?.ProductRibbon ?? ""; 70 71 <section class="productimages__wrapper"> 72 73 @if (displayManufacturerLogo && ProductAndVariants.Manufacturer != null && ProductAndVariants.Manufacturer.Logo != "") 74 { 75 <img src="/Admin/Public/GetImage.ashx?Image=/Files/@ProductAndVariants.Manufacturer.Logo&Crop=7&Format=webp&Quality=90&Compression=80&width=150" class="manufacturer__logo" alt="Manufacturer" width="150" height="50" /> 76 } 77 78 @if (!string.IsNullOrWhiteSpace(productRibbon) && displayRibbon) 79 { 80 <p class="product-detailpage__ribbon product-detailpage__ribbon--big"><span>@productRibbon</span></p> 81 } 82 83 <div class="swiper product-swiper" thumbs-swiper=".thumbnails-swiper"> 84 <div class="swiper-wrapper"> 85 <div class="swiper-slide"> 86 <img class="w-auto" src="/Admin/Public/GetImage.ashx?Image=@defaultImage&Format=webp&Quality=99&width=800&height=800" alt="@product.Name" height="800" width="800" /> 87 </div> 88 89 @if(hasMultipleImages) 90 { 91 foreach (Image Image in imageLoop) 92 { 93 <div class="swiper-slide"> 94 <img class="w-auto" src="/Admin/Public/GetImage.ashx?Image=@Image.Value&Format=webp&Quality=99&width=800&height=800" alt="@product.Name" /> 95 </div> 96 } 97 } 98 99 @if (!string.IsNullOrWhiteSpace(videoId)) 100 { 101 <div class="swiper-slide"> 102 <div> 103 <lite-youtube videoid="@videoId" params="controls=1&loop=0&playlist=@videoId&playsinline=1&modestbranding=1&mute=0&rel=0&enablejsapi=1&origin=@origin&disablekb=0"></lite-youtube> 104 </div> 105 </div> 106 } 107 </div> 108 109 @if (_data.DisplayPaginationDots) 110 { 111 <div class="swiper-pagination"></div> 112 } 113 114 @if (_data.DisplayImageArrows) 115 { 116 <div class="swiper-button-prev" style="@colorCode"></div> 117 <div class="swiper-button-next" style="@colorCode"></div> 118 } 119 </div> 120 121 </section> 122 123 if (_data.ThumbnailQuantity == 0) 124 { 125 _data.ThumbnailQuantity = 3; 126 } 127 128 if(hasMultipleImages || !string.IsNullOrWhiteSpace(videoId)) 129 { 130 <div class="swiper thumbnails-swiper" style="@displayThumbnails" data-previewnumber="@_data.ThumbnailQuantity"> 131 <div class="swiper-wrapper"> 132 @if (_data.ThumbnailWidth == 0) 133 { 134 _data.ThumbnailWidth = 200; 135 } 136 @if (_data.ThumbnailHeight == 0) 137 { 138 _data.ThumbnailHeight = 200; 139 } 140 141 <div class="swiper-slide"> 142 <img class="product-image" src="/Admin/Public/GetImage.ashx?Image=@defaultImage&Format=webp&Quality=99&width=@_data.ThumbnailWidth&height=@_data.ThumbnailHeight" alt="@product.Name" height="@_data.ThumbnailHeight" width="@_data.ThumbnailWidth" /> 143 </div> 144 145 146 @if(hasMultipleImages) 147 { 148 foreach (Image Thumb in imageLoop) 149 { 150 <div class="swiper-slide"> 151 <img class="product-image" src="/Admin/Public/GetImage.ashx?Image=@Thumb.Value&Crop=7&Format=webp&Quality=90&Compression=80&width=@_data.ThumbnailWidth&height=@_data.ThumbnailHeight" alt="Thumbnail @product.Name" width="@_data.ThumbnailWidth" height="@_data.ThumbnailHeight" /> 152 </div> 153 } 154 } 155 156 @if (!string.IsNullOrWhiteSpace(videoId)) 157 { 158 string thumbnailWidth = "width:" + _data.ThumbnailWidth + "px;"; 159 string thumbnailHeight = "height:" + _data.ThumbnailHeight + "px;"; 160 string iconPositionWidth = "left:" + (_data.ThumbnailWidth / 2 - 12).ToString() + "px;"; 161 string iconPositionHeight = "top:" + (_data.ThumbnailHeight / 2 - 12).ToString() + "px;"; 162 163 <div class="swiper-slide"> 164 <div class="productimages__thumbnail productimages__thumbnail--video" style="@thumbnailWidth @thumbnailHeight"> 165 <img class="h-full" src="https://i.ytimg.com/vi_webp/@videoId/hqdefault.webp" alt="Video preview @ProductAndVariants.ProductInfo.Name" /> 166 <span class="video-icon" style="@iconPositionWidth @iconPositionHeight"> 167 <i class="fas fa-play"></i> 168 </span> 169 </div> 170 </div> 171 } 172 173 </div> 174 175 @if (_data.DisplayThumbnailArrows) 176 { 177 <div class="swiper-button-prev" style="@colorCode"></div> 178 <div class="swiper-button-next" style="@colorCode"></div> 179 } 180 </div> 181 } 182 } 183 </section> 184 </section> 185 </div> 186 187
Error executing template "Designs/ColoursAndCoating_generated/Paragraph/ProductDetailWidgetPrice.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_3300d843cff442ad9ccbf0eed74a3323.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.Prices; 3 @using Dynamicweb.Ecommerce.ProductCatalog; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 5 @using Bluedesk.DynamicWeb.ItemTypes.Settings.Configuration; 6 @using Bluedesk.DynamicWeb.ItemTypes; 7 @{ 8 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 9 ProductDetailWidgetPrice _data = Dynamicweb.Content.Services.Items.GetItem("ProductDetailWidgetPrice", Model.ItemId).ToCodeFirstItemCached<ProductDetailWidgetPrice>() ?? new ProductDetailWidgetPrice(); 10 11 var master_configuration = Dynamicweb.Content.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "MasterConfiguration"); 12 MasterConfig mc = master_configuration.Item.ToCodeFirstItemCached<MasterConfig>(); 13 EcomConfig EcommerceConfiguration = mc.EcomConfiguration; 14 15 ProductViewModel product = new ProductViewModel(); 16 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 17 { 18 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 19 } 20 21 bool WithVATBool = Pageview.Area.EcomPricesWithVat == "True"; 22 bool pricesWithoutVatForUsers = EcommerceConfiguration.ShowPricesWithoutVatForUsers; 23 bool pricesWithoutVatForValidVat = EcommerceConfiguration.ShowPricesWithoutVatWhenValidVatNumber; 24 if(pricesWithoutVatForUsers && !pricesWithoutVatForValidVat && Pageview.User != null) { 25 WithVATBool = false; 26 } 27 if(pricesWithoutVatForValidVat && Pageview.User != null && !string.IsNullOrWhiteSpace(Pageview.User.VatRegNumber)) { 28 WithVATBool = false; 29 } 30 31 bool hidePricesForGuests = EcommerceConfiguration.HidePricesForGuests; 32 bool hideZeroPrices = EcommerceConfiguration.HideZeroPrices; 33 bool displayPrice = hidePricesForGuests ? Pageview.User != null : true; 34 bool pricezero = product.Price.Price <= 0; 35 36 bool displayProductPrice = displayPrice; 37 if (hideZeroPrices && pricezero) 38 { 39 displayProductPrice = false; 40 } 41 42 string ProductdetailPriceSuffixWithVAT = Translate("Productdetail.Price.Suffix.WithVAT", "Incl. VAT"); 43 string ProductdetailPriceSuffixWithoutVAT = Translate("Productdetail.Price.Suffix.WithoutVAT", "Excl. VAT"); 44 string ProductdetailPriceSuffix = WithVATBool ? ProductdetailPriceSuffixWithVAT : ProductdetailPriceSuffixWithoutVAT; 45 46 var gtmValue = WithVATBool ? product.Price.PriceWithVat : product.Price.PriceWithoutVat; 47 var priceFormatted = WithVATBool ? product.Price.PriceWithVatFormatted : product.Price.PriceWithoutVatFormatted; 48 var priceBeforeDiscount = WithVATBool ? product.PriceBeforeDiscount.PriceWithVat : product.PriceBeforeDiscount.PriceWithoutVat; 49 var priceBeforeDiscountFormatted = WithVATBool ? product.PriceBeforeDiscount.PriceWithVatFormatted : product.PriceBeforeDiscount.PriceWithoutVatFormatted; 50 var priceTotalDiscount = WithVATBool ? product.Discount.PriceWithVat : product.Discount.PriceWithoutVat; 51 var priceTotalDiscountFormatted = WithVATBool ? product.Discount.PriceWithVatFormatted : product.Discount.PriceWithoutVatFormatted; 52 double discountPercentage = Math.Round(((priceTotalDiscount / priceBeforeDiscount) * -100)); 53 bool hasDiscount = product.Discount.Price > 0; 54 55 string informativePrice = WithVATBool ? product.PriceInformative.PriceWithVatFormatted : product.PriceInformative.PriceWithoutVatFormatted; 56 if (EcommerceConfiguration.UseInformativePriceAsFromPrice && !string.IsNullOrWhiteSpace(informativePrice)) 57 { 58 var currency = Dynamicweb.Ecommerce.Common.Context.Currency; 59 double informativePriceValue = WithVATBool ? product.PriceInformative.PriceWithVat : product.PriceInformative.PriceWithoutVat; 60 hasDiscount = gtmValue < informativePriceValue; 61 if (hasDiscount) 62 { 63 priceBeforeDiscountFormatted = informativePrice; 64 discountPercentage = Math.Round((((gtmValue - informativePriceValue) / informativePriceValue) * 100)); 65 66 double yourProfitValue = informativePriceValue - gtmValue; 67 priceTotalDiscountFormatted = WithVATBool ? new PriceInfo(currency) { PriceWithVAT = yourProfitValue }.PriceWithVATFormatted : new PriceInfo(currency) { PriceWithoutVAT = yourProfitValue }.PriceWithoutVATFormatted; 68 } 69 } 70 71 string retailPrice = ""; 72 bool displayRetailPrice = EcommerceConfiguration.DisplayRetailPrice; 73 if(EcommerceConfiguration.DisplayRetailPriceForUsers && Pageview.User == null) { 74 displayRetailPrice = false; 75 } 76 if(displayRetailPrice) { 77 string priceFieldName = EcommerceConfiguration.RetailPriceField; 78 if(EcommerceConfiguration.RetailPriceIsDbPrice) { 79 var p = Dynamicweb.Ecommerce.Services.Products.GetProductById(product.Id, product.VariantId, Pageview.Area.EcomLanguageId); 80 PriceContext customerPriceContext = new PriceContext(Dynamicweb.Ecommerce.Common.Context.Currency, Dynamicweb.Ecommerce.Common.Context.Country, null, null, Dynamicweb.Ecommerce.Common.Context.ReverseChargeForVatEnabled, DateTime.Now); 81 var customerPrice = Dynamicweb.Ecommerce.Prices.PriceManager.GetPrice(customerPriceContext, p); 82 if(customerPrice.Price > 0) { 83 retailPrice = WithVATBool ? customerPrice.PriceWithVATFormatted : customerPrice.PriceWithoutVATFormatted; 84 } 85 } else if(!string.IsNullOrWhiteSpace(priceFieldName)) { 86 var currency = Dynamicweb.Ecommerce.Common.Context.Currency; 87 double customerPriceValue = 0.0; 88 if (product.ProductFields.TryGetValue(priceFieldName, out var fieldValue) && fieldValue.Value is double) { 89 customerPriceValue = (double)fieldValue.Value; 90 } 91 if(customerPriceValue > 0) { 92 retailPrice = WithVATBool ? new PriceInfo(currency) { PriceWithVAT = customerPriceValue }.PriceWithVATFormatted : new PriceInfo(currency) { PriceWithoutVAT = customerPriceValue }.PriceWithoutVATFormatted; 93 } 94 } 95 } 96 97 bool isVariant = product.VariantId != ""; 98 int variantCount = product?.VariantInfo?.VariantInfo?.Count ?? 0; 99 bool hasVariants = !isVariant ? variantCount > 0 : false; 100 } 101 102 <div id="@paragraphID" class="pdp-paragraph @_data.CssClass"> 103 @if (displayPrice && displayProductPrice) 104 { 105 <div class="pdp-price__container"> 106 @if(!isVariant && hasVariants) 107 { 108 string minPrice = WithVATBool ? product.VariantInfo.PriceMin.PriceWithVatFormatted : product.VariantInfo.PriceMin.PriceWithoutVatFormatted; 109 string maxPrice = WithVATBool ? product.VariantInfo.PriceMax.PriceWithVatFormatted : product.VariantInfo.PriceMax.PriceWithoutVatFormatted; 110 111 <section class="pdp-price__subcontainer"> 112 @if(minPrice != maxPrice) 113 { 114 <span class="pdp-price">@minPrice - @maxPrice</span> 115 } 116 else 117 { 118 <span class="pdp-price">@minPrice</span> 119 } 120 <span class="pdp-price--suffix">@ProductdetailPriceSuffix</span> 121 </section> 122 } 123 else 124 { 125 if (hasDiscount) 126 { 127 <p class="pdp-price--original">@priceBeforeDiscountFormatted</p> 128 <section class="pdp-price__subcontainer"> 129 <span class="pdp-price">@priceFormatted</span> 130 <span class="pdp-price--suffix">@ProductdetailPriceSuffix</span> 131 <span class="pdp-price__percentage">@discountPercentage%</span> 132 </section> 133 } 134 else 135 { 136 <section class="pdp-price__subcontainer"> 137 <span class="pdp-price">@priceFormatted</span> 138 <span class="pdp-price--suffix">@ProductdetailPriceSuffix</span> 139 </section> 140 } 141 if (!string.IsNullOrWhiteSpace(retailPrice)) 142 { 143 <p class="pdp-price__retail-price"> 144 @String.Format(Translate("ProductBlockTitle.RetailPrice", "Retail price: {0}"), retailPrice) 145 </p> 146 } 147 if (hasDiscount) 148 { 149 <p class="pdp-price__yourprofit"> 150 @Translate("Productdetail.YourProfitLabel", "Your profit:") @priceTotalDiscountFormatted 151 </p> 152 } 153 } 154 </div> 155 156 if(displayPrice && displayProductPrice && product.Prices.Any()) { 157 var priceList = new List<object>(); 158 var loopIndex = 1; 159 160 foreach (var volumePrice in product.Prices) 161 { 162 double volumePriceQuantity = volumePrice.Quantity; 163 164 if (volumePriceQuantity > 1) 165 { 166 var currency = Dynamicweb.Ecommerce.Common.Context.Currency; 167 168 double newVolumePriceVal = WithVATBool ? volumePrice.Price.PriceWithVat : volumePrice.Price.PriceWithoutVat; 169 double productPriceVal = WithVATBool ? product.Price.PriceWithVat : product.Price.PriceWithoutVat; 170 171 double newVolumePrice = Math.Round(newVolumePriceVal * volumePrice.Quantity, 2); 172 string newVolumePriceFormatted = WithVATBool ? new PriceInfo(currency) { PriceWithVAT = newVolumePrice }.PriceWithVATFormatted : new PriceInfo(currency) { PriceWithoutVAT = newVolumePrice }.PriceWithoutVATFormatted; 173 174 double diffVolumePrice = Math.Round((productPriceVal - newVolumePriceVal) * volumePrice.Quantity, 2); 175 string diffVolumePriceFormatted = WithVATBool ? new PriceInfo(currency) { PriceWithVAT = diffVolumePrice }.PriceWithVATFormatted : new PriceInfo(currency) { PriceWithoutVAT = diffVolumePrice }.PriceWithoutVATFormatted; 176 177 var priceObj = new 178 { 179 discountId = loopIndex, 180 newVolumePriceFormatted = newVolumePriceFormatted, 181 diffVolumePriceFormatted = diffVolumePriceFormatted, 182 unitPriceFormatted = WithVATBool ? volumePrice.Price.PriceWithVatFormatted : volumePrice.Price.PriceWithoutVatFormatted, 183 quantity = volumePriceQuantity 184 }; 185 priceList.Add(priceObj); 186 } 187 loopIndex++; 188 } 189 190 string pricesJson = Newtonsoft.Json.JsonConvert.SerializeObject(priceList); 191 192 <div class="app-volumeprices" data-price-list='@pricesJson'></div> 193 } 194 } 195 </div> 196

Voor 17:00 besteld, volgende werkdag geleverd

Error executing template "/Designs/ColoursAndCoating_generated/Paragraph/ProductDetailWidgetStock.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_720b836ef17e4a5e88d44d52378dcf02.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.Ecommerce.Stocks; 4 @using Bluedesk.DynamicWeb.ItemTypes.Settings.Configuration; 5 @using System.Globalization; 6 7 @using Bluedesk.DynamicWeb.ItemTypes; 8 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 9 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 10 11 @{ 12 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 13 ProductDetailWidgetStock _data = Dynamicweb.Content.Services.Items.GetItem("ProductDetailWidgetStock", Model.ItemId).ToCodeFirstItemCached<ProductDetailWidgetStock>() ?? new ProductDetailWidgetStock(); 14 15 var master_configuration = Dynamicweb.Content.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "MasterConfiguration"); 16 MasterConfig mc = master_configuration.Item.ToCodeFirstItemCached<MasterConfig>(); 17 EcomConfig EcommerceConfiguration = mc.EcomConfiguration; 18 19 ProductViewModel product = new ProductViewModel(); 20 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 21 { 22 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 23 } 24 25 bool isVariant = product.VariantId != ""; 26 int variantCount = product?.VariantInfo?.VariantInfo?.Count ?? 0; 27 bool hasVariants = !isVariant ? variantCount > 0 : false; 28 29 bool hideStockForGuests = EcommerceConfiguration.HideStockForGuests; 30 bool enableProductStock = hideStockForGuests ? Pageview.User != null : true; 31 32 double stockAmount = 0; 33 string stock = stockAmount.ToString(stockAmount % 1 == 0 ? "N0" : "N2", CultureInfo.GetCultureInfo(Pageview.Area.CultureInfo.TwoLetterISOLanguageName)) ?? ""; 34 string stockFormat = EcommerceConfiguration.StockFormat; 35 bool inStock = stockAmount > 0 || product.NeverOutOfstock; 36 string stockStateClass = inStock ? "pdp-stockstate--instock" : "pdp-stockstate--outofstock"; 37 38 string productLifecycleStateId = ""; 39 if (product.ProductFields.TryGetValue("ProductLifecycleStateId", out var lifecycleField) && lifecycleField.Value is string lifecycleValue) 40 { 41 productLifecycleStateId = lifecycleValue; 42 } 43 44 string productVerpakkingsHoeveelheid = ""; 45 if (product.ProductFields.TryGetValue("VerpakkingsHoeveelheid", out var quantityField) && quantityField.Value is string quantityValue) 46 { 47 productVerpakkingsHoeveelheid = quantityValue; 48 } 49 50 string productVerkoopEenheid = ""; 51 if (product.ProductFields.TryGetValue("Verkoopeenheid", out var unitField) && unitField.Value is string unitValue) 52 { 53 productVerkoopEenheid = unitValue; 54 } 55 } 56 57 <div id="@paragraphID" class="pdp-paragraph"> 58 @if(enableProductStock && !string.IsNullOrWhiteSpace(stockFormat)) 59 { 60 <div class="pdp-stockstate__wrapper"> 61 <div> 62 @if(stockFormat == "text") { 63 StockLocation stockLocation = Dynamicweb.Ecommerce.Services.StockService.GetStockLocation(Pageview.Area.StockLocationID); 64 var currentProduct = Dynamicweb.Ecommerce.Services.Products.GetProductById(product.Id, "", Pageview.Area.EcomLanguageId); 65 string stockText = Dynamicweb.Ecommerce.Services.StockService.GetStockStatus(product.Id)?.GetText(Pageview.Area.EcomLanguageId); 66 67 if (!string.IsNullOrWhiteSpace(stockText)) 68 { 69 <span class="pdp-stockstate @stockStateClass">@string.Format(stockText, stock)</span> 70 } 71 } 72 else 73 { 74 string translationTag = ""; 75 if(product.NeverOutOfstock) 76 { 77 translationTag = Translate("ProductBlockStockInfo.AmountInStock", "In stock"); 78 } 79 else if(stockAmount == 1) 80 { 81 translationTag = Translate("ProductBlockStockInfo.AmountInStockSingle", "{0} product in stock"); 82 } 83 else if(stockAmount > 1) 84 { 85 translationTag = Translate("ProductBlockStockInfo.AmountInStockMultiple", "{0} products in stock"); 86 } 87 else if(!inStock) 88 { 89 translationTag = Translate("ProductBlockStockInfo.AmountOutOfStock", "Out of stock"); 90 } 91 92 <span class="pdp-stockstate @stockStateClass">@string.Format(translationTag, stock)</span> 93 } 94 @if(!string.IsNullOrWhiteSpace(_data.Suffix)) 95 { 96 <span class="pdp-stockstate__suffix">@_data.Suffix</span> 97 } 98 </div> 99 @if(!string.IsNullOrWhiteSpace(_data.Subline)) 100 { 101 <p class="pdp-stockstate__subline">@_data.Subline</p> 102 } 103 </div> 104 105 } 106 107 @if (productLifecycleStateId == "Service artikel") 108 { 109 if (!string.IsNullOrWhiteSpace(productVerpakkingsHoeveelheid) && !string.IsNullOrWhiteSpace(productVerkoopEenheid) && Pageview.User != null) 110 { 111 <p class="products-module__product-units">@String.Format(Translate("Product.SoldPerUnit", "Verkocht per {0} {1}"), productVerpakkingsHoeveelheid, productVerkoopEenheid)</p> 112 } 113 114 <span data-tippy-content="@Translate("Product.Stock.Disclaimer.Content", "Disclaimer")" class="product-stock__disclaimer"> 115 @Translate("Product.Stock.Disclaimer", "Disclaimer") 116 <i class="fal fa-info-circle"></i> 117 </span> 118 } 119 </div> 120
Error executing template "Designs/ColoursAndCoating_generated/Paragraph/ProductDetailWidgetVariantSelector.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_e9c3f0c70da641768ff63882561439cb.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 3 @using Dynamicweb.Ecommerce.ProductCatalog; 4 @using Dynamicweb.Ecommerce.Variants; 5 @using Newtonsoft.Json; 6 7 @{ 8 int pageId = Pageview.ID; 9 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 10 11 ProductViewModel product = new ProductViewModel(); 12 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 13 { 14 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 15 } 16 17 string variantSelection = product.VariantId.Replace(".", ","); 18 string[] variantSelectionArr = variantSelection.Split(','); 19 20 List<string[]> variantCombinationsIds = new List<string[]>(); 21 List<List<string>> variantGroupsOptionIds = new List<List<string>>(); 22 23 var variantCombinations = Dynamicweb.Ecommerce.Services.VariantCombinations.GetVariantCombinations(product.Id); 24 var variantGroups = Dynamicweb.Ecommerce.Services.VariantGroups.GetVariantGroupsByProductId(product.Id); 25 26 foreach (var combination in variantCombinations) 27 { 28 variantCombinationsIds.Add(combination.VariantId.Split('.')); 29 } 30 string variantCombinationsIdsJson = JsonConvert.SerializeObject(variantCombinationsIds).Replace("\"", "\'"); 31 32 foreach (var variantGroup in variantGroups) 33 { 34 var variantsObject = new List<string>(); 35 foreach (var variantOption in variantGroup.GetAllVariantOptions()) 36 { 37 if (variantCombinationsIds.Any(ids => ids.Contains(variantOption.Id))) 38 { 39 variantsObject.Add(variantOption.Id); 40 } 41 } 42 if (variantsObject.Count > 0) 43 { 44 variantGroupsOptionIds.Add(variantsObject); 45 } 46 } 47 string variantGroupsOptionIdsJson = JsonConvert.SerializeObject(variantGroupsOptionIds).Replace("\"", "\'"); 48 } 49 50 <div id="@paragraphID" class="pdp-paragraph"> 51 @if(variantGroups.Any()) { 52 <div class="product-variants__wrapper pdp-variants"> 53 <div class="js-variants" data-total-variant-groups="@variantGroups.Count" data-combinations="@variantCombinationsIdsJson" data-variants="@variantGroupsOptionIdsJson" data-current-page-variant="@variantSelection" data-variant-selections="@variantSelection" data-page-id="@pageId" data-product-id="@product.Id" data-group-id="@product.PrimaryOrDefaultGroup.Id"> 54 @foreach (var variantGroup in variantGroups) 55 { 56 bool containsImage = variantGroup.GetAllVariantOptions().Any(v => !string.IsNullOrEmpty(v.SmallImage)); 57 bool containsColor = variantGroup.GetAllVariantOptions().Any(v => !string.IsNullOrEmpty(v.Color)); 58 string variantGroupName = variantGroup.GetName(Pageview.Area.EcomLanguageId); 59 string variantGroupId = variantGroup.Id; 60 var variantGroupOptions = variantGroup.GetAllVariantOptions().Where(o => variantCombinationsIds.Any(ids => ids.Contains(o.Id))); 61 62 <div class="product-variants__block product-variants__block--@variantGroupId"> 63 @if (containsImage || containsColor) 64 { 65 if(!string.IsNullOrWhiteSpace(variantGroupName)) 66 { 67 <p class="product-variants__title">@variantGroupName</p> 68 } 69 70 <div class="product-variants__options-wrapper"> 71 @foreach (VariantOption variantOption in variantGroupOptions) 72 { 73 string variantOptionName = Translate(string.Format("VariantOption.{0}.{1}", variantGroupId, variantOption.Id), variantOption.GetName(Pageview.Area.EcomLanguageId)); 74 string selected = variantSelectionArr.Contains(variantOption.Id) ? "product-variants__btn--checked" : ""; 75 76 if (!string.IsNullOrEmpty(variantOption.SmallImage)) 77 { 78 string variantImage = "/Files/" + variantOption.SmallImage; 79 <div data-variant-id="@variantOption.Id" data-variant-group="@variantGroupId" class="js-variant-option product-variants__btn product-variants__btn--image @selected"> 80 <img src="@variantImage" alt="@variantOptionName" title="@variantOptionName" /> 81 </div> 82 } 83 else if (!string.IsNullOrEmpty(variantOption.Color)) 84 { 85 <div data-variant-id="@variantOption.Id" data-variant-group="@variantGroupId" class="js-variant-option product-variants__btn product-variants__btn--color @selected"> 86 <span title="@variantOptionName" style="--variant-color: @variantOption.Color;"></span> 87 </div> 88 } 89 else 90 { 91 <button type="button" data-variant-id="@variantOption.Id" data-variant-group="@variantGroupId" class="js-variant-option product-variants__btn @selected">@variantOptionName</button> 92 } 93 } 94 </div> 95 } 96 else 97 { 98 if(!string.IsNullOrWhiteSpace(variantGroupName)) 99 { 100 <p class="product-variants__title">@variantGroupName</p> 101 } 102 103 <div class="product-variants__dropdown"> 104 <div class="product-variants__dropdown-wrapper"> 105 106 <button class="product-variants__toggle"> 107 <span data-original="@Translate(string.Format("VariantDropdown.Placeholder.{0}", variantGroupName), "Select your option")">@Translate(string.Format("VariantDropdown.Placeholder.{0}", variantGroupName), "Select your option")</span> 108 <i class="fal fa-chevron-down"></i> 109 </button> 110 111 <div class="product-variants__options-wrapper product-variants__options-wrapper--dropdown product-variants__dropdown-options-wrapper"> 112 @foreach (VariantOption variantOption in variantGroupOptions) 113 { 114 string selected = variantSelectionArr.Contains(variantOption.Id) ? "product-variants__btn--checked" : ""; 115 116 <button type="button" data-variant-id="@variantOption.Id" data-variant-group="@variantGroupId" class="js-variant-option product-variants__btn--dropdown @selected"> 117 @Translate(string.Format("VariantOption.{0}.{1}", variantGroupId, variantOption.Id), variantOption.GetName(Pageview.Area.EcomLanguageId)) 118 </button> 119 } 120 </div> 121 </div> 122 </div> 123 } 124 </div> 125 } 126 </div> 127 </div> 128 } 129 </div> 130
Error executing template "Designs/ColoursAndCoating_generated/Paragraph/ProductDetailWidgetAddToCart.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_5c77a4a2731846ababc6d22b29232b93.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 Bluedesk.DynamicWeb.ItemTypes.Settings.Configuration; 4 @using Bluedesk.DynamicWeb.ItemTypes.Configuration; 5 @using Bluedesk.DynamicWeb.ItemTypes; 6 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 7 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 8 9 @{ 10 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 11 ProductDetailWidgetAddToCart _data = Dynamicweb.Content.Services.Items.GetItem("ProductDetailWidgetAddToCart", Model.ItemId).ToCodeFirstItemCached<ProductDetailWidgetAddToCart>() ?? new ProductDetailWidgetAddToCart(); 12 13 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj)Dynamicweb.Context.Current.Session["ProductAndVariants"]; 14 15 var master_configuration = Dynamicweb.Content.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "MasterConfiguration"); 16 MasterConfig mc = master_configuration.Item.ToCodeFirstItemCached<MasterConfig>(); 17 EcomConfig EcommerceConfiguration = mc.EcomConfiguration; 18 19 ProductViewModel product = new ProductViewModel(); 20 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 21 { 22 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 23 } 24 25 bool hideShoppingCartForGuests = EcommerceConfiguration.HideShoppingCartForGuests; 26 bool enableAddToCartForZeroPrices = EcommerceConfiguration.AddToCartAllowZeroPrices; 27 bool enableAddToCartForOutOfStock = EcommerceConfiguration.AddToCartAllowOutOfStock; 28 29 bool enableShoppingCart = hideShoppingCartForGuests && Pageview.User == null ? false : Pageview.Area.Item["ConfigModuleShoppingCart"] != null ? (bool)Pageview.Area.Item["ConfigModuleShoppingCart"] : false; 30 bool enableProductShoppingCart = enableShoppingCart; 31 if (!enableAddToCartForZeroPrices && product.Price.Price <= 0) 32 { 33 enableProductShoppingCart = false; 34 } 35 if (!enableAddToCartForOutOfStock && !(product.StockLevel > 0 || product.NeverOutOfstock)) 36 { 37 enableProductShoppingCart = false; 38 } 39 if(product.Discontinued) 40 { 41 enableProductShoppingCart = false; 42 } 43 44 int QuotePageID = GetPageIdByNavigationTag("QuoteForm"); 45 var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; 46 47 bool isVariant = product.VariantId != ""; 48 int variantCount = product?.VariantInfo?.VariantInfo?.Count ?? 0; 49 bool hasVariants = !isVariant ? variantCount > 0 : false; 50 51 bool showLoginButton = _data.ShowLoginButton; 52 var loginButtonText = _data.LoginButtonText; 53 var loginButtonIcon = _data.LoginButtonIcon; 54 55 bool enableColorPicker = false; 56 if (product.ProductFields.TryGetValue("CompanoCustomUDF_LOA_ITM_ArtikelSoort", out var fieldValue) && fieldValue.Value is string artikelSoort) 57 { 58 enableColorPicker = artikelSoort == "KMA" || artikelSoort == "Maatwerk"; 59 } 60 } 61 62 <div id="@paragraphID" class="pdp-paragraph @_data.CssClass"> 63 @if (!hasVariants) 64 { 65 if (enableShoppingCart && enableProductShoppingCart) 66 { 67 if(enableColorPicker) 68 { 69 <div class="vue-cc-colourpicker" data-product-id="@product.Id"></div> 70 } 71 72 <div class="pdp-add-to-cart pdp-add-to-cart__container"> 73 <add-to-cart class="app-addtocart" 74 data-prodid="@product.Id" 75 data-variantid="@product.VariantId" 76 data-min-quantity="@product.PurchaseMinimumQuantity" 77 data-step="@product.PurchaseQuantityStep" 78 data-list-id="product_detail" 79 data-list-name="Product detail"> 80 </add-to-cart> 81 </div> 82 } 83 else if (!enableShoppingCart && showLoginButton) 84 { 85 ButtonConfiguration btnStyle = _data.LoginButtonConfiguration; 86 string btnStyleClass = btnStyle != null ? $"btn--{btnStyle.Id}" : ""; 87 88 <style> 89 @if (btnStyle != null) 90 { 91 @btnStyle.GetButtonStylesheet() 92 } 93 </style> 94 <a class="btn default-btn @btnStyleClass pdp-login-button topmenu__link--login" href="javascript:;"> 95 @if (!string.IsNullOrWhiteSpace(loginButtonText)) 96 { 97 <span style="color: white;" class="btn__text">@loginButtonText</span> 98 } 99 @if (!string.IsNullOrWhiteSpace(loginButtonIcon)) 100 { 101 <i class="@loginButtonIcon btn__icon"></i> 102 } 103 </a> 104 } 105 } 106 else 107 { 108 if (product.Price.Price <= 0 && !product.Discontinued && !string.IsNullOrWhiteSpace(_data.OffertePageId)) 109 { 110 ButtonConfiguration btnStyle = _data.ButtonConfiguration; 111 string btnStyleClass = btnStyle != null ? $"btn--{btnStyle.Id}" : ""; 112 string btnTarget = "javascript:void(0);"; 113 114 if (!string.IsNullOrWhiteSpace(_data.OffertePageId)) 115 { 116 btnTarget = $"/Default.aspx?ID={_data.OffertePageId}&ProdID={product.Id}"; 117 if (!string.IsNullOrWhiteSpace(product.VariantId)) 118 { 119 btnTarget = $"{btnTarget}&VarID={product.VariantId}"; 120 } 121 } 122 123 <div id="@paragraphID" class="pdp-paragraph @_data.CssClass"> 124 <style> 125 @if (btnStyle != null) 126 { 127 @btnStyle.GetButtonStylesheet() 128 } 129 </style> 130 <div class="pdp-quote-button"> 131 <a href="@btnTarget" class="btn default-btn @btnStyleClass"> 132 <span class="btn__text">@_data.ButtonText</span> 133 <i class="btn__icon @_data.ButtonIcon"></i> 134 </a> 135 </div> 136 </div> 137 } 138 139 if (product.Discontinued && !string.IsNullOrWhiteSpace(product.ReplacementProduct.ProductId)) 140 { 141 ProductViewModelSettings productSetting = new ProductViewModelSettings 142 { 143 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 144 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 145 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 146 ShopId = Pageview.Area.EcomShopId 147 }; 148 ProductViewModel repProd = ViewModelFactory.CreateView(productSetting, product.ReplacementProduct.ProductId, product.ReplacementProduct.VariantId); 149 150 if (repProd != null) 151 { 152 int productDetailPageId = GetPageIdByNavigationTag("ProductOverview"); 153 string productUrl = $"Default.aspx?ID={productDetailPageId}&GroupID={repProd.PrimaryOrDefaultGroup.Id}&ProductID={repProd.Id}"; 154 if (!string.IsNullOrWhiteSpace(repProd.VariantId)) 155 { 156 productUrl = $"{productUrl}?VariantID={repProd.VariantId}"; 157 } 158 159 <div class="pdp-replacement__container"> 160 @if (!string.IsNullOrWhiteSpace(Translate("ProductDetail.ReplacementProd.Intro", ""))) 161 { 162 <p class="pdp-replacement__intro">@string.Format(Translate("ProductDetail.ReplacementProd.Intro", "This product is not available anymore. Please take a look at our selected replacement product."), repProd.Name)</p> 163 } 164 <a href="@productUrl" class="btn default-btn"> 165 <span class="btn__text">@string.Format(Translate("ProductDetail.ReplacementProd.Btn", "View replacement product"), repProd.Name)</span> 166 <i class="btn__icon @buttonIconClass"></i> 167 </a> 168 </div> 169 } 170 } 171 } 172 </div> 173
  • Veilig op rekening kopen
  • Gratis verzending vanaf €150,- exclusief btw
Error executing template "Designs/ColoursAndCoating_generated/Paragraph/ProductDetailWidgetShortDescription.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_039e9366f71a4166a9a2455c7e511361.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 Bluedesk.DynamicWeb.ItemTypes; 3 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 5 @using Dynamicweb.Ecommerce.ProductCatalog; 6 7 @{ 8 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 9 10 ProductDetailWidgetShortDescription _data = Dynamicweb.Content.Services.Items.GetItem("ProductDetailWidgetShortDescription", Model.ItemId).ToCodeFirstItemCached<ProductDetailWidgetShortDescription>() ?? new ProductDetailWidgetShortDescription(); 11 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj) Dynamicweb.Context.Current.Session["ProductAndVariants"]; 12 13 ProductViewModel product = new ProductViewModel(); 14 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 15 { 16 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 17 } 18 19 string readMoreTarget = _data.ButtonTarget; 20 string shortDescription = ProductAndVariants?.ProductInfo?.ShortDescription ?? ""; 21 22 string productInhoud = ""; 23 if (product.ProductFields.TryGetValue("CompanoCustomInhoud", out var fieldValue) && fieldValue.Value is string) 24 { 25 productInhoud = (string)fieldValue.Value; 26 } 27 } 28 29 <div id="@paragraphID" class="pdp-paragraph pdp-paragraph-short-description ProductShortDescription"> 30 @if(!string.IsNullOrWhiteSpace(shortDescription)) 31 { 32 <p>@shortDescription</p> 33 if(!string.IsNullOrWhiteSpace(readMoreTarget)) 34 { 35 <a href="@readMoreTarget" class="btn default-btn" target="_self"> 36 <span class="btn__text">@Translate("Productdetail.Readmore", "Read more")</span> 37 <i class="btn__icon fa-chevron-right"></i> 38 </a> 39 } 40 } 41 42 @if(!string.IsNullOrWhiteSpace(productInhoud)) 43 { 44 <p class="pdp-paragraph-short-description--inhoud"><span>@Translate("ProductFieldLabel.Inhoud", "Inhoud: ")</span>@productInhoud</p> 45 } 46 </div> 47
Error executing template "Designs/ColoursAndCoating_generated/Paragraph/ProductDetailWidgetSidebarTrigger.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_753cb8dfaff94fad86b32f074fbee8ba.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 Bluedesk.DynamicWeb.ItemTypes; 3 @using Bluedesk.DynamicWeb.ItemTypes.Pages; 4 @using Bluedesk.DynamicWeb.ItemTypes.Settings; 5 @using Bluedesk.DynamicWeb.ItemTypes.Configuration; 6 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 7 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 8 @using Dynamicweb.Ecommerce.ProductCatalog; 9 @using System.Text.RegularExpressions; 10 11 @{ 12 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 13 ProductDetailWidgetSidebarTrigger _data = Dynamicweb.Content.Services.Items.GetItem("ProductDetailWidgetSidebarTrigger", Model.ItemId).ToCodeFirstItemCached<ProductDetailWidgetSidebarTrigger>() ?? new ProductDetailWidgetSidebarTrigger(); 14 15 ProductViewModel product = new ProductViewModel(); 16 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 17 { 18 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 19 } 20 21 ButtonConfiguration btnStyle = _data.ButtonConfiguration; 22 string btnStyleClass = btnStyle != null ? $"btn--{btnStyle.Id}" : ""; 23 24 string ERPpropertiesXML = product.ProductFields != null && product.ProductFields.ContainsKey("ERPpropertiesXML") ? product.ProductFields["ERPpropertiesXML"].Value.ToString() : ""; 25 string CATpropertiesXML = product.ProductFields != null && product.ProductFields.ContainsKey("CATpropertiesXML") ? product.ProductFields["CATpropertiesXML"].Value.ToString() : ""; 26 27 List<dynamic> propertiesXML = new List<dynamic>(); 28 29 if (!string.IsNullOrWhiteSpace(ERPpropertiesXML)) 30 { 31 AddSidebarPropertiesFromXML(ERPpropertiesXML, propertiesXML); 32 } 33 if (!string.IsNullOrWhiteSpace(CATpropertiesXML)) 34 { 35 AddSidebarPropertiesFromXML(CATpropertiesXML, propertiesXML); 36 } 37 38 List<dynamic> defaultSpecifications = new List<dynamic>(); 39 foreach (var field in product.ProductFields) 40 { 41 defaultSpecifications.Add(new 42 { 43 id = field.Value.SystemName, 44 label = field.Value.Name, 45 value = field.Value 46 }); 47 } 48 if(!string.IsNullOrWhiteSpace(product.Number)) 49 { 50 defaultSpecifications.Add(new 51 { 52 id = "ProductNumber", 53 label = Translate("SpecificationsList.ProductNumber", "Number"), 54 value = product.Number 55 }); 56 } 57 if(!string.IsNullOrWhiteSpace(product.EAN)) 58 { 59 defaultSpecifications.Add(new 60 { 61 id = "ProductEAN", 62 label = Translate("SpecificationsList.ProductEAN", "EAN"), 63 value = product.EAN 64 }); 65 } 66 if(!string.IsNullOrWhiteSpace(product.Name)) 67 { 68 defaultSpecifications.Add(new 69 { 70 id = "ProductName", 71 label = Translate("SpecificationsList.ProductName", "Name"), 72 value = product.Name 73 }); 74 } 75 defaultSpecifications = defaultSpecifications.OrderBy(d => d.label).ToList(); 76 } 77 78 <div id="@paragraphID" class="pdp-paragraph @_data.CssClass"> 79 <style> 80 @if(btnStyle != null) { 81 @btnStyle.GetButtonStylesheet() 82 } 83 </style> 84 <div class="pdp-sidebar-trigger"> 85 <a href="javascript:void(0);" class="btn default-btn toggle-of-canvas-menu @btnStyleClass" data-offcanvas-target="specifications"> 86 <span class="btn__text" >@_data.ButtonText</span> 87 <i class="btn__icon @_data.ButtonIcon"></i> 88 </a> 89 </div> 90 </div> 91 92 <div class="offcanvas__backdrop" name="specifications"></div> 93 94 <aside class="offcanvas" name="specifications"> 95 <header class="offcanvas__header"> 96 <span class="offcanvas__title">@Translate("OffCanvasMenu.SpecificationsTitle", "Specifications")</span> 97 <button class="offcanvas__close" aria-label="@Translate("OffCanvasMenu.Close", "Close menu")"> 98 <i class="fal fa-times"></i> 99 </button> 100 </header> 101 <div class="offcanvas__body"> 102 103 @if(product != null && defaultSpecifications.Count > 0) 104 { 105 <section class="product-specifications__category"> 106 <button class="product-specifications__header product-specifications__toggle" aria-expanded="true" aria-controls="defaultSpecifications"> 107 <p class="product-specifications__title">@Translate("SpecificationsList.DefaultSpecifications", "Product Details")</p> 108 <i class="fal fa-chevron-down"></i> 109 </button> 110 <ul id="defaultSpecifications" class="product-specifications__list"> 111 @foreach (var spec in defaultSpecifications) 112 { 113 if (!string.IsNullOrWhiteSpace(spec.value.ToString())) 114 { 115 <li class="product-specifications__list-item"> 116 <span class="product-specifications__label">@spec.label</span> 117 <span class="product-specifications__value">@spec.value</span> 118 </li> 119 } 120 } 121 </ul> 122 </section> 123 } 124 125 @if(product != null) 126 { 127 if (propertiesXML.Count > 0) 128 { 129 <section class="product-specifications__category"> 130 <button class="product-specifications__header product-specifications__toggle" aria-expanded="true" aria-controls="propertiesXml"> 131 <p class="product-specifications__title">@Translate("SpecificationsList.PropertiesXML", "Specifications")</p> 132 <i class="fal fa-chevron-down"></i> 133 </button> 134 <ul id="propertiesXml" class="product-specifications__list"> 135 @foreach (var spec in propertiesXML) 136 { 137 <li class="product-specifications__list-item"> 138 <span class="product-specifications__label">@spec.Caption</span> 139 <span class="product-specifications__value">@spec.Value @spec.Unit</span> 140 </li> 141 } 142 </ul> 143 </section> 144 } 145 else if(product.ProductCategories != null) 146 { 147 Regex valueRegex = new Regex(@"\[(.+?)\]", RegexOptions.IgnoreCase); 148 149 foreach(var categorie in product.ProductCategories) 150 { 151 string prodCategoryId = categorie.Value.Id.ToString(); 152 string prodCategoryName = categorie.Value.Name.ToString(); 153 154 if(categorie.Value.Fields.Any(d => !string.IsNullOrWhiteSpace(d.Value.ToString()))) 155 { 156 <section class="product-specifications__category"> 157 <button class="product-specifications__header product-specifications__toggle" aria-expanded="true" aria-controls="@prodCategoryId"> 158 <p class="product-specifications__title">@Translate("SpecificationsList." + prodCategoryName.Replace(" ", ""), prodCategoryName)</p> 159 <i class="fal fa-chevron-down"></i> 160 </button> 161 <ul id="@prodCategoryId" class="product-specifications__list"> 162 @foreach (var categoryField in categorie.Value.Fields) 163 { 164 if (!string.IsNullOrWhiteSpace(categoryField.Value.ToString())) 165 { 166 Match unitMatch = valueRegex.Match(categoryField.Value.Name); 167 string unit = unitMatch.Groups[1].Value; 168 169 <li class="product-specifications__list-item"> 170 <span class="product-specifications__label">@valueRegex.Replace(categoryField.Value.Name, "")</span> 171 <span class="product-specifications__value">@categoryField.Value @unit</span> 172 </li> 173 } 174 } 175 </ul> 176 </section> 177 } 178 } 179 } 180 } 181 182 </div> 183 </aside> 184 185 @functions { 186 public void AddSidebarPropertiesFromXML(string xml, List<dynamic> specifications) 187 { 188 var xmlDoc = new System.Xml.XmlDocument(); 189 xmlDoc.LoadXml(xml); 190 191 foreach (System.Xml.XmlNode fieldNode in xmlDoc.SelectNodes("//Field")) 192 { 193 specifications.Add(new 194 { 195 Id = fieldNode.Attributes["id"]?.InnerText, 196 Caption = fieldNode.SelectSingleNode("Caption")?.InnerText, 197 Value = fieldNode.SelectSingleNode("Value")?.InnerText, 198 Unit = fieldNode.SelectSingleNode("Unit")?.InnerText 199 }); 200 } 201 } 202 } 203

Heeft u hulp nodig?

Heb je een vraag over een bepaald product? Of behoefte aan deskundig advies?


Neem dan contact met onze klantenservice. Onze supporters helpen je graag verder.

 

Supporter van jouw project

We zijn meer dan een verfgroothandel! En dat merk je in ons dienstenpakket. We kijken graag mee, adviseren waar nodig en maken je het altijd zo gemakkelijk mogelijk.