Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_ProductPrice.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.RazorEngine_5b55fa6aaa4a4c41bcb659078bae569d.ExecuteAsync()
   at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
   at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
   at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
   at Dynamicweb.Rendering.Template.RenderRazorTemplate()

1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 @using Dynamicweb.Ecommerce.Products 4 5 @{ 6 ProductViewModel product = null; 7 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 8 { 9 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 10 } else if (!string.IsNullOrEmpty(Pageview.Page.Item["DummyProduct"]?.ToString()) && Pageview.IsVisualEditorMode) 11 { 12 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 13 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 14 15 if (productList?.Products is object) 16 { 17 product = productList.Products[0]; 18 } 19 } else if (Pageview.IsVisualEditorMode) { 20 product = new ProductViewModel(); 21 product.Price = new PriceViewModel() { 22 Price = 99, 23 PriceFormatted = "99 " + Pageview.Area.EcomCurrencyId, 24 PriceWithoutVat = 99, 25 PriceWithoutVatFormatted = "99 " + Pageview.Area.EcomCurrencyId, 26 PriceWithVat = 99, 27 PriceWithVatFormatted = "99 " + Pageview.Area.EcomCurrencyId 28 }; 29 product.PriceInformative = new PriceViewModel() { 30 Price = 49, 31 PriceFormatted = "49 " + Pageview.Area.EcomCurrencyId, 32 PriceWithoutVat = 49, 33 PriceWithoutVatFormatted = "49 " + Pageview.Area.EcomCurrencyId, 34 PriceWithVat = 49, 35 PriceWithVatFormatted = "49 " + Pageview.Area.EcomCurrencyId 36 }; 37 product.PriceBeforeDiscount = new PriceViewModel() { 38 Price = 199, 39 PriceFormatted = "199 " + Pageview.Area.EcomCurrencyId, 40 PriceWithoutVat = 199, 41 PriceWithoutVatFormatted = "199 " + Pageview.Area.EcomCurrencyId, 42 PriceWithVat = 199, 43 PriceWithVatFormatted = "99 " + Pageview.Area.EcomCurrencyId 44 }; 45 } 46 47 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 48 bool anonymousUser = Pageview.User == null; 49 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser; 50 51 bool productIsDiscontinued = product is object && product.Discontinued; 52 bool doNotShowPriceIfProductIsDiscontinued = Model.Item.GetBoolean("DoNotShowPriceIfProductIsDiscontinued"); 53 var isDiscontinued = productIsDiscontinued && doNotShowPriceIfProductIsDiscontinued; 54 55 string priceType = string.Empty; 56 if (Dynamicweb.Context.Current.Items.Contains("PriceType")) 57 { 58 priceType = Dynamicweb.Context.Current.Items["PriceType"].ToString().ToLower(); 59 } 60 } 61 62 @if (product is object && !hidePrice && !isDiscontinued && priceType != "fixedprice") { 63 bool showInformativePrice = Model.Item.GetBoolean("ShowInformativePrice"); 64 string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : string.Empty; 65 66 string priceFontSize = Model.Item.GetRawValueString("PriceSize", "fs-2"); 67 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 68 string layout = Model.Item.GetRawValueString("Layout", "horizontal"); 69 string textAlign = horizontalAlign == "center" ? "text-center" : string.Empty; 70 textAlign = horizontalAlign == "end" ? "text-end" : textAlign; 71 72 horizontalAlign = horizontalAlign == "center" && layout == "horizontal" ? "justify-content-center" : horizontalAlign; 73 horizontalAlign = horizontalAlign == "end" && layout == "horizontal" ? "justify-content-end" : horizontalAlign; 74 horizontalAlign = horizontalAlign == "center" && layout == "vertical" ? "align-items-center" : horizontalAlign; 75 horizontalAlign = horizontalAlign == "end" && layout == "vertical" ? "align-items-end" : horizontalAlign; 76 77 string flexDirection = layout == "horizontal" ? string.Empty : "flex-column"; 78 string flexGap = layout == "horizontal" ? "gap-3" : string.Empty; 79 string order = layout == "horizontal" ? string.Empty : "order-2"; 80 81 string showPricesWithVat = Dynamicweb.Ecommerce.Common.Context.DisplayPricesWithVat.ToString(); 82 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 83 84 string priceMin = ""; 85 string priceMax = ""; 86 87 <div class="@textAlign item_@Model.Item.SystemName.ToLower()" data-product-id="@product.Id" data-variant-id="@product.VariantId"> 88 @if (showInformativePrice && product.PriceInformative.Price != 0) 89 { 90 <div class="opacity-50"> 91 <span>@Translate("RRP") </span> 92 <span class="text-decoration-line-through text-price">@product.PriceInformative.PriceFormatted</span> 93 </div> 94 } 95 <div class="@priceFontSize m-0 d-flex flex-wrap @flexDirection @flexGap @horizontalAlign" style="row-gap: 0 !important" itemprop="offers" itemscope itemtype="https://schema.org/Offer"> 96 <span itemprop="priceCurrency" content="@product.Price.CurrencyCode" class="d-none"></span> 97 98 99 @if (showPricesWithVat == "false" && !neverShowVat) 100 { 101 string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceWithoutVatFormatted : product.PriceBeforeDiscount.PriceWithoutVatFormatted; 102 103 <span itemprop="price" content="@product.Price.PriceWithoutVat" class="d-none"></span> 104 if (product.Price.Price != product.PriceBeforeDiscount.Price) 105 { 106 <span class="text-decoration-line-through opacity-75 @order">@beforePrice</span> 107 } 108 } 109 else 110 { 111 string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceFormatted : product.PriceBeforeDiscount.PriceFormatted; 112 113 <span itemprop="price" content="@product.Price.Price" class="d-none"></span> 114 115 if (product.Price.Price != product.PriceBeforeDiscount.Price) 116 { 117 <span class="text-decoration-line-through opacity-75 @order"> 118 <span class="text-price">@beforePrice</span> 119 </span> 120 } 121 } 122 123 @if (showPricesWithVat == "false" && !neverShowVat) 124 { 125 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceWithoutVatFormatted : product.Price.PriceWithoutVatFormatted; 126 127 if (product?.VariantInfo?.VariantInfo != null) 128 { 129 priceMin = product?.VariantInfo?.PriceMin?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithoutVatFormatted : ""; 130 priceMax = product?.VariantInfo?.PriceMax?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithoutVatFormatted : ""; 131 } 132 if (priceMin != priceMax) 133 { 134 price = priceMin + " - " + priceMax; 135 } 136 137 <span class="text-price">@price</span> 138 } 139 else 140 { 141 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceFormatted : product.Price.PriceFormatted; 142 143 if (product?.VariantInfo?.VariantInfo != null) 144 { 145 priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted != null ? product.VariantInfo.PriceMin.PriceFormatted : ""; 146 priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted != null ? product.VariantInfo.PriceMax.PriceFormatted : ""; 147 } 148 if (priceMin != priceMax) 149 { 150 price = priceMin + " - " + priceMax; 151 } 152 153 <span class="text-price">@price</span> 154 } 155 156 @* Stock state for Schema.org, start *@ 157 @{ 158 Uri url = Dynamicweb.Context.Current.Request.Url; 159 } 160 161 <link itemprop="url" href="@url"> 162 163 @{ 164 bool IsNeverOutOfStock = product.NeverOutOfstock; 165 } 166 167 @if (IsNeverOutOfStock) 168 { 169 <span itemprop="availability" class="d-none">@Translate("Available in stock")</span> 170 } 171 else 172 { 173 if (product.StockLevel > 0) 174 { 175 <span itemprop="availability" class="d-none">InStock</span> 176 } 177 else 178 { 179 <span itemprop="availability" class="d-none">OutOfStock</span> 180 } 181 } 182 @* Stock state for Schema.org, stop *@ 183 184 </div> 185 186 @if (showPricesWithVat == "false" && !neverShowVat) 187 { 188 if (!Pageview.IsVisualEditorMode) 189 { 190 <small class="opacity-85 fst-normal js-text-price-with-vat d-none" data-suffix="@Translate("Incl. VAT")"></small> 191 } 192 else 193 { 194 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceWithVatFormatted : product.Price.PriceWithVatFormatted; 195 196 if (product?.VariantInfo?.VariantInfo != null) 197 { 198 priceMin = product?.VariantInfo?.PriceMin?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithVatFormatted : ""; 199 priceMax = product?.VariantInfo?.PriceMax?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithVatFormatted : ""; 200 } 201 if (priceMin != priceMax) 202 { 203 price = priceMin + " - " + priceMax; 204 } 205 <small class="opacity-85 fst-normal">@price @Translate("Incl. VAT")</small> 206 } 207 } 208 </div> 209 } 210 else if (Pageview.IsVisualEditorMode) 211 { 212 <div class="alert alert-dark m-0" role="alert"> 213 <span>@Translate("No products available")</span> 214 </div> 215 } 216 <script> 217 window.dataLayer.push({ 218 event: "view_item", 219 currency: "@product.Price.CurrencyCode", 220 value: @PriceViewModelExtensions.ToStringInvariant(product.Price), 221 ecommerce: { 222 items: [ 223 { 224 item_id: "@product.Number", 225 item_name: "@Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(product.Name)", 226 currency: "@product.Price.CurrencyCode", 227 price: @PriceViewModelExtensions.ToStringInvariant(product.Price) 228 } 229 ] 230 } 231 }) 232 </script> 233

Product specifications

Downloads and ressources

Related products

Hand dryers vs paper towels?

The choice between paper towels and hand dryers is about more than just comfort. It also impacts costs and the environment. With our savings calculator, you can see the expenses and potential annual savings. Try the calculator to get an overview of what makes the most sense – both for your budget and the planet.

Custom solutions

Everything starts with understanding the needs of the building and its users

Every building is unique – and so are its needs. We create hygiene solutions that align with the architecture, the people, and the way the space is used. Working with you, we see the solution through from concept to completion. So everything works – day after day.