Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetName.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_3dccae04181d434bb0b836ebd4fc5fb2.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetName.cshtml:line 15 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 3 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 5 6 @{ 7 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 8 9 ProductDetailWidgetName _data = Dynamicweb.Services.Items.GetItem("ProductDetailWidgetName", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetName>() ?? new ProductDetailWidgetName(); 10 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj) Dynamicweb.Context.Current.Session["ProductAndVariants"]; 11 } 12 13 <div id="@paragraphID" class="pdp__ProductName @_data.CssClass"> 14 <h1 class="pdp-header__title"> 15 @if (_data.DisplayManufacturer && ProductAndVariants.Manufacturer != null) 16 { 17 <span class="pdp-header__manufacturer">@ProductAndVariants.Manufacturer.Name</span> 18 } 19 <span class="pdp-header__productname">@ProductAndVariants.ProductInfo.Name</span> 20 </h1> 21 </div> 22 23 <style> 24 25 .pdp__ProductName .pdp-header__productname { 26 color: var(--Color); 27 @_data.FontConfigurationProductName.InlineStyles 28 } 29 30 </style> 31
Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetImages.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_38be9945a07d4f35ac9399f726ecb17b.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetImages.cshtml:line 21 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog; 3 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 5 @using System.Text.RegularExpressions; 6 7 8 @{ 9 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 10 ProductDetailWidgetImages _data = Dynamicweb.Services.Items.GetItem("ProductDetailWidgetImages", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetImages>() ?? new ProductDetailWidgetImages(); 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 List<FieldOptionValueViewModel> productRibbons = null; 20 21 if (product.ProductFields["ProductRibbon"] != null) 22 { 23 productRibbons = (List<FieldOptionValueViewModel>)product.ProductFields["ProductRibbon"].Value; 24 } 25 26 //ProductObj ProductObj = (ProductObj)HttpContext.Current.Session["ProductDetails"]; 27 28 //ProductDetailObj DefaultProduct = ProductObj.Default[0]; 29 30 //ProductInfoObj DefaultProductInfo = DefaultProduct.ProductInfo; 31 32 //List<ProductAssetsObj> Assets = DefaultProduct.ProductImages.ProductAssets; 33 34 bool displayRibbon = _data.DisplayRibbon; 35 bool displayManufacturerLogo = _data.DisplayManufacturerLogo; 36 37 string videoUrl = ProductAndVariants?.ProductDetail?.YoutubeProductVideo ?? ""; 38 string videoId = ""; 39 string origin = Dynamicweb.Environment.Helpers.LinkHelper.GetHttpDomain(); 40 41 if (!string.IsNullOrWhiteSpace(videoUrl)) 42 { 43 // regex for direct YouTube ID (e.g. keBgXIeTmhk) 44 if (Regex.IsMatch(videoUrl, @"^[a-zA-Z0-9_-]{11}$")) 45 { 46 videoId = videoUrl; 47 } 48 // regex for https://youtu.be/{videoId} 49 else if (Regex.IsMatch(videoUrl, @"youtu\.be\/([^?&]+)")) 50 { 51 Match match = Regex.Match(videoUrl, @"youtu\.be\/([^?&]+)"); 52 videoId = match.Groups[1].Value; 53 } 54 // regex for https://www.youtube.com/watch?v={videoId} 55 else if (Regex.IsMatch(videoUrl, @"v=([^&]+)")) 56 { 57 Match match = Regex.Match(videoUrl, @"v=([^&]+)"); 58 videoId = match.Groups[1].Value; 59 } 60 } 61 } 62 63 <div id="@paragraphID" class="pdp-paragraph w-full @_data.CssClass"> 64 65 @if (!string.IsNullOrWhiteSpace(ProductAndVariants.ProductDetail.ProductRibbon) && displayRibbon) 66 { 67 <p class="product-detailpage__ribbon product-detailpage__ribbon--big"><span>@ProductAndVariants.ProductDetail.ProductRibbon</span></p> 68 } 69 70 <section class="product-detailpage__images pdp__images-container"> 71 <section class="productimages pdp__images"> 72 73 <section class="productimages__wrapper"> 74 75 <div class="productimages__carousel-big hidden"> 76 77 <div class="productimages__item"> 78 <img class="w-auto" src="/Admin/Public/GetImage.ashx?Image=@ProductAndVariants.Images.Default&Format=webp&Quality=-1&width=800&height=800" alt="@ProductAndVariants.Images.Default" height="800" width="800" /> 79 </div> 80 81 @if (!string.IsNullOrWhiteSpace(videoId)) 82 { 83 <div class="productimages__item"> 84 <div class="productimages__carousel__video-container"> 85 <lite-youtube 86 videoid="@videoId" 87 params="controls=1&loop=0&playlist=@videoId&playsinline=1&modestbranding=1&mute=1&rel=0&enablejsapi=1&origin=@origin&disablekb=0"> 88 </lite-youtube> 89 </div> 90 </div> 91 } 92 93 @if (ProductAndVariants.Images.AssetImages != null) 94 { 95 foreach (Image Image in ProductAndVariants.Images.AssetImages) 96 { 97 <div class="productimages__item"> 98 <img class="w-auto" src="/Admin/Public/GetImage.ashx?Image=@Image.Value&Format=webp&Quality=-1&width=800&height=800" alt="@Image.Value" /> 99 </div> 100 } 101 } 102103 </div> 104 </section> 105106 <div class="productimages__carousel-thumbnails hidden"> 107108 <div class="productimages__thumbnail" style="display: none;"> 109 <img class="w-auto" src="/Admin/Public/GetImage.ashx?Image=@ProductAndVariants.Images.Default&Crop=5&Format=webp&Quality=90&Compression=80&width=100&height=100" alt="@ProductAndVariants.Images.Default" height="100" width="100" /> 110 </div> 111112 @if(!string.IsNullOrWhiteSpace(videoId)) 113 { 114 <div class="productimages__thumbnail productimages__thumbnail--video pin-t mr-4" aria-hidden="true"> 115 <img class="h-full" src="https://img.youtube.com/vi/@videoId/0.jpg" alt="Video preview" height="84" width="84"> 116 <span class="video-icon"> 117 <i class="fas fa-play"></i> 118 </span> 119 </div> 120 } 121122 @if (ProductAndVariants.Images.AssetImages != null) 123 { 124 foreach (Image Thumb in ProductAndVariants.Images.AssetImages) 125 { 126 <div class="productimages__thumbnail"> 127 <img class="product-image" src="/Admin/Public/GetImage.ashx?Image=@Thumb.Value&Crop=5&Format=webp&Quality=90&Compression=80&width=100&height=100" alt="Thumbnail @Thumb.Value" width="100" height="100" /> 128 </div> 129 } 130 } 131 </div> 132133 <section class="productimages__wrapper"> 134 @if (displayManufacturerLogo && ProductAndVariants.Manufacturer != null && ProductAndVariants.Manufacturer.Logo != "") 135 { 136 <img src="/Admin/Public/GetImage.ashx?Image=/Files/@ProductAndVariants.Manufacturer.Logo&Crop=5&Format=webp&Quality=90&Compression=80&width=150" class="manufacturer__logo" alt="Manufacturer" width="150" height="50" /> 137 } 138 </section> 139140 </section> 141 </section> 142 </div> 143144 <style> 145 .productimages__item { 146 height: 400px; 147 } 148 </style> 149
Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetVariantSelector.cshtml" System.ArgumentNullException: Value cannot be null. Parameter name: key at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument) at System.Collections.Generic.Dictionary`2.FindEntry(TKey key) at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value) at Dynamicweb.Caching.DictionaryCache`2.GetCacheResult(IEnumerable`1 keys) at Dynamicweb.Caching.ServiceCache`2.GetCache(IEnumerable`1 keys) at Dynamicweb.Caching.ServiceCache`2.GetCache(TKey key) at Dynamicweb.Ecommerce.Variants.VariantGroupProductRelationService.GetProductRelations(String productId) at Dynamicweb.Ecommerce.Variants.VariantGroupService.GetVariantGroupsByProductId(String productId) at CompiledRazorTemplates.Dynamic.RazorEngine_3d9a5bdf5c454fe8a502adf6eb05a1f7.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetVariantSelector.cshtml:line 21 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 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 List<string[]> variantCombinationsIds = new List<string[]>(); 18 List<List<string>> variantGroupsOptionIds = new List<List<string>>(); 19 20 var variantCombinations = Dynamicweb.Ecommerce.Services.VariantCombinations.GetVariantCombinations(product.Id); 21 var variantGroups = Dynamicweb.Ecommerce.Services.VariantGroups.GetVariantGroupsByProductId(product.Id); 22 23 // Simple variants (no variant record in this language) return the master product without VariantId, fall back to the requested variant 24 string variantId = product.VariantId; 25 string requestedVariantId = Dynamicweb.Context.Current.Request.QueryString.Get("VariantID"); 26 if (string.IsNullOrEmpty(variantId) && !string.IsNullOrEmpty(requestedVariantId) && variantCombinations.Any(c => c.VariantId == requestedVariantId)) 27 { 28 variantId = requestedVariantId; 29 } 30 31 string variantSelection = variantId.Replace(".", ","); 32 string[] variantSelectionArr = variantSelection.Split(','); 33 34 foreach (var combination in variantCombinations) 35 { 36 variantCombinationsIds.Add(combination.VariantId.Split('.')); 37 } 38 string variantCombinationsIdsJson = JsonConvert.SerializeObject(variantCombinationsIds).Replace("\"", "\'"); 39 40 foreach (var variantGroup in variantGroups) 41 { 42 var variantsObject = new List<string>(); 43 foreach (var variantOption in variantGroup.GetAllVariantOptions()) 44 { 45 if (variantCombinationsIds.Any(ids => ids.Contains(variantOption.Id))) 46 { 47 variantsObject.Add(variantOption.Id); 48 } 49 } 50 if (variantsObject.Count > 0) 51 { 52 variantGroupsOptionIds.Add(variantsObject); 53 } 54 } 55 string variantGroupsOptionIdsJson = JsonConvert.SerializeObject(variantGroupsOptionIds).Replace("\"", "\'"); 56 } 57 58 <div id="@paragraphID" class="pdp-paragraph w-full"> 59 @if(variantGroups.Any()) { 60 <div class="product-variants__wrapper pdp-variants"> 61 <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"> 62 @foreach (var variantGroup in variantGroups) 63 { 64 bool containsImage = variantGroup.GetAllVariantOptions().Any(v => !string.IsNullOrEmpty(v.SmallImage)); 65 bool containsColor = variantGroup.GetAllVariantOptions().Any(v => !string.IsNullOrEmpty(v.Color)); 66 string variantGroupName = variantGroup.GetName(Pageview.Area.EcomLanguageId); 67 string variantGroupId = variantGroup.Id; 68 var variantGroupOptions = variantGroup.GetAllVariantOptions().Where(o => variantCombinationsIds.Any(ids => ids.Contains(o.Id))); 69 70 <div class="product-variants__block product-variants__block--@variantGroupId"> 71 @if (containsImage || containsColor) 72 { 73 if(!string.IsNullOrWhiteSpace(variantGroupName)) 74 { 75 <p class="product-variants__title">@Translate(string.Format("VariantGroup.{0}", variantGroupName), string.Format("Choose your {0}", variantGroupName))</p> 76 } 77 78 <div class="product-variants__options-wrapper"> 79 @foreach (VariantOption variantOption in variantGroupOptions) 80 { 81 string variantOptionName = Translate(string.Format("VariantOption.{0}.{1}", variantGroupId, variantOption.Id), variantOption.GetName(Pageview.Area.EcomLanguageId)); 82 string selected = variantSelectionArr.Contains(variantOption.Id) ? "product-variants__btn--checked" : ""; 83 84 if (!string.IsNullOrEmpty(variantOption.SmallImage)) 85 { 86 string variantImage = "/Files/" + variantOption.SmallImage; 87 <div data-variant-id="@variantOption.Id" data-variant-group="@variantGroupId" class="js-variant-option product-variants__btn product-variants__btn--image @selected"> 88 <img src="@variantImage" alt="@variantOptionName" title="@variantOptionName" /> 89 </div> 90 } 91 else if (!string.IsNullOrEmpty(variantOption.Color)) 92 { 93 <div data-variant-id="@variantOption.Id" data-variant-group="@variantGroupId" class="js-variant-option product-variants__btn product-variants__btn--color @selected"> 94 <span title="@variantOptionName" style="--variant-color: @variantOption.Color;"></span> 95 </div> 96 } 97 else 98 { 99 <button type="button" data-variant-id="@variantOption.Id" data-variant-group="@variantGroupId" class="js-variant-option product-variants__btn @selected">@variantOptionName</button> 100 } 101 } 102 </div> 103 } 104 else 105 { 106 if(!string.IsNullOrWhiteSpace(variantGroupName)) 107 { 108 <p class="product-variants__title">@Translate(string.Format("VariantGroup.{0}", variantGroupName), string.Format("Choose your {0}", variantGroupName))</p> 109 } 110111 <div class="product-variants__dropdown"> 112 <div class="product-variants__dropdown-wrapper"> 113114 <button class="product-variants__toggle"> 115 <span data-original="@Translate(string.Format("VariantDropdown.Placeholder.{0}", variantGroupName), "Select your option")">@Translate(string.Format("VariantDropdown.Placeholder.{0}", variantGroupName), "Select your option")</span> 116 <i class="fal fa-chevron-down"></i> 117 </button> 118119 <div class="product-variants__options-wrapper product-variants__options-wrapper--dropdown product-variants__dropdown-options-wrapper"> 120 @foreach (VariantOption variantOption in variantGroupOptions) 121 { 122 string selected = variantSelectionArr.Contains(variantOption.Id) ? "product-variants__btn--checked" : ""; 123124 <button type="button" data-variant-id="@variantOption.Id" data-variant-group="@variantGroupId" class="js-variant-option product-variants__btn--dropdown @selected"> 125 @Translate(string.Format("VariantOption.{0}.{1}", variantGroupId, variantOption.Id), variantOption.GetName(Pageview.Area.EcomLanguageId)) 126 </button> 127 } 128 </div> 129 </div> 130 </div> 131 } 132 </div> 133 } 134 </div> 135 </div> 136 } 137 </div> 138
Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetPrice.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_704a236515c24c729e5f368edfd72b48.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetPrice.cshtml:line 34 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.Prices; 3 @using Dynamicweb.Ecommerce.ProductCatalog; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 5 @using Bluedesk.DynamicWeb.ItemTypes.Settings.Configuration; 6 7 @{ 8 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 9 ProductDetailWidgetPrice _data = Dynamicweb.Services.Items.GetItem("ProductDetailWidgetPrice", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetPrice>() ?? new ProductDetailWidgetPrice(); 10 11 var master_configuration = Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "MasterConfiguration"); 12 MasterConfig mc = master_configuration.Item.ToCodeFirstItem<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 double informativePriceValue = WithVATBool ? product.PriceInformative.PriceWithVat : product.PriceInformative.PriceWithoutVat; 59 hasDiscount = gtmValue < informativePriceValue; 60 if (hasDiscount) 61 { 62 priceBeforeDiscountFormatted = informativePrice; 63 discountPercentage = Math.Round((((gtmValue - informativePriceValue) / informativePriceValue) * 100)); 64 65 double yourProfitValue = informativePriceValue - gtmValue; 66 priceTotalDiscountFormatted = WithVATBool ? new PriceInfo { PriceWithVAT = yourProfitValue }.PriceWithVATFormatted : new PriceInfo { PriceWithoutVAT = yourProfitValue }.PriceWithoutVATFormatted; 67 } 68 } 69 70 string retailPrice = ""; 71 bool displayRetailPrice = EcommerceConfiguration.DisplayRetailPrice; 72 if(EcommerceConfiguration.DisplayRetailPriceForUsers && Pageview.User == null) { 73 displayRetailPrice = false; 74 } 75 if(displayRetailPrice) { 76 string priceFieldName = EcommerceConfiguration.RetailPriceField; 77 if(EcommerceConfiguration.RetailPriceIsDbPrice) { 78 var p = Dynamicweb.Ecommerce.Services.Products.GetProductById(product.Id, product.VariantId, Pageview.Area.EcomLanguageId); 79 PriceContext customerPriceContext = new PriceContext(Dynamicweb.Ecommerce.Common.Context.Currency, Dynamicweb.Ecommerce.Common.Context.Country, null, null, Dynamicweb.Ecommerce.Common.Context.ReverseChargeForVatEnabled, DateTime.Now); 80 var customerPrice = p?.GetPrice(customerPriceContext); 81 if(customerPrice.Price > 0) { 82 retailPrice = WithVATBool ? customerPrice.PriceWithVATFormatted : customerPrice.PriceWithoutVATFormatted; 83 } 84 } else if(!string.IsNullOrWhiteSpace(priceFieldName)) { 85 double customerPriceValue = 0.0; 86 if (product.ProductFields.TryGetValue(priceFieldName, out var fieldValue) && fieldValue.Value is double) { 87 customerPriceValue = (double)fieldValue.Value; 88 } 89 if(customerPriceValue > 0) { 90 retailPrice = WithVATBool ? new PriceInfo { PriceWithVAT = customerPriceValue }.PriceWithVATFormatted : new PriceInfo { PriceWithoutVAT = customerPriceValue }.PriceWithoutVATFormatted; 91 } 92 } 93 } 94 95 bool isVariant = product.VariantId != ""; 96 int variantCount = product?.VariantInfo?.VariantInfo?.Count ?? 0; 97 bool hasVariants = !isVariant ? variantCount > 0 : false; 98 } 99100 <div id="@paragraphID" class="pdp-paragraph @_data.CssClass"> 101 @if (displayPrice && displayProductPrice) 102 { 103 <div class="pdp-price__container"> 104 @if (hasVariants) 105 { 106 string priceMin = WithVATBool ? product?.VariantInfo?.PriceMin?.PriceWithVatFormatted : product?.VariantInfo?.PriceMin?.PriceWithoutVatFormatted; 107 string fromText = Translate("Productdetail.Price.FromLabel", "From"); 108109 if (!string.IsNullOrWhiteSpace(priceMin)) 110 { 111 <section class="pdp-price__subcontainer"> 112 <span class="pdp-price__from">@fromText</span> 113 <span class="pdp-price">@priceMin</span> 114 <span class="pdp-price--suffix">@ProductdetailPriceSuffix</span> 115 </section> 116 } 117 } 118 else 119 { 120 if (hasDiscount) 121 { 122 <p class="pdp-price--original">@priceBeforeDiscountFormatted</p> 123 <section class="pdp-price__subcontainer"> 124 <span class="pdp-price">@priceFormatted</span> 125 <span class="pdp-price--suffix">@ProductdetailPriceSuffix</span> 126 <span class="pdp-price__percentage">@discountPercentage%</span> 127 </section> 128 } 129 else 130 { 131 <section class="pdp-price__subcontainer"> 132 <span class="pdp-price">@priceFormatted</span> 133 <span class="pdp-price--suffix">@ProductdetailPriceSuffix</span> 134 </section> 135 } 136137 if (!string.IsNullOrWhiteSpace(retailPrice)) 138 { 139 <p class="pdp-price__retail-price"> 140 @String.Format(Translate("ProductBlockTitle.RetailPrice", "Retail price: {0}"), retailPrice) 141 </p> 142 } 143 if (hasDiscount) 144 { 145 <p class="pdp-price__yourprofit"> 146 @Translate("Productdetail.YourProfitLabel", "Your profit:") @priceTotalDiscountFormatted 147 </p> 148 } 149 } 150 </div> 151 } 152 </div> 153
Error executing template "/Designs/ClientBase_generated/Paragraph/ProductDetailWidgetStock.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at Dynamicweb.Ecommerce.Products.ProductService.GetStockStatus(Product product, StockLocation stockLocation, String unitId) at CompiledRazorTemplates.Dynamic.RazorEngine_042950a066b549308e349a4e62fe4c5f.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetStock.cshtml:line 46 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 3 @using Dynamicweb.Ecommerce.ProductCatalog; 4 @using Dynamicweb.Ecommerce.Stocks; 5 @using Bluedesk.DynamicWeb.ItemTypes.Settings.Configuration; 6 7 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 8 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 9 10 @{ 11 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 12 13 var master_configuration = Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "MasterConfiguration"); 14 MasterConfig mc = master_configuration.Item.ToCodeFirstItem<MasterConfig>(); 15 EcomConfig EcommerceConfiguration = mc.EcomConfiguration; 16 17 ProductViewModel product = new ProductViewModel(); 18 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 19 { 20 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 21 } 22 23 ProductAndVariantsObj _product = (ProductAndVariantsObj)Dynamicweb.Context.Current.Session["ProductAndVariants"]; 24 25 bool hideStockForGuests = EcommerceConfiguration.HideStockForGuests; 26 bool enableProductStock = hideStockForGuests ? Pageview.User != null : true; 27 string stockFormat = EcommerceConfiguration.StockFormat; 28 bool inStock = product.StockLevel > 0 || product.NeverOutOfstock; 29 string stockStateClass = inStock ? "pdp-stockstate--instock" : "pdp-stockstate--outofstock"; 30 31 bool isVariant = product.VariantId != ""; 32 int variantCount = product?.VariantInfo?.VariantInfo?.Count ?? 0; 33 bool hasVariants = !isVariant ? variantCount > 0 : false; 34 35 if(hasVariants) { 36 enableProductStock = false; 37 } 38 } 39 40 <div id="@paragraphID" class="pdp-paragraph"> 41 @if(enableProductStock && !string.IsNullOrWhiteSpace(stockFormat)) 42 { 43 if(stockFormat == "text") { 44 StockLocation stockLocation = Dynamicweb.Ecommerce.Services.StockService.GetStockLocation(Pageview.Area.StockLocationID); 45 var currentProduct = Dynamicweb.Ecommerce.Services.Products.GetProductById(product.Id, "", Pageview.Area.EcomLanguageId); 46 string stockText = Dynamicweb.Ecommerce.Services.Products.GetStockStatus(currentProduct, stockLocation, Pageview.Area.EcomLanguageId)?.Text; 47 48 if (!string.IsNullOrWhiteSpace(stockText)) 49 { 50 <p class="pdp-stockstate @stockStateClass">@string.Format(stockText, product.StockLevel)</p> 51 } 52 } 53 else 54 { 55 string translationTag = ""; 56 if(product.NeverOutOfstock) 57 { 58 translationTag = Translate("ProductBlockStockInfo.AmountInStock", "In stock"); 59 } 60 else if(product.StockLevel == 1) 61 { 62 translationTag = Translate("ProductBlockStockInfo.AmountInStockSingle", "{0} product in stock"); 63 } 64 else if(product.StockLevel > 1) 65 { 66 translationTag = Translate("ProductBlockStockInfo.AmountInStockMultiple", "{0} products in stock"); 67 } 68 else if(!inStock) 69 { 70 translationTag = Translate("ProductBlockStockInfo.AmountOutOfStock", "Out of stock"); 71 } 72 73 <p class="pdp-stockstate @stockStateClass">@string.Format(translationTag, product.StockLevel)</p> 74 } 75 } 76 </div> 77
Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetAddToCart.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_6cdfaffe77b4478785746723487954f1.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetAddToCart.cshtml:line 35 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Web; 3 @using Dynamicweb.Ecommerce.ProductCatalog; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 5 @using Bluedesk.DynamicWeb.ItemTypes.Settings.Configuration; 6 @using Bluedesk.DynamicWeb.ItemTypes.Configuration; 7 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 8 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 9 10 @{ 11 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 12 ProductDetailWidgetAddToCart _data = Dynamicweb.Services.Items.GetItem("ProductDetailWidgetAddToCart", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetAddToCart>() ?? new ProductDetailWidgetAddToCart(); 13 14 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj)Dynamicweb.Context.Current.Session["ProductAndVariants"]; 15 16 var master_configuration = Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "MasterConfiguration"); 17 MasterConfig mc = master_configuration.Item.ToCodeFirstItem<MasterConfig>(); 18 EcomConfig EcommerceConfiguration = mc.EcomConfiguration; 19 20 var corporate_settings = Dynamicweb.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "CorporateSettingsPage"); 21 CorporateSettingsPage cs = corporate_settings?.Item?.ToCodeFirstItem<CorporateSettingsPage>(); 22 23 ProductViewModel product = new ProductViewModel(); 24 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 25 { 26 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 27 } 28 29 bool hideShoppingCartForGuests = EcommerceConfiguration.HideShoppingCartForGuests; 30 bool enableAddToCartForZeroPrices = EcommerceConfiguration.AddToCartAllowZeroPrices; 31 bool enableAddToCartForOutOfStock = EcommerceConfiguration.AddToCartAllowOutOfStock; 32 33 bool enableShoppingCart = hideShoppingCartForGuests && Pageview.User == null ? false : Pageview.Area.Item["ConfigModuleShoppingCart"] != null ? (bool)Pageview.Area.Item["ConfigModuleShoppingCart"] : false; 34 bool enableProductShoppingCart = enableShoppingCart; 35 if (!enableAddToCartForZeroPrices && product.Price.Price <= 0) 36 { 37 enableProductShoppingCart = false; 38 } 39 if (!enableAddToCartForOutOfStock && !(product.StockLevel > 0 || product.NeverOutOfstock)) 40 { 41 enableProductShoppingCart = false; 42 } 43 44 int QuotePageID = !string.IsNullOrWhiteSpace(_data.OffertePageId) ? int.Parse(_data.OffertePageId) : 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 // Simple variants (no variant record in this language) return the master product without VariantId, fall back to the requested variant 48 string variantId = product.VariantId; 49 string requestedVariantId = Dynamicweb.Context.Current.Request.QueryString.Get("VariantID"); 50 if (string.IsNullOrEmpty(variantId) && !string.IsNullOrEmpty(requestedVariantId) && Dynamicweb.Ecommerce.Services.VariantCombinations.GetVariantCombinations(product.Id).Any(c => c.VariantId == requestedVariantId)) 51 { 52 variantId = requestedVariantId; 53 } 54 55 bool isVariant = variantId != ""; 56 int variantCount = product?.VariantInfo?.VariantInfo?.Count ?? 0; 57 bool hasVariants = !isVariant ? variantCount > 0 : false; 58 59 bool enablePhoneButton = _data.EnableCallButton; 60 string phonenumberFormatted = !string.IsNullOrWhiteSpace(_data.CallButtonText) ? _data.CallButtonText : cs.Phonenumber; 61 string phonenumberHref = phonenumberFormatted?.Replace("(", "").Replace(")", "").Replace(" ", "") ?? ""; 62 if(string.IsNullOrWhiteSpace(phonenumberHref)) 63 { 64 enablePhoneButton = false; 65 } 66 } 67 68 <div id="@paragraphID" class="pdp-paragraph @_data.CssClass"> 69 @if (!hasVariants) 70 { 71 if (enableShoppingCart && enableProductShoppingCart) 72 { 73 <div class="pdp-add-to-cart pdp-add-to-cart__container"> 74 <add-to-cart class="app-addtocart" 75 data-prodid="@product.Id" 76 data-variantid="@variantId" 77 data-min-quantity="@product.PurchaseMinimumQuantity" 78 data-step="@product.PurchaseQuantityStep" 79 data-list-id="product_detail" 80 data-list-name="Product detail"> 81 </add-to-cart> 82 </div> 83 } 84 else 85 { 86 if (QuotePageID > 0 || enablePhoneButton) 87 { 88 ButtonConfiguration btnStyle = _data.ButtonConfiguration; 89 string btnStyleClass = btnStyle != null ? $"btn--{btnStyle.Id}" : ""; 90 91 <style> 92 @if (btnStyle != null) 93 { 94 @btnStyle.GetButtonStylesheet() 95 } 96 </style> 97 98 <div class="pdp-quote-button"> 99 @if(_data.ShowTitle) 100 { 101 <p><strong>@Translate("QuoteRequestTitle", "Want to know more?")</strong></p> 102 } 103 <div class="pdp-quote-button__list"> 104105 @if (QuotePageID > 0) 106 { 107 string btnTarget = $"/Default.aspx?ID={QuotePageID}&ProdID={product.Id}"; 108 if (!string.IsNullOrWhiteSpace(variantId)) 109 { 110 btnTarget = $"{btnTarget}&VarID={variantId}"; 111 } 112 <a href="@btnTarget" class="btn btn-quote--contact default-btn @btnStyleClass"> 113 <span class="btn__text">@_data.ButtonText</span> 114 <i class="btn__icon @_data.ButtonIcon"></i> 115 </a> 116 } 117118 @if (enablePhoneButton) 119 { 120 <a href="tel:@phonenumberHref" class="btn btn-quote--phone default-btn"> 121 <span class="btn__text"><strong>@Translate("QuoteRequestPhone", "Call:")</strong> @phonenumberFormatted</span> 122 </a> 123 } 124 </div> 125 </div> 126 } 127 } 128 } 129 </div> 130
Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetPaymentLogos.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_0428f21a5d8b46cc96181646003ebf4a.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetPaymentLogos.cshtml:line 18 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 3 @using Dynamicweb.Ecommerce.ProductCatalog; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 5 6 @{ 7 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 8 var selectedPaymentLogos = Pageview.Area.Item["FooterPaymentLogos"]; 9 ProductDetailWidgetPaymentLogos _data = Dynamicweb.Services.Items.GetItem("ProductDetailWidgetPaymentLogos", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetPaymentLogos>() ?? new ProductDetailWidgetPaymentLogos(); 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 18 @if (product.Price.Price > 0) 19 { 20 <div id="@paragraphID" class="pdp-paragraph @_data.CssClass"> 21 <section class="pdp-paymentlogos paymentlogos--small"> 22 <div class="footer-paymentoptions" data-paymentmethods="@selectedPaymentLogos"></div> 23 </section> 24 </div> 25 } 26
Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetProductUsps.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_7af5c86533f24e8aa3bac9d2bf30a7a3.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetProductUsps.cshtml:line 13 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 3 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 5 6 @{ 7 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 8 ProductDetailWidgetProductUsps _data = Dynamicweb.Services.Items.GetItem("ProductDetailWidgetProductUsps", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetProductUsps>() ?? new ProductDetailWidgetProductUsps(); 9 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj)Dynamicweb.Context.Current.Session["ProductAndVariants"]; 10 string uspIcon = _data.USPIcon; 11 12 var productUsps = new List<String>(); 13 if (ProductAndVariants.USP != null && !string.IsNullOrWhiteSpace(ProductAndVariants.USP.USP1)) { productUsps.Add(ProductAndVariants.USP.USP1.ToString()); } 14 if (ProductAndVariants.USP != null && !string.IsNullOrWhiteSpace(ProductAndVariants.USP.USP2)) { productUsps.Add(ProductAndVariants.USP.USP2); } 15 if (ProductAndVariants.USP != null && !string.IsNullOrWhiteSpace(ProductAndVariants.USP.USP3)) { productUsps.Add(ProductAndVariants.USP.USP3); } 16 if (ProductAndVariants.USP != null && !string.IsNullOrWhiteSpace(ProductAndVariants.USP.USP4)) { productUsps.Add(ProductAndVariants.USP.USP4); } 17 if (ProductAndVariants.USP != null && !string.IsNullOrWhiteSpace(ProductAndVariants.USP.USP5)) { productUsps.Add(ProductAndVariants.USP.USP5); } 18 19 /* 20 21 ProductViewModel product = new ProductViewModel(); 22 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 23 { 24 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 25 } 26 27 var productUsps = new List<String>(); 28 29 if (product.ProductFields != null && product.ProductFields.ContainsKey("ProductUSP1")) 30 { 31 productUsps.Add(product.ProductFields["ProductUSP1"].Value.ToString()); 32 } 33 if (product.ProductFields != null && product.ProductFields.ContainsKey("ProductUSP2")) 34 { 35 productUsps.Add(product.ProductFields["ProductUSP2"].Value.ToString()); 36 } 37 if (product.ProductFields != null && product.ProductFields.ContainsKey("ProductUSP3")) 38 { 39 productUsps.Add(product.ProductFields["ProductUSP3"].Value.ToString()); 40 } 41 if (product.ProductFields != null && product.ProductFields.ContainsKey("ProductUSP4")) 42 { 43 productUsps.Add(product.ProductFields["ProductUSP4"].Value.ToString()); 44 } 45 if (product.ProductFields != null && product.ProductFields.ContainsKey("ProductUSP5")) 46 { 47 productUsps.Add(product.ProductFields["ProductUSP5"].Value.ToString()); 48 } 49 50 */ 51 52 } 53 54 <div id="@paragraphID" class="pdp-paragraph @_data.CssClass"> 55 56 <ul class="pdp-usplist"> 57 @foreach (string usp in productUsps) 58 { 59 if (!string.IsNullOrWhiteSpace(usp)) 60 { 61 <li class="pdp-usplist__item"> 62 @if (!string.IsNullOrWhiteSpace(uspIcon)) 63 { 64 <i class="pdp-usplist__uspicon @uspIcon"></i> 65 } 66 <span>@usp</span> 67 </li> 68 } 69 } 70 </ul> 71 72 </div> 73
Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetShortDescription.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_0c37805f91764bfa91b447257564e6b6.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetShortDescription.cshtml:line 12 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 3 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 4 5 @{ 6 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 7 8 ProductDetailWidgetShortDescription _data = Dynamicweb.Services.Items.GetItem("ProductDetailWidgetShortDescription", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetShortDescription>() ?? new ProductDetailWidgetShortDescription(); 9 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj) Dynamicweb.Context.Current.Session["ProductAndVariants"]; 10 11 string readMoreTarget = _data.ButtonTarget; 12 string shortDescription = ProductAndVariants.ProductInfo.ShortDescription; 13 } 14 15 <div id="@paragraphID" class="pdp-paragraph pdp-paragraph-short-description ProductShortDescription"> 16 @if(!string.IsNullOrWhiteSpace(shortDescription)) 17 { 18 <p class="pdp-header__productname">@shortDescription</p> 19 if(!string.IsNullOrWhiteSpace(readMoreTarget)) 20 { 21 <a href="@readMoreTarget" class="btn default-btn" target="_self"> 22 <span class="btn__text">@Translate("Productdetail.Readmore", "Read more")</span> 23 <i class="btn__icon fa-chevron-right"></i> 24 </a> 25 } 26 } 27 </div> 28
Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetLongDescription.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_6ec41786bd3a4450a01bae3f63d61a9d.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetLongDescription.cshtml:line 41 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 3 @using Dynamicweb; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Configuration.AdvancedGrid.Elements; 5 6 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 7 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 8 9 @{ 10 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 11 12 ProductDetailWidgetLongDescription _data = Dynamicweb.Services.Items.GetItem("ProductDetailWidgetLongDescription", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetLongDescription>() ?? new ProductDetailWidgetLongDescription(); 13 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj)Dynamicweb.Context.Current.Session["ProductAndVariants"]; 14 15 bool IsNotContentManager = false; 16 bool isVisualEditor = Pageview.IsVisualEditorMode; 17 18 if (isVisualEditor) 19 { 20 System.Web.HttpContext.Current.Session["PreviousPage"] = Pageview.Page.ID; 21 IsNotContentManager = (Dynamicweb.Security.UserManagement.User.GetCurrentBackendUser()?.Groups?.All(g => g.Name != "Content managers") ?? true); 22 } 23 24 if (ProductAndVariants != null && ProductAndVariants.ProductInfo != null && ProductAndVariants.ProductInfo.LongDescription != null) 25 { 26 27 <div id="@paragraphID" class="ProductLongDescription @_data.CssClass"> 28 <div class="ProductLongDescription__header">@Translate("ProductDetailWidget.LongDescription.Header", "Productinformatie")</div> 29 30 <p>@ProductAndVariants.ProductInfo.LongDescription</p> 31 </div> 32 33 <style> 34 @_data.FontConfigurationProductName.InlineStyles 35 </style> 36 37 } 38 else 39 { 40 41 <script>console.dir(@ProductAndVariants.Template.Json)</script> 42 43 <placeholder id="@paragraphID" class="ProductLongDescription @_data.CssClass"></placeholder> 44 45 if (_data.HideTabWhenEmpty) 46 { 47 <script> 48 49 document.addEventListener('DOMContentLoaded', function () { 50 51 var Element = document.getElementById("@paragraphID"); 52 console.dir(Element); 53 var parentElement = Element.closest('.content-tab'); 54 console.dir(parentElement); 55 var TabElement = document.querySelector('[data-tab-target=' + parentElement.id + ']'); 56 console.dir(TabElement); 57 58 @{ 59 if (isVisualEditor && IsNotContentManager) 60 { 61 <text>TabElement.style.display = 'flex';</text> 62 } 63 else 64 { 65 <text>TabElement.style.display = 'none';</text> 66 } 67 } 68 69 }); 70 71 </script> 72 } 73 74 } 75 76 } 77
Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetDownloadProductsheet.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_3976a5533c7442428fc1b678f2817b49.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetDownloadProductsheet.cshtml:line 12 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 3 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 4 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 5 6 @{ 7 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 8 ProductDetailWidgetDownloadProductsheet _data = Dynamicweb.Services.Items.GetItem("ProductDetailWidgetDownloadProductsheet", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetDownloadProductsheet>() ?? new ProductDetailWidgetDownloadProductsheet(); 9 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj)Dynamicweb.Context.Current.Session["ProductAndVariants"]; 10 } 11 12 @if (!string.IsNullOrWhiteSpace(ProductAndVariants.ProductDetail.DownloadProductsheet)) 13 { 14 15 <nav id="@paragraphID" class="cta-paragraph__btn-navigation @_data.CssClass"> 16 <a href="/Files/Images/@ProductAndVariants.ProductDetail.DownloadProductsheet" class="btn default-btn btn--@paragraphID" target="_blank"> 17 <i class="btn__icon fa-download cta-paragraph__btn-icon"></i> 18 <span class="btn__text cta-paragraph__btn cta-paragraph__btn-label">@_data.Label</span> 19 </a> 20 </nav> 21 22 } 23
Error executing template "Designs/ClientBase_generated/Paragraph/ProductOptiePakketten.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_5b2a039cdfef47d9b6b63c2715ba4b9f.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductOptiePakketten.cshtml:line 23 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System.Web; 3 @using System.Linq; 4 @using System.Collections.Generic; 5 @using KoksGroup.Tools.ItemTypes; 6 @using Dynamicweb.Ecommerce.ProductCatalog; 7 8 @{ 9 var paragraphID = Pageview.CurrentParagraph.ID; 10 ProductOptiePakketten _data = Dynamicweb.Services.Items.GetItem("ProductOptiePakketten", Model.ItemId).ToCodeFirstItem<ProductOptiePakketten>() ?? new ProductOptiePakketten(); 11 12 ProductViewModel product = new ProductViewModel(); 13 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 14 { 15 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 16 } 17 18 // Get configurable field names from paragraph settings 19 string allOptiePakkettenFieldName = !string.IsNullOrWhiteSpace(_data.AllOptiePakkettenFieldName) ? _data.AllOptiePakkettenFieldName : "KoksOptiepakketten"; 20 string productSpecificOptiePakkettenFieldName = !string.IsNullOrWhiteSpace(_data.ProductSpecificOptiePakkettenFieldName) ? _data.ProductSpecificOptiePakkettenFieldName : "KoksProductSpecificOptiepakketten"; 21 22 string allOptiePakkettenIds = ""; 23 if (product.ProductFields.TryGetValue(allOptiePakkettenFieldName, out var allOptiePakkettenFieldValue) && allOptiePakkettenFieldValue.Value is IEnumerable<dynamic> allOptiePakkettenItems) { 24 var values = allOptiePakkettenItems.Select(item => item.Value?.ToString()).Where(v => !string.IsNullOrEmpty(v)); 25 allOptiePakkettenIds = string.Join(",", values); 26 } 27 List<OptiePakket> allOptiePakkettenList = GetOptiePakkettenByIds(allOptiePakkettenIds, Pageview.Area.ID, Pageview.Area.IsMaster); 28 29 string productUniqueOptiePakkettenIds = ""; 30 if (product.ProductFields.TryGetValue(productSpecificOptiePakkettenFieldName, out var productUniqueFieldValue) && productUniqueFieldValue.Value is IEnumerable<dynamic> productUniqueItems) { 31 var values = productUniqueItems.Select(item => item.Value?.ToString()).Where(v => !string.IsNullOrEmpty(v)); 32 productUniqueOptiePakkettenIds = string.Join(",", values); 33 } 34 List<OptiePakket> productUniqueOptiePakkettenList = GetOptiePakkettenByIds(productUniqueOptiePakkettenIds, Pageview.Area.ID, Pageview.Area.IsMaster); 35 } 36 37 @if(allOptiePakkettenList.Any() || productUniqueOptiePakkettenList.Any()) 38 { 39 <div id="@paragraphID" class="pdp-paragraph pdp-optiepakketten w-full"> 40 <div class="container"> 41 42 @if (allOptiePakkettenList.Any()) 43 { 44 <div class="pdp-optiepakketten__wrapper"> 45 <h2 class="pdp-optiepakketten__title">@Translate("AlleOptiePakketten.Title", "Alle optiepakketten")</h2> 46 <ul class="optiepakketten-list"> 47 @foreach (var item in allOptiePakkettenList) 48 { 49 @RenderOptiePakketItem(item) 50 } 51 </ul> 52 </div> 53 } 54 55 @if (productUniqueOptiePakkettenList.Any()) 56 { 57 <div class="pdp-optiepakketten__wrapper"> 58 <h2 class="pdp-optiepakketten__title">@Translate("UniekeOptiePakketten.Title", "Unieke optiepakketten voor dit product")</h2> 59 <ul class="optiepakketten-list"> 60 @foreach (var item in productUniqueOptiePakkettenList) 61 { 62 @RenderOptiePakketItem(item) 63 } 64 </ul> 65 </div> 66 } 67 68 <div id="optiepakket-modal" class="koks-modal" role="dialog" aria-labelledby="koks-modal-title" aria-hidden="true" tabindex="-1"> 69 <div class="koks-modal__overlay" data-modal-close></div> 70 <div class="koks-modal__content"> 71 <div class="koks-modal__header"> 72 <h2 class="koks-modal__heading"> 73 <span id="koks-modal-number" class="koks-modal__number"></span> 74 <span class="koks-modal__seperator"> | </span> 75 <span id="koks-modal-title" class="koks-modal__title"></span> 76 </h2> 77 <button type="button" class="koks-modal__close" data-modal-close aria-label="@Translate("Modal.Close", "Sluiten")"> 78 <i class="fal fa-times" aria-hidden="true"></i> 79 </button> 80 </div> 81 <div class="koks-modal__body"> 82 <div class="koks-modal__image-container"> 83 <img id="koks-modal-image" src="" alt="" class="koks-modal__image" width="502" height="200" /> 84 </div> 85 <div id="koks-modal-description-text" class="koks-modal__description"> 86 </div> 87 </div> 88 </div> 89 </div> 90 91 </div> 92 </div> 93 } 94 95 @functions { 96 public OptiePakket GetOptiePakketById(int masterPageId, int languageId, bool isMaster) 97 { 98 try 99 { 100 var pageId = isMaster ? masterPageId : Dynamicweb.Content.Services.Pages.GetPageIDByMasterID(masterPageId, languageId); 101 return Dynamicweb.Services.Items.GetItemByPageId(pageId, false).ToCodeFirstItem<OptiePakket>(); 102 } 103 catch 104 { 105 return null; 106 } 107 } 108109 public List<OptiePakket> GetOptiePakkettenByIds(string masterPageIdString, int languageId, bool isMaster) 110 { 111 var result = new List<OptiePakket>(); 112113 if (string.IsNullOrWhiteSpace(masterPageIdString)) 114 { 115 return result; 116 } 117118 string[] masterPageIds = masterPageIdString.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries); 119120 foreach (var idString in masterPageIds) 121 { 122 if (int.TryParse(idString.Trim(), out int masterPageId)) 123 { 124 var item = GetOptiePakketById(masterPageId, languageId, isMaster); 125 if (item != null) 126 { 127 result.Add(item); 128 } 129 } 130 } 131132 return result; 133 } 134135 public IHtmlString RenderOptiePakketItem(OptiePakket item) 136 { 137 string viewDetailsText = $"{Translate("OptiePakket.ViewDetails", "Bekijk details van optiepakket")} {item.Number} {item.Name}"; 138139 var html = $@" 140 <li class=""optiepakket__item"" 141 data-name=""{HttpUtility.HtmlAttributeEncode(item.Name ?? "")}"" 142 data-number=""{item.Number ?? ""}"" 143 data-description=""{HttpUtility.HtmlAttributeEncode(item.Description ?? "")}"" 144 data-image=""{item.Image ?? ""}""> 145 <button type=""button"" class=""optiepakket__button"" aria-label=""{HttpUtility.HtmlAttributeEncode(viewDetailsText)}"" data-optiepakket-trigger=""true""> 146 <p> 147 <span class=""optiepakket__number"">{item.Number}</span> 148 <span class=""optiepakket__seperator""> | </span> 149 <span class=""optiepakket__name"">{HttpUtility.HtmlEncode(item.Name)}</span> 150 </p> 151 <span class=""optiepakket__more-info""> 152 <i class=""fal fa-chevron-right"" aria-hidden=""true""></i> 153 </span> 154 </button> 155 </li>"; 156157 return new HtmlString(html); 158 } 159 } 160

Laat u adviseren door een specialist Maak kennis met ons en onze producten Krijg inzicht in welke oplossing het beste bij u past
Error executing template "Designs/ClientBase_generated/Paragraph/ProductDetailWidgetStickyAddToCart.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_12d44cd9cac84987b8106042e5809185.Execute() in D:\dynamicweb.net\Solutions\Bluedesk\koksgroup.cloud.dynamicweb-cms.com\files\Templates\Designs\ClientBase_generated\Paragraph\ProductDetailWidgetStickyAddToCart.cshtml:line 32 at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 3 @using Dynamicweb.Ecommerce.Prices; 4 @using Dynamicweb.Ecommerce.ProductCatalog; 5 @using Bluedesk.DynamicWeb.ItemTypes.Settings.Configuration; 6 @using Bluedesk.DynamicWeb.ItemTypes.Configuration; 7 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution; 8 @using Bluedesk.DynamicWeb.ItemTypes.BaseSolution.Frontend; 9 10 @{ 11 string paragraphID = Pageview.CurrentParagraph.ID.ToString(); 12 ProductDetailWidgetStickyAddToCart _data = Dynamicweb.Content.Services.Items.GetItem("ProductDetailWidgetStickyAddToCart", Model.ItemId).ToCodeFirstItem<ProductDetailWidgetStickyAddToCart>() ?? new ProductDetailWidgetStickyAddToCart(); 13 14 ProductAndVariantsObj ProductAndVariants = (ProductAndVariantsObj)Dynamicweb.Context.Current.Session["ProductAndVariants"]; 15 16 var master_configuration = Dynamicweb.Content.Services.Pages.GetPageByNavigationTag(Pageview.AreaID, "MasterConfiguration"); 17 MasterConfig mc = master_configuration.Item.ToCodeFirstItem<MasterConfig>(); 18 EcomConfig EcommerceConfiguration = mc.EcomConfiguration; 19 20 ProductViewModel product = new ProductViewModel(); 21 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 22 { 23 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 24 } 25 26 bool hideShoppingCartForGuests = EcommerceConfiguration.HideShoppingCartForGuests; 27 bool enableAddToCartForZeroPrices = EcommerceConfiguration.AddToCartAllowZeroPrices; 28 bool enableAddToCartForOutOfStock = EcommerceConfiguration.AddToCartAllowOutOfStock; 29 30 bool enableShoppingCart = hideShoppingCartForGuests && Pageview.User == null ? false : Pageview.Area.Item["ConfigModuleShoppingCart"] != null ? (bool)Pageview.Area.Item["ConfigModuleShoppingCart"] : false; 31 bool enableProductShoppingCart = enableShoppingCart; 32 if (!enableAddToCartForZeroPrices && product.Price.Price <= 0) 33 { 34 enableProductShoppingCart = false; 35 } 36 if (!enableAddToCartForOutOfStock && !(product.StockLevel > 0 || product.NeverOutOfstock)) 37 { 38 enableProductShoppingCart = false; 39 } 40 if (product.Discontinued) 41 { 42 enableProductShoppingCart = false; 43 } 44 45 bool WithVATBool = Pageview.Area.EcomPricesWithVat == "True"; 46 bool pricesWithoutVatForUsers = EcommerceConfiguration.ShowPricesWithoutVatForUsers; 47 bool pricesWithoutVatForValidVat = EcommerceConfiguration.ShowPricesWithoutVatWhenValidVatNumber; 48 if (pricesWithoutVatForUsers && !pricesWithoutVatForValidVat && Pageview.User != null) 49 { 50 WithVATBool = false; 51 } 52 if (pricesWithoutVatForValidVat && Pageview.User != null && !string.IsNullOrWhiteSpace(Pageview.User.VatRegNumber)) 53 { 54 WithVATBool = false; 55 } 56 57 bool hidePricesForGuests = EcommerceConfiguration.HidePricesForGuests; 58 bool hideZeroPrices = EcommerceConfiguration.HideZeroPrices; 59 bool displayPrice = hidePricesForGuests ? Pageview.User != null : true; 60 bool pricezero = product.Price.Price <= 0; 61 62 bool displayProductPrice = displayPrice; 63 if (hideZeroPrices && pricezero) 64 { 65 displayProductPrice = false; 66 } 67 68 string ProductdetailPriceSuffixWithVAT = Translate("Productdetail.Price.Suffix.WithVAT", "Incl. VAT"); 69 string ProductdetailPriceSuffixWithoutVAT = Translate("Productdetail.Price.Suffix.WithoutVAT", "Excl. VAT"); 70 string ProductdetailPriceSuffix = WithVATBool ? ProductdetailPriceSuffixWithVAT : ProductdetailPriceSuffixWithoutVAT; 71 72 var gtmValue = WithVATBool ? product.Price.PriceWithVat : product.Price.PriceWithoutVat; 73 var priceFormatted = WithVATBool ? product.Price.PriceWithVatFormatted : product.Price.PriceWithoutVatFormatted; 74 var priceBeforeDiscount = WithVATBool ? product.PriceBeforeDiscount.PriceWithVat : product.PriceBeforeDiscount.PriceWithoutVat; 75 var priceBeforeDiscountFormatted = WithVATBool ? product.PriceBeforeDiscount.PriceWithVatFormatted : product.PriceBeforeDiscount.PriceWithoutVatFormatted; 76 var priceTotalDiscount = WithVATBool ? product.Discount.PriceWithVat : product.Discount.PriceWithoutVat; 77 var priceTotalDiscountFormatted = WithVATBool ? product.Discount.PriceWithVatFormatted : product.Discount.PriceWithoutVatFormatted; 78 double discountPercentage = Math.Round(((priceTotalDiscount / priceBeforeDiscount) * -100)); 79 bool hasDiscount = product.Discount.Price > 0; 80 81 string informativePrice = WithVATBool ? product.PriceInformative.PriceWithVatFormatted : product.PriceInformative.PriceWithoutVatFormatted; 82 if (EcommerceConfiguration.UseInformativePriceAsFromPrice && !string.IsNullOrWhiteSpace(informativePrice)) 83 { 84 double informativePriceValue = WithVATBool ? product.PriceInformative.PriceWithVat : product.PriceInformative.PriceWithoutVat; 85 hasDiscount = gtmValue < informativePriceValue; 86 if (hasDiscount) 87 { 88 priceBeforeDiscountFormatted = informativePrice; 89 discountPercentage = Math.Round((((gtmValue - informativePriceValue) / informativePriceValue) * 100)); 90 91 double yourProfitValue = informativePriceValue - gtmValue; 92 priceTotalDiscountFormatted = WithVATBool ? new PriceInfo { PriceWithVAT = yourProfitValue }.PriceWithVATFormatted : new PriceInfo { PriceWithoutVAT = yourProfitValue }.PriceWithoutVATFormatted; 93 } 94 } 95 96 string retailPrice = ""; 97 bool displayRetailPrice = EcommerceConfiguration.DisplayRetailPrice; 98 if (EcommerceConfiguration.DisplayRetailPriceForUsers && Pageview.User == null) 99 { 100 displayRetailPrice = false; 101 } 102 if (displayRetailPrice) 103 { 104 string priceFieldName = EcommerceConfiguration.RetailPriceField; 105 if (EcommerceConfiguration.RetailPriceIsDbPrice) 106 { 107 var p = Dynamicweb.Ecommerce.Services.Products.GetProductById(product.Id, product.VariantId, Pageview.Area.EcomLanguageId); 108 PriceContext customerPriceContext = new PriceContext(Dynamicweb.Ecommerce.Common.Context.Currency, Dynamicweb.Ecommerce.Common.Context.Country, null, null, Dynamicweb.Ecommerce.Common.Context.ReverseChargeForVatEnabled, DateTime.Now); 109 var customerPrice = p?.GetPrice(customerPriceContext); 110 if (customerPrice.Price > 0) 111 { 112 retailPrice = WithVATBool ? customerPrice.PriceWithVATFormatted : customerPrice.PriceWithoutVATFormatted; 113 } 114 } 115 else if (!string.IsNullOrWhiteSpace(priceFieldName)) 116 { 117 double customerPriceValue = 0.0; 118 if (product.ProductFields.TryGetValue(priceFieldName, out var fieldValue) && fieldValue.Value is double) 119 { 120 customerPriceValue = (double)fieldValue.Value; 121 } 122 if (customerPriceValue > 0) 123 { 124 retailPrice = WithVATBool ? new PriceInfo { PriceWithVAT = customerPriceValue }.PriceWithVATFormatted : new PriceInfo { PriceWithoutVAT = customerPriceValue }.PriceWithoutVATFormatted; 125 } 126 } 127 } 128129 // Simple variants (no variant record in this language) return the master product without VariantId, fall back to the requested variant 130 string variantId = product.VariantId; 131 string requestedVariantId = Dynamicweb.Context.Current.Request.QueryString.Get("VariantID"); 132 if (string.IsNullOrEmpty(variantId) && !string.IsNullOrEmpty(requestedVariantId) && Dynamicweb.Ecommerce.Services.VariantCombinations.GetVariantCombinations(product.Id).Any(c => c.VariantId == requestedVariantId)) 133 { 134 variantId = requestedVariantId; 135 } 136137 bool isVariant = variantId != ""; 138 int variantCount = product?.VariantInfo?.VariantInfo?.Count ?? 0; 139 bool hasVariants = !isVariant ? variantCount > 0 : false; 140141 var prod = Dynamicweb.Ecommerce.Services.Products.GetProductById(product.Id, product.VariantId, Pageview.Area.EcomLanguageId); 142 string defaultImage = Dynamicweb.Ecommerce.Services.ProductImages.GetImagePath(prod); 143144 int QuotePageID = GetPageIdByNavigationTag("QuoteForm"); 145 var buttonIconClass = Pageview.Area.Item["Global_button_icon"] != null ? Pageview.Area.Item["Global_button_icon"].ToString().Replace("+", " ") : "fal fa-arrow-right"; 146 } 147148 <!-- BEGIN Stickymenu --> 149 <section class="w-full stickymenu__replaceable__wrapper"> 150 <div class="container"> 151 <section class="stickymenu__replaceable"> 152153 <div class="stickymenu_product-info-wrapper"> 154 @if (!string.IsNullOrWhiteSpace(defaultImage)) 155 { 156 <figure class="stickymenu__product-image"> 157 <img src="/Admin/Public/GetImage.ashx?Image=@defaultImage&Crop=5&Format=webp&Quality=90&Compression=80&Height=60&Width=60" alt="@product.Name" width="60" height="60"> 158 </figure> 159 } 160 <div class="stickymenu_product-info"> 161 <p class="stickymenu__product-name"> 162 @if (!string.IsNullOrWhiteSpace(product.Manufacturer.Name)) 163 { 164 <span class="stickymenu__product-name--manufacturer">@product.Manufacturer.Name</span> 165 } 166 <span class="stickymenu__product-name--product">@product.Name</span> 167 </p> 168169 @if (displayPrice && displayProductPrice) 170 { 171 if (hasDiscount) 172 { 173 <div class="stickymenu_product__price__wrapper"> 174 <span class="stickymenu_product__price--old">@priceBeforeDiscountFormatted</span> 175 <span class="stickymenu_product__price--current">@priceFormatted</span> 176 <span class="stickymenu_product__price--suffix">@ProductdetailPriceSuffix</span> 177 <span class="stickymenu_product__price--profit">@Translate("Productdetail.YourProfitLabel", "Your profit:") @priceTotalDiscountFormatted</span> 178 </div> 179 } 180 else 181 { 182 <div class="stickymenu_product__price__wrapper"> 183 <span class="stickymenu_product__price--current">@priceFormatted</span> 184 <span class="stickymenu_product__price--suffix">@ProductdetailPriceSuffix</span> 185 </div> 186 } 187 } 188189 </div> 190 </div> 191192 @if(!hasVariants) 193 { 194 if (enableShoppingCart && enableProductShoppingCart) 195 { 196 <add-to-cart class="app-addtocart" 197 data-prodid="@product.Id" 198 data-variantid="@variantId" 199 data-min-quantity="@product.PurchaseMinimumQuantity" 200 data-step="@product.PurchaseQuantityStep" 201 data-list-id="product_detail" 202 data-list-name="Product detail"> 203 </add-to-cart> 204 } 205 else 206 { 207 if (QuotePageID > 0) 208 { 209 <div class="py-4"> 210 <a href="/Default.aspx?ID=@QuotePageID&ProdID=@product.Id&VarID=@variantId" class="btn product-detailpage__info-btn--request-quote"> 211 <span class="btn__text">@Translate("ProductDetail.StickyAddToCart.QuoteButton.Text", "Vraag een offerte aan")</span> 212 <i class="btn__icon @buttonIconClass"></i> 213 </a> 214 </div> 215 } 216 } 217 } 218219 </section> 220 </div> 221 </section> 222223 <script> 224 window.addEventListener('DOMContentLoaded', function (event) { 225 var stickyAddToCartEl = document.querySelector('.stickymenu__replaceable__wrapper'); 226 var pdpAddToCartElement = document.querySelector('.pdp-add-to-cart'); 227 var pdpQuoteButtonElement = document.querySelector('.pdp-quote-button'); 228 var scrollToTopEl = document.querySelector('#scroll-to-top'); 229230 if(pdpAddToCartElement || pdpQuoteButtonElement) { 231 var observer = new IntersectionObserver((entries, observer) => { 232 entries.forEach(entry => { 233 if(entry.intersectionRatio != 1 && window.scrollY >= entry.boundingClientRect.top) { 234 // Out of view 235 stickyAddToCartEl.classList.add('stickymenu__replaceable__wrapper--active'); 236 scrollToTopEl.classList.add('scroll-to-top--shown--lg'); 237 scrollToTopEl.style.setProperty('--sticky-bottom-offset', stickyAddToCartEl.offsetHeight + 'px'); 238 document.body.style.paddingBottom = stickyAddToCartEl.offsetHeight + 'px'; 239 } else { 240 // In view 241 stickyAddToCartEl.classList.remove('stickymenu__replaceable__wrapper--active'); 242 scrollToTopEl.classList.remove('scroll-to-top--shown--lg'); 243 scrollToTopEl.style.setProperty('--sticky-bottom-offset', '0px'); 244 document.body.style.paddingBottom = null; 245 } 246 }); 247 }, { 248 threshold: 1 249 }); 250251 if(pdpAddToCartElement) { 252 observer.observe(pdpAddToCartElement); 253 } else { 254 observer.observe(pdpQuoteButtonElement); 255 } 256257 } 258259 }); 260 </script> 261 <!-- END Stickymenu --> 262