Komponent editor til: Productpage > Right side

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

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

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

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @{ 5 ProductViewModel product = new ProductViewModel(); 6 7 ProductViewModelSettings productSetting = new ProductViewModelSettings 8 { 9 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 10 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 11 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 12 ShopId = Pageview.Area.EcomShopId 13 }; 14 15 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) { 16 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 17 } else if (Pageview.Item["DummyProduct"] != null) { 18 string dummyProductId = ""; 19 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 20 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 21 if (productList.Products != null) 22 { 23 foreach (var p in productList.Products) { dummyProductId = p.Id; } 24 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 25 product = dummyProduct; 26 } 27 else 28 { 29 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 30 } 31 } else if (Pageview.Item["DummyProduct"] == null) { 32 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 33 } 34 35 bool hideTitle = Model.Item.GetBoolean("HideTitle"); 36 37 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 38 39 string titleFontSize = Model.Item.GetRawValueString("TitleFontSize", "display-4"); 40 41 string contentPadding = Model.Item.GetRawValueString("ContentPadding", ""); 42 contentPadding = contentPadding == "small" ? "p-2 p-md-3" : contentPadding; 43 contentPadding = contentPadding == "large" ? "p-4 p-md-5" : contentPadding; 44 45 string maxWidth = Model.Item.GetRawValueString("TextReadability", "max-width-on"); 46 maxWidth = maxWidth == "max-width-on" ? "mw-75ch d-inline-block" : maxWidth; 47 maxWidth = maxWidth == "max-width-off" ? "" : maxWidth; 48 } 49 50 @if (!string.IsNullOrEmpty(product.LongDescription)) { 51 <div class="@(theme) h-100 item_@Model.Item.SystemName.ToLower()"> 52 <div class="@(contentPadding)"> 53 @if (!hideTitle && !string.IsNullOrEmpty(Model.Item.GetString("Title"))) 54 { 55 <div class="text-start pb-2 pb-lg-4"> 56 <h2 class="@titleFontSize @(maxWidth)">@Model.Item.GetString("Title")</h2> 57 </div> 58 } 59 <div class="@(maxWidth)" itemprop="description"> 60 @product.LongDescription 61 </div> 62 </div> 63 </div> 64 } else if (Pageview.IsVisualEditorMode) { 65 <div class="alert alert-dark m-0">@Translate("Long description will be shown here, if any")</div> 66 } 67
Error executing template "Designs/Swift_custom/Paragraph/Swift_ProductPrice.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_460c321638184698bc05b0d006b90bf0.Execute() in D:\dynamicweb.net\Solutions\Capo\sundqvist-new.cloud.dynamicweb-cms.com\Files\Templates\Designs\Swift_custom\Paragraph\Swift_ProductPrice.cshtml:line 49
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 Newtonsoft.Json; 4 @using Newtonsoft.Json.Linq; 5 @using System.Globalization 6 @using Dynamicweb.Ecommerce.Products; 7 @using Dynamicweb.DataIntegration.Integration.ERPIntegration; 8 <style> 9 .campaign-price { 10 color: #e32477; 11 } 12 .item_swift_productprice{ 13 margin-bottom: -7px; 14 } 15 </style> 16 17 @{ 18 ProductViewModel product = new ProductViewModel(); 19 20 21 22 ProductViewModelSettings productSetting = new ProductViewModelSettings 23 { 24 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 25 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 26 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 27 ShopId = Pageview.Area.EcomShopId, 28 29 }; 30 31 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 32 { 33 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 34 } 35 else if (Pageview.Item["DummyProduct"] != null) 36 { 37 38 string dummyProductId = ""; 39 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 40 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 41 if (productList.Products != null) 42 { 43 foreach (var p in productList.Products) { dummyProductId = p.Id; } 44 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 45 product = dummyProduct; 46 } 47 else 48 { 49 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 50 } 51 } 52 else if (Pageview.Item["DummyProduct"] == null) 53 { 54 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 55 } 56 57 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 58 bool anonymousUser = Pageview.User == null; 59 bool isErpConnectionDown = !Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); ; 60 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHidePrices") && isErpConnectionDown; 61 62 bool showInformativePrice = Model.Item.GetBoolean("ShowInformativePrice"); 63 string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : string.Empty; 64 65 string priceFontSize = Model.Item.GetRawValueString("PriceSize", "fs-2"); 66 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 67 string layout = Model.Item.GetRawValueString("Layout", "horizontal"); 68 string textAlign = horizontalAlign == "center" ? "text-center" : string.Empty; 69 textAlign = horizontalAlign == "end" ? "text-end" : textAlign; 70 71 horizontalAlign = horizontalAlign == "center" && layout == "horizontal" ? "justify-content-center" : horizontalAlign; 72 horizontalAlign = horizontalAlign == "end" && layout == "horizontal" ? "justify-content-end" : horizontalAlign; 73 horizontalAlign = horizontalAlign == "center" && layout == "vertical" ? "align-items-center" : horizontalAlign; 74 horizontalAlign = horizontalAlign == "end" && layout == "vertical" ? "align-items-end" : horizontalAlign; 75 76 string flexDirection = layout == "horizontal" ? string.Empty : "flex-column"; 77 string flexGap = layout == "horizontal" ? "gap-3" : string.Empty; 78 string order = layout == "horizontal" ? string.Empty : "order-2"; 79 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? "theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 80 theme = GetViewParameter("theme") != null ? GetViewParameterString("theme") : theme; 81 82 string contentPadding = Model.Item.GetRawValueString("ContentPadding", ""); 83 contentPadding = contentPadding == "none" ? "p-0" : contentPadding; 84 contentPadding = contentPadding == "small" ? "p-1 px-md-2 py-md-1" : contentPadding; 85 contentPadding = contentPadding == "large" ? "p-2 px-md-3 py-md-2" : contentPadding; 86 87 } 88 89 @if (!hidePrice && product.Id != null) 90 { 91 string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower(); 92 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 93 94 string priceMin = ""; 95 string priceMax = ""; 96 97 string liveInfoClass = ""; 98 string productInfoFeed = ""; 99 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 100 bool isCampaign = Dynamicweb.Core.Converter.ToBoolean(product.ProductFields["productCampaign"].Value); 101 bool isDisableAddtoCart = Pageview.AreaSettings.GetBoolean("DisableAddToCart"); 102 if (isLazyLoadingForProductInfoEnabled) 103 { 104 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 105 { 106 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 107 if (!string.IsNullOrEmpty(productInfoFeed)) 108 { 109 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 110 } 111 } 112 liveInfoClass = "js-live-info"; 113 } 114115 <div class="@textAlign @liveInfoClass item_@Model.Item.SystemName.ToLower()" data-product-id="@product.Id" @productInfoFeed> 116 @if (showInformativePrice && product.PriceInformative.Price != 0) 117 { 118 <div class="opacity-50"> 119120 <span class="text-decoration-line-through text-price">@product.PriceInformative.PriceFormatted</span> 121 </div> 122 } 123 <div class="@priceFontSize m-0 d-flex @flexDirection @flexGap @horizontalAlign" itemprop="offers" itemscope itemtype="https://schema.org/Offer"> 124 <span itemprop="priceCurrency" content="@product.Price.CurrencyCode" class="d-none"></span> 125126127 @if (showPricesWithVat == "false" && !neverShowVat) 128 { 129130 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 131 { 132 <span itemprop="price" content="" class="d-none"></span> 133 <span class="text-decoration-line-through js-text-decoration-line-through opacity-75 me-3 text-price js-text-price d-none" data-show-if="LiveProductInfo.product.Price.Price != LiveProductInfo.product.PriceBeforeDiscount.Price"></span> 134 } 135 else 136 { 137 string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceWithoutVatFormatted : product.PriceBeforeDiscount.PriceWithoutVatFormatted; 138139 <span itemprop="price" content="@product.Price.PriceWithoutVat" class="d-none"></span> 140 if (product.Price.Price != product.PriceBeforeDiscount.Price) 141 { 142 <span class="text-decoration-line-through opacity-75 @order">@beforePrice</span> 143 } 144 } 145 } 146 else 147 { 148 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 149 { 150 <span itemprop="price" content="" class="d-none"></span> 151 <span class="text-decoration-line-through js-text-decoration-line-through opacity-75 me-3 text-price js-text-price d-none" data-show-if="LiveProductInfo.product.Price.Price != LiveProductInfo.product.PriceBeforeDiscount.Price"></span> 152 } 153 else 154 { 155156 string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceFormatted : product.PriceBeforeDiscount.PriceFormatted; 157158 <span itemprop="price" content="@product.Price.Price" class="d-none"></span> 159160 if (product.Price.Price != product.PriceBeforeDiscount.Price) 161 { 162 <span class="text-decoration-line-through opacity-75 @order"> 163 <span class="text-price">@beforePrice</span> 164 </span> 165166 } 167 } 168 } 169170 @if (showPricesWithVat == "false" && !neverShowVat) 171 { 172 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 173 { 174 <span class="text-price js-text-price"> 175 <span class="spinner-border" role="status"></span> 176 </span> 177 } 178 else 179 { 180 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceWithoutVatFormatted : product.Price.PriceWithoutVatFormatted; 181182 if (product?.VariantInfo?.VariantInfo != null) 183 { 184 priceMin = product?.VariantInfo?.PriceMin?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithoutVatFormatted : ""; 185 priceMax = product?.VariantInfo?.PriceMax?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithoutVatFormatted : ""; 186 } 187 if (priceMin != priceMax) 188 { 189 price = priceMin + " - " + priceMax; 190 } 191192 if (Model.PageID == GetPageIdByNavigationTag("ProductDetailsComponent")) 193 { 194 <div> 195 <span class="fs-3 mb-1"><b>@price</b></span> 196 </div> 197 } 198 } 199 } 200 else 201 { 202 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 203 { 204 <span class="text-price js-text-price"> 205 <span class="spinner-border" role="status"></span> 206 </span> 207 } 208 else 209 { 210 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceFormatted : product.Price.PriceFormatted; 211212 if (anonymousUser) 213 { 214 // Actual system price just visually remove 00 decimals if the price is already round 215 price = product.Price.PriceWithVatFormatted.Replace(",00", ""); 216 // Perform rounding of anonymous prices that are not rounded - with custom formatting function 217 //price = App_Code.Capo_Helpers.FormatStringPriceIncExTax(product.Price.PriceWithoutVat.ToString(), true); 218219 } 220221 if (product?.VariantInfo?.VariantInfo != null) 222 { 223 priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted != null ? product.VariantInfo.PriceMin.PriceFormatted : ""; 224 priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted != null ? product.VariantInfo.PriceMax.PriceFormatted : ""; 225 } 226 if (priceMin != priceMax) 227 { 228 price = priceMin + " - " + priceMax; 229 } 230231 if (isCampaign && Model.PageID == GetPageIdByNavigationTag("ProductDetailsComponent") && !isDisableAddtoCart) 232 { 233 if (anonymousUser) 234 { 235 string productPriceConsumerOld = string.Empty; 236 productPriceConsumerOld = Dynamicweb.Core.Converter.ToString(product.ProductFields["productPriceOld"].Value); 237 string productPriceConsumerOldFormatted = App_Code.Capo_Helpers.FormatStringPriceIncExTax(productPriceConsumerOld, true); 238239 <span class="@theme @contentPadding" > 240 <span class="text-price campaign-price fs-3"><b>@price &nbsp;&nbsp;</b></span> 241 <span class="text-price text-decoration-line-through"><b>@productPriceConsumerOldFormatted</b></span> 242 </span> 243 } 244 else 245 { 246 <span class="@theme @contentPadding"> 247 <span class="text-price campaign-price fs-3">@price</span> 248 </span> 249 } 250 } 251 else 252 { 253 if (anonymousUser) 254 { 255 //Slider 256 if (isCampaign && !isDisableAddtoCart) 257 { 258 string productPriceConsumerOld = string.Empty; 259 productPriceConsumerOld = Dynamicweb.Core.Converter.ToString(product.ProductFields["productPriceOld"].Value); 260 string productPriceConsumerOldFormatted = App_Code.Capo_Helpers.FormatStringPriceIncExTax(productPriceConsumerOld, true); 261262 <span class="@theme @contentPadding" > 263 <span class="text-price campaign-price fs-3"><b>@price &nbsp;</b></span><br> 264 <span class="text-price text-decoration-line-through"><b>@productPriceConsumerOldFormatted</b></span> 265 </span> 266 } 267 else 268 { 269 <span class="@theme @contentPadding"> 270 <span class="text-price fs-3"><b>@price</b></span> 271 </span> 272 } 273 } 274 } 275 } 276 } 277278 @* Stock state for Schema.org, start *@ 279 @{ 280 Uri url = Dynamicweb.Context.Current.Request.Url; 281 } 282283 <link itemprop="url" href="@url"> 284285 @{ 286 bool IsNeverOutOfStock = product.NeverOutOfstock; 287 } 288289 @if (IsNeverOutOfStock) 290 { 291 <span itemprop="availability" class="d-none">@Translate("Available in stock")</span> 292 } 293 else 294 { 295 if (product.StockLevel > 0) 296 { 297 <span itemprop="availability" class="d-none">InStock</span> 298 } 299 else 300 { 301 <span itemprop="availability" class="d-none">OutOfStock</span> 302 } 303 } 304 @* Stock state for Schema.org, stop *@ 305306 </div> 307308 @*// stackedPrices for logged in users only and not working in visual editor mode*@ 309 @*Stacked prices logic will not be used initially with bc. Keeping this uncommend for later.*@ 310 @*@if (!Pageview.IsVisualEditorMode && !anonymousUser && product.Id != null) 311 { 312 object pricesJSON; 313 var prodID = product.Id.ToString(); 314 var prod = Dynamicweb.Ecommerce.Services.Products.GetProductById(prodID, "", true); 315 var user = Pageview.User; 316 var settings = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Configuration.SettingsManager.GetSettingsByShop(Pageview.Area.EcomShopId); 317 var productInfo = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products.ProductManager.GetProductInfo(prod, settings, user); 318319 try 320 { 321 //Handle any errors by assigning an empty object if value is not found 322 productInfo.TryGetValue("stackedPricesData", out pricesJSON); 323324 } 325 catch (Exception) 326 { 327 //return; // Cant do a return here as it will exit the whole template rendering and for example not render the "Rek. pris" logik below at all 328 pricesJSON = null; // Must assign to null otherwise error on the if statement below 329 } 330331 // Override of Stacked prices JSON for easy development/test of rendering 332 //pricesJSON = @"[ 333 // { 334 // 'quantity':'4', 335 // 'price':'767.52' 336 // }, 337 // { 338 // 'quantity':'10', 339 // 'price':'697.06' 340 // }, 341 // { 342 // 'quantity':'100', 343 // 'price':'540.85' 344 // } 345 //]"; 346347 if (pricesJSON != null && pricesJSON.ToString() != string.Empty ) 348 { 349350 try 351 { 352 // Last bracket is sent in NAV response but lost in the string here 353 JArray pricesArray = JArray.Parse(pricesJSON.ToString() + "]"); 354355 <div class="d-block"> 356 @Translate("discontPricingTable", "Mängdrabatt - styckpris vid köp av minst:") 357 </div> 358359 <div class="bracket-price" data-id="@product.Number.ToString()"> 360361 @foreach (dynamic priceLine in pricesArray) 362 { 363 double culturePrice = Convert.ToDouble(priceLine.price); 364365 <div> 366 <span class="campaign-price"> 367 @priceLine.quantity @Translate("Unit", "St") @Dynamicweb.Ecommerce.Common.Context.Currency.Format(culturePrice) 368 </span> 369 </div> 370 } 371372 </div> 373374 } 375 catch 376 { 377 if (Dynamicweb.Frontend.PageView.Current().Page.NavigationTag == "ProductDetailPage") { 378 <p class="campaign-price">@Translate("StackedPricesBadDataFormatMessage", "Kontakta oss för information om mängdrabatter.")</p> 379 } 380 } 381 } 382383 }*@ 384385386 @if (showPricesWithVat == "false" && !neverShowVat) 387 { 388 string productPriceConsumerOld = string.Empty; 389 string productPriceConsumer = string.Empty; 390391 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 392 { 393 <small class="opacity-85 fst-normal js-text-price-with-vat d-none" data-suffix="@Translate("Incl. VAT")"></small> 394 } 395 else 396 { 397 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceWithVatFormatted : product.Price.PriceWithVatFormatted; 398399 if (!anonymousUser) 400 { 401 productPriceConsumerOld = App_Code.Capo_Helpers.FormatStringPriceIncExTax(Dynamicweb.Core.Converter.ToString(product.ProductFields["productPriceOld"].Value), true); 402403 productPriceConsumer = App_Code.Capo_Helpers.GetDbPrice(product.Id, "ProductPrice"); 404 productPriceConsumer = App_Code.Capo_Helpers.FormatStringPriceIncExTax(productPriceConsumer.ToString(), true); 405 } 406407 if (product?.VariantInfo?.VariantInfo != null) 408 { 409 priceMin = product?.VariantInfo?.PriceMin?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithVatFormatted : ""; 410 priceMax = product?.VariantInfo?.PriceMax?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithVatFormatted : ""; 411 } 412 if (priceMin != priceMax) 413 { 414 price = priceMin + " - " + priceMax; 415416 } 417 if (isCampaign && (Model.PageID == @GetPageIdByNavigationTag("ProductDetailsComponent") || Dynamicweb.Frontend.PageView.Current().Page.NavigationTag == "ProductDetailPage")) 418 { 419 <span class="my-2 d-inline-block d-flex"> 420 @Translate("RRP", "Rek. konsumentpris (inkl moms): ") 421 <text class="opacity-85 fst-normal campaign-price">@productPriceConsumer&nbsp;</text> 422 <text class="opacity-85 fst-normal text-decoration-line-through">@productPriceConsumerOld</text> 423 </span> 424 } 425 else 426 { 427428 if (Model.PageID == @GetPageIdByNavigationTag("ProductDetailsComponent") || Dynamicweb.Frontend.PageView.Current().Page.NavigationTag == "ProductDetailPage") 429 { 430 <div class="my-2" style="white-space: pre"> 431 @Translate("RRP", "Rek. konsumentpris (inkl moms): ") 432 <small class="opacity-85 fst-normal">@productPriceConsumer</small> 433 </div> 434 } 435 else 436 { 437438 if (!anonymousUser) 439 { 440 <div class="my-2"> 441 <span class="text-price fs-3"><b>@product.GetPrice(unitId).Price.PriceWithoutVat.ToString()</b></span> 442 </div> 443 } 444 else 445 { 446 <div class="text-uppercase my-2 "> 447 <span class="text-price fs-3"><b>@App_Code.Capo_Helpers.FormatStringPriceIncExTax(price, true)</b></span> 448 </div> 449 } 450 } 451 } 452 } 453 } 454 </div> 455 } 456 else if (Pageview.IsVisualEditorMode) 457 { 458 <div class="alert alert-dark m-0" role="alert"> 459 <span>@Translate("No products available")</span> 460 </div> 461 } 462