Error executing template "Designs/Junget/eCom/Productlist/productlist.cshtml"
System.NullReferenceException: Object reference not set to an instance of an object.
at CompiledRazorTemplates.Dynamic.RazorEngine_3ae66cb625144589abc01a35ec5844d1.Execute() in D:\Web\Junget\Website\Files\Templates\Designs\Junget\eCom\Productlist\productlist.cshtml:line 1587
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 @using System.Web
2 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
3
4 @{
5 var query = HttpContext.Current.Request;
6 var pathName = GetGlobalValue("Global:Pageview.Url");
7 if (pathName.IndexOf("?") != -1)
8 {
9 pathName = pathName.Substring(0, pathName.IndexOf("?"));
10 }
11
12 string prevPage = !string.IsNullOrWhiteSpace(GetString("Ecom:ProductList.PrevPage.Clean")) ? GetString("Ecom:ProductList.PrevPage.Clean") : "";
13 string nextPage = !string.IsNullOrWhiteSpace(GetString("Ecom:ProductList.NextPage.Clean")) ? GetString("Ecom:ProductList.NextPage.Clean") : "";
14 var facetGroup = GetLoop("FacetGroups");
15 var products = GetLoop("Products");
16 var pageService = new Dynamicweb.Content.PageService();
17 var pages = pageService.GetPagesForItems(new string[] { "PageShopList" }).Where(p => p.AreaId == Pageview.AreaID);
18 }
19
20 @using Dynamicweb.Ecommerce
21 @using Dynamicweb.Ecommerce.Products
22 @using Dynamicweb.Security.UserManagement;
23 @using Helpers = Website.Helpers;
24 @using VestjyskMarketing.Models;
25
26 @inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>
27 @functions {
28
29 string DiscountPct(LoopItem context = null) {
30 double oldPrice = 0;
31 double price = 0;
32 double discount = 0;
33
34 string inputdiscountPrice = (context != null ? context.GetString("Ecom:Product.Discount.AmountWithVAT") : GetString("Ecom:Product.Discount.AmountWithVAT"));
35 string inputprice = (context != null ? context.GetString("Ecom:Product.Price.Price") : GetString("Ecom:Product.Price.Price"));
36
37 double.TryParse( inputprice, out oldPrice);
38 double.TryParse( inputdiscountPrice, out price);
39
40 double difference = ( oldPrice - price );
41 discount = Math.Round((difference / oldPrice) * 100);
42
43 return discount.ToString();
44 }
45
46 string DiscountDiff(LoopItem context = null) {
47 double oldPrice = 0;
48 double price = 0;
49
50 var inputdiscountPrice = (context != null ? context.GetString("Ecom:Product.Discount.AmountWithVAT") : GetString("Ecom:Product.Discount.AmountWithVAT"));
51 var inputprice = (context != null ? context.GetString("Ecom:Product.Price.Price") : GetString("Ecom:Product.Price.Price"));
52
53 double.TryParse( inputprice, out oldPrice);
54 double.TryParse( inputdiscountPrice, out price);
55
56 double difference = ( oldPrice - price );
57
58 return SliceCommas(difference.ToString());
59 }
60
61 string OldPrice(LoopItem context = null, LoopItem product = null) {
62 double oldPrice = 0;
63 double price = 0;
64
65 var inputdiscountPrice = (context != null ? context.GetString("Ecom:Product.Discount.AmountWithVAT") : GetString("Ecom:Product.Discount.AmountWithVAT"));
66 var inputprice = (product != null ? product.GetString("Ecom:Product.Price.Price") : GetString("Ecom:Product.Price.Price"));
67
68 double.TryParse( inputprice, out oldPrice);
69 double.TryParse( inputdiscountPrice, out price);
70
71 double difference = ( oldPrice + price );
72
73 return SliceCommas(difference.ToString());
74 }
75
76 string SliceCommas(string givenPrice) {
77 // We remove everything after comma, if the Discount-Handler calculates it differently, however the price in the cart is with comma values *@
78 string price = givenPrice;
79 int index = price.LastIndexOf(',');
80
81 if(index > -1) {
82 price = price.Substring(0, index) + ",-";
83 }
84 else {
85 price = price + ",-";
86 }
87
88 return price.ToString();
89 }
90
91 string ChangeAttribute(string input, string format) {
92 if(!String.IsNullOrEmpty(input) && input == "checked") {
93 return format;
94 }
95 else if(!String.IsNullOrEmpty(input) && Convert.ToBoolean(input)) {
96 return format;
97 }
98 return null;
99 }
100
101 }
102
103
104 @helper ContentRenderingNew(LoopItem item, string loopName, bool isSmallSpot = false, string productUrl = "", bool checkoutPage = false)
105 {
106 User mainUserHeader = Pageview.User?.CurrentSecondaryUser != null ? Pageview.User.CurrentSecondaryUser : Pageview.User;
107
108 //set URL for page. To get correct URL all places in regards to list
109 //fetch pages from shop
110 var pageService = new Dynamicweb.Content.PageService();
111 var pages = pageService.GetPagesForItems(new string[] { "PageShopList" }).Where(p => p.AreaId == Pageview.AreaID);
112 string productPrice = GetString("Ecom:Product.Price.PriceWithoutVATFormatted").Replace(",00", ",-");
113 var group = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(item.GetString("Ecom:Product.PrimaryOrFirstGroupID"));
114 int pageId = 0;
115 foreach (var page in pages)
116 {
117 var shopGroupPage = Dynamicweb.Core.Converter.ToString(page.Item["ShopCategoryNumber"]);
118 if (shopGroupPage == group.Number && page.AreaId.Equals(Pageview.AreaID))
119 {
120 pageId = page.ID;
121 break;
122 }
123 }
124
125 productUrl = "/Default.aspx?ID=" + pageId + "&ProductID=" + item.GetString("Ecom:Product.ID");
126 if (pageId == 0)
127 {
128 productUrl = item.GetString("Ecom:Product.Link.Clean");
129 }
130
131 // Images
132 string grpId = string.Empty;
133 string grpQtyDiscount5 = string.Empty;
134 string grpQtyDiscount10 = string.Empty;
135
136 foreach (LoopItem subItem in item.GetLoop("AssociatedGroups"))
137 {
138 grpId = subItem.GetString("Ecom:Group.ID");
139 }
140
141 if (!string.IsNullOrEmpty(grpId))
142 {
143 var productApi = Dynamicweb.Ecommerce.Services.Products.GetProductById(item.GetString("Ecom:Product.ID"), null, false);
144 double minQuantity = item.GetDouble("Ecom:Product.PurchaseMinimumQuantity");
145 if (minQuantity < 1)
146 {
147 minQuantity = 1;
148 }
149
150 double quantityStep = item.GetDouble("Ecom:Product.PurchaseQuantityStep");
151 if (quantityStep < 1)
152 {
153 quantityStep = 1;
154 }
155
156 bool internalProduct = item.GetBoolean("Ecom:Product:Field.InternalProduct");
157 bool webshopOK = item.GetBoolean("Ecom:Product:Field.WebshopOK");
158 string productName = item.GetString("Ecom:Product.Name");
159 string productImage = Website.Helpers.Product.GetMainProductImage(productApi);
160 if (String.IsNullOrEmpty(productImage))
161 {
162 productImage = "/Files/System/Images/Shop/na-image.jpg";
163 }
164
165 var deleteLink = item.GetString("Ecom:Order:OrderLine.DeleteLink");
166 var newDeleteLink = deleteLink;
167 if (!string.IsNullOrEmpty(deleteLink) && deleteLink.ToLower().Contains("&productid"))
168 {
169 var deleteLinkParts = deleteLink.ToLowerInvariant().Split('&');
170 var productItemPart = deleteLinkParts.FirstOrDefault(p => p.Contains("productid"));
171 var productId = item.GetString("Ecom:Product.ID");
172 deleteLinkParts[Array.IndexOf(deleteLinkParts, productItemPart)] = "productid=" + productId;
173 newDeleteLink = string.Join("&", deleteLinkParts);
174 }
175
176 int jungStockAmount = Dynamicweb.Core.Converter.ToInt32(item.GetString("Ecom:Product:Field.jung_stock").Replace("D", ""));
177 string productFabrikat = item.GetString("Ecom:Product:Field.fabrikat").ToLower();
178
179 string image = VestjyskMarketing.Helpers.ImageHelper.ResizeImage(new ResizeImageSettings()
180 {
181 Image = "/Files/Files/Images/img_calculator.png",
182 Height = 96,
183 Width = 96,
184 Quality = 85
185 });
186
187 //get campaign name
188 string campaignName = "";
189 var prices = productApi.Prices;
190 double oldPrice = 0;
191 string oldPriceCurrency = "";
192
193
194 foreach (var priceFromMatrix in prices)
195 {
196 if (priceFromMatrix.Amount == item.GetDouble("Ecom:Product.Price.PriceWithoutVAT.Value") && Helpers.Product.IsCampaingPrice(priceFromMatrix)
197 && Helpers.Product.IsPriceValid(priceFromMatrix))
198 {
199 campaignName = priceFromMatrix.Periods.FirstOrDefault()?.Name;
200 foreach (var priceFromMatrix2 in prices)
201 {
202 if (priceFromMatrix2.Amount != item.GetDouble("Ecom:Product.Price.PriceWithoutVAT.Value") &&
203 !Helpers.Product.IsCampaingPrice(priceFromMatrix2) && Helpers.Product.IsPriceValid(priceFromMatrix2))
204 {
205 if (Pageview.Area.EcomCurrencyId == priceFromMatrix2.CurrencyCode)
206 {
207 oldPrice = priceFromMatrix2.Amount;
208 oldPriceCurrency = priceFromMatrix2.CurrencyCode;
209 break;
210 }
211 }
212 }
213 }
214 }
215
216 //has to be done like this and not tags. tags will make more calls via live integrayion.
217 bool hasCombinations = productApi.VariantCombinations.Any();
218
219 var smallSpotClasses = "product-item__price";
220
221 if (isSmallSpot)
222 {
223 smallSpotClasses = "text-success font-weight-bold ml-auto";
224
225 if (checkoutPage)
226 {
227 <a href="@item.GetString("Ecom:Order:OrderLine.DeleteLink")" class="product-item__closebtn btn p-0">
228 <span class="icon icon-close m-0"></span>
229 </a>
230 }
231 else
232 {
233 <a href="#" class="product-item__closebtn btn js-product-state-submit p-0" data-action="@newDeleteLink">
234 <span class="icon icon-close m-0"></span>
235 </a>
236 }
237 }
238
239 if (!string.IsNullOrEmpty(campaignName))
240 {
241 string discountImage = ""; //@TODO hvad skal vi gøre med billeder?
242 bool blackFriday = false; //@TODO hvad skal vi gøre med black friday?
243
244 if (!String.IsNullOrEmpty(discountImage))
245 {
246 <div class="product-item__badge image-badge">
247 <img src="@discountImage" alt="Kampagne billede" width="150px"/>
248 </div>
249 }
250 else if (blackFriday)
251 {
252 <div class="product-item__badge blackfriday-badge text-uppercase">@Translate("ecom-campaigne-blackfriday", "Black Friday")</div>
253 }
254 else
255 {
256 //old campaign
257 @*<div class="product-item__badge text-uppercase">@Translate("Campaign-" + campaignName, campaignName)</div>*@
258 }
259 }
260
261 if (internalProduct && !webshopOK)
262 {
263 <div class="product-item__badge image-badge">
264 <img src="/Files/System/Images/Shop/Webshop_logo_intern.jpg" alt="Internt produkt" height="50px"/>
265 </div>
266 }
267
268 <div class="d-flex flex-column result-item__product-content w-100">
269 @if (loopName == "Products" || loopName == "Item.ProductDisplay")
270 {
271 <picture class="product-item__photo d-flex justify-content-center" onclick="window.location = '@productUrl';" style="cursor:pointer">
272 <!--
273 <source srcset="/Admin/Public/GetImage.ashx?Image=@productImage&width=146&height=128&background=ffffff&format=webP&Compression=99&fillcanvas=true" media="(min-width: 576px)">
274
275 -->
276 <img class="img-fluid" src="/Admin/Public/GetImage.ashx?Image=@productImage&width=345&height=300&background=ffffff&format=webP&Compression=99&fillcanvas=true" alt="@productName">
277 </picture>
278 }
279 <div class="d-flex mb-3 mt-3 flex-row" style="height: 110px; justify-content: center;">
280 <div class="w-100 d-flex flex-column justify-content-center" onclick="window.location = '@productUrl';" style="cursor:pointer">
281 <div style="font-size: 13px; padding: 5px; text-align: center; line-height: 15px; line-break: auto " class="product-item__title m-0 p-0">@productName</div>
282
283 <div class="d-flex justify-content-center">
284 <div class="product-item__description d-flex mt-2" style="justify-content: center; width: max-content; font-size: 12px">
285 @Translate("ProductNumber", "Varenummer") @item.GetString("Ecom:Product.Number")
286 @if ((jungStockAmount > 0 && jungStockAmount < 3) || item.GetInteger("Ecom:Product.Stock") > 0)
287 {
288 <svg style="margin-left: 10px" height="20" width="20"> <circle cx="8" cy="8" r="6" stroke="#92D053" stroke-width="3" fill="#92D053"/> Sorry, your browser does not support inline SVG. </svg>
289 }
290 </div>
291 </div>
292 <div class="product-item__delivery-time" style="font-size: 12px; text-align: center">
293 @Helpers.Product.GetJungStock(item.GetString("Ecom:Product:Field.jung_stock"), item.GetInteger("Ecom:Product.Stock"))
294 </div>
295
296
297 @if (mainUserHeader != null && mainUserHeader.HasGroup(24))
298 {
299 <span class="d-flex justify-content-center">
300
301 (@item.GetInteger("Ecom:Product.Stock") @Translate("stk."))
302 </span>
303 }
304
305 @{
306 if (minQuantity > 1)
307 {
308 <div class="d-flex" style="justify-content: center; font-size: 12px">
309 <strong> @Translate("Minimumskøb:", "Minimumskøb:") @minQuantity @Translate("stk.")</strong>
310 </div>
311 }
312 }
313 @foreach (LoopItem subItem in item.GetLoop("Order.OrderLineFields"))
314 {
315 <div class="product-item__description">
316 @if (subItem.GetString("Ecom:Order:OrderLine.OrderLineField.SystemName") == "DeliveryPromised")
317 {
318 @subItem.GetString("Ecom:Order:OrderLine.OrderLineField.Value")
319 }
320 else if (subItem.GetString("Ecom:Order:OrderLine.OrderLineField.SystemName") == "customSizeAdded")
321 {
322 @Translate("customSize", "Størrelse")
323 @subItem.GetString("Ecom:Order:OrderLine.OrderLineField.Value")<span>mm</span>
324 }
325 </div>
326 }
327 </div>
328
329 </div>
330
331 <div>
332
333 <div class="d-flex mb-2" style="justify-content: space-evenly; align-items: center">
334 <input type="hidden" name="ProdId" class="js-reorder-product-id" value="@item.GetString("Ecom:Product.ID")"/>
335 @if (loopName != "Products" && loopName != "Item.ProductDisplay")
336 {
337 <div class="input-group product-item__quantity-wrapper">
338 <span class="input-group-btn">
339 @if (checkoutPage)
340 {
341 <a href="@item.GetString("Ecom:Order:OrderLine.DecrementLink")" role="button" class="btn btn-buy d-inline-flex align-items-center justify-content-center">
342 <span class="icon icon-minus"></span>
343 </a>
344 }
345 else
346 {
347 <a href="#" role="button" class="btn btn-buy d-inline-flex align-items-center justify-content-center js-product-state-submit" data-action="@item.GetString("Ecom:Order:OrderLine.DecrementLink")">
348 <span class="icon icon-minus"></span>
349 </a>
350 }
351 </span>
352 <input id="Quantity" type="text" autocomplete="off" class="form-control js-quantity-input text-center" name="Quantity" min="@minQuantity" value="@item.GetString("Ecom:Order:OrderLine.Quantity")" data-step="@quantityStep" data-type="order">
353 <span class="input-group-btn">
354 @if (checkoutPage)
355 {
356 <a href="@item.GetString("Ecom:Order:OrderLine.IncrementLink")" role="button" class="btn btn-buy d-inline-flex align-items-center justify-content-center">
357 <span class="icon icon-plus"></span>
358 </a>
359 }
360 else
361 {
362 <a href="#" role="button" class="btn btn-buy d-inline-flex align-items-center justify-content-center js-product-state-submit" data-action="@item.GetString("Ecom:Order:OrderLine.IncrementLink")">
363 <span class="icon icon-plus"></span>
364 </a>
365 }
366
367 </span>
368 </div>
369 }
370 else if (!hasCombinations)
371 {
372 <div class="input-group product-item__quantity-wrapper d-md-none">
373 <span class="input-group-btn">
374 <button class="btn btn-buy js-reorder-quantity-subtract" type="button">
375 <span class="icon icon-minus"></span>
376 </button>
377 </span>
378 <input type="text" autocomplete="off" class="form-control js-reorder-quantity-input text-center" name="Quantity" min="0" max="20" value="1">
379 <span class="input-group-btn">
380 <button class="btn btn-buy js-reorder-quantity-add" type="button">
381 <span class="icon icon-plus"></span>
382 </button>
383 </span>
384 </div>
385 }
386
387
388 @if (productFabrikat != "leitz")
389 {
390 <div class="@smallSpotClasses" onclick="window.location = '@productUrl';" style="cursor:pointer">
391 @if (!String.IsNullOrEmpty(campaignName) && oldPrice > 0 && !User.IsExtranetUserLoggedIn())
392 {
393 @*<div class="product-details__price-container">
394 @if (hasCombinations && loopName != "OrderLines")
395 {
396 <div class="from-price">@Translate("ProductFromPrice", "Fra")</div>
397 }
398 <div>@item.GetString("Ecom:Product.Price.PriceWithoutVATFormatted").Replace(",00", ",-")</div>
399 <div class="product-item__price--old">DKK @oldPrice,-</div>
400 </div>*@
401
402
403 <div class="without-discount d-flex flex-column align-items-center" style="font-size: 17px; line-height: 1.2">
404 @if (loopName == "OrderLines")
405 {
406 @item.GetString("Ecom:Order:OrderLine.UnitPrice.PriceWithoutVATFormatted").Replace(",00", ",-")
407 }
408 else
409 {
410 <div class="without-discount d-flex flex-column align-items-center">
411 @if (hasCombinations && loopName != "OrderLines")
412 {
413 @Translate("ProductFromPrice", "Fra")
414 }
415
416 @item.GetString("Ecom:Product.Price.PriceWithoutVATFormatted").Replace(",00", ",-")
417
418 <div class="product-item__price--old m-0 text-center" style="font-size: 11px; color: #68943c">@oldPriceCurrency @oldPrice,-</div>
419 </div>
420 }
421 </div>
422 }
423
424 else
425 {
426 <div class="without-discount d-flex flex-column align-items-center" style="font-size: 17px; line-height: 1.2">
427 @if (loopName == "OrderLines")
428 {
429 @item.GetString("Ecom:Order:OrderLine.UnitPrice.PriceWithoutVATFormatted").Replace(",00", ",-")
430 }
431 else
432 {
433 <div class="d-flex">
434 @if (hasCombinations && loopName != "OrderLines")
435 {
436 @Translate("ProductFromPrice", "Fra")<span> </span>
437 }
438
439 <div data-id="@item.GetString("Ecom:Product.ID")" data-variantid='@(hasCombinations ? "variantid" : "")' class="lazyload-price lazyload-price-vat">
440 <span>
441 @item.GetString("Ecom:Product.Price.PriceWithoutVATFormatted").Replace(",00", ",-")
442 </span>
443 <img src="/Files/Images/loading.gif">
444 </div>
445 </div>
446 <div class="item__container__info__no-vat">(@Translate("ecom-price-excl-vat", ""))</div>
447 }
448 </div>
449 }
450 </div>
451 }
452 else if (User.IsExtranetUserLoggedIn())
453 {
454 <div class="@smallSpotClasses" onclick="window.location = '@productUrl';" style="cursor:pointer">
455
456 @if (hasCombinations && loopName != "OrderLines")
457 {
458 <div class="from-price without-discount">@Translate("ProductFromPrice", "Fra")</div>
459 }
460
461 <div class="without-discount d-flex flex-column align-items-center" style="font-size: 17px; line-height: 1.2">
462 @if (loopName == "OrderLines")
463 {
464 @item.GetString("Ecom:Order:OrderLine.UnitPrice.PriceWithoutVATFormatted").Replace(",00", ",-")
465 }
466 else
467 {
468 <div data-id="@item.GetString("Ecom:Product.ID")" data-variantid='@(hasCombinations ? "variantid" : "")' class="lazyload-price lazyload-price-vat">
469 <span>
470 @item.GetString("Ecom:Product.Price.PriceWithoutVATFormatted").Replace(",00", ",-")
471 </span>
472 <img src="/Files/Images/loading.gif">
473 </div>
474 }
475 <div class="item__container__info__no-vat">(@Translate("ecom-price-excl-vat", ""))</div>
476 </div>
477
478
479 </div>
480 }
481
482 @if (loopName == "Products" || loopName == "Item.ProductDisplay")
483 {
484 if (productFabrikat != "leitz" || User.IsExtranetUserLoggedIn())
485 {
486 <div class="d-inline-block no-wrap flex-row">
487 @if (!hasCombinations)
488 {
489 <button type="submit" class="js-reorder-add-to-basket w-100 btn btn-sm btn-success align-self-end d-md-none ml-auto">
490 <span class="icon icon-cart"></span>
491 </button>
492 }
493 else
494 {
495 <button type="submit" class="w-100 btn btn-sm btn-success align-self-end d-md-none ml-auto" onclick="window.location = '@productUrl';">
496 <span class="icon icon-cart"></span>
497 </button>
498 }
499 <button type="button" class="btn btn-success align-self-end d-none d-md-flex px-4" onclick="window.location = '@productUrl';">
500 <div class="d-flex flex-row">
501 <span class="icon icon-shopping-cart mr-2" style="font-size: 14px"></span>
502 </div>@Translate("BESTIL")
503 </button>
504
505
506 </div>
507 }
508 else
509 {
510 <div class="d-flex">
511
512 <div class="align-self-end d-none d-md-inline-block px-4" style="font-size: 12px">@Translate("Log ind for at se prisen")</div>
513
514 <button type="button" class="btn btn-success align-self-end d-md-inline-block js-aside-btn px-4" href="#" data-view="login">@Translate("HeaderLoginButton", "Login")</button>
515 </div>
516 }
517 }
518 </div>
519
520 @if (mainUserHeader != null && mainUserHeader.HasGroup(24) && !isSmallSpot)
521 {
522 string salesPrice = item.GetDouble("Ecom:Product.DBPrice").ToString("F2");
523 string webPrice = salesPrice;
524 string webDiscount = Dynamicweb.Core.Converter.ToString(productApi.GetProductFieldValue("WebDiscount"));
525 string cost = Dynamicweb.Core.Converter.ToString(productApi.Cost);
526 string externalNumber = Dynamicweb.Core.Converter.ToString(productApi.GetProductFieldValue("ExterntNummer"));
527 string manufacturer = productApi.Manufacturer != null ? productApi.Manufacturer.Name : "";
528 string discountGroup = Dynamicweb.Core.Converter.ToString(productApi.GetProductFieldValue("ItemDiscGroup"));
529
530 foreach (var priceFromMatrix in productApi.Prices)
531 {
532 if (Helpers.Product.IsPriceValid(priceFromMatrix))
533 {
534 var userToTakePriceFrom = Pageview.User;
535
536 if (!string.IsNullOrEmpty(userToTakePriceFrom.Currency) && priceFromMatrix.CurrencyCode == userToTakePriceFrom.Currency)
537 {
538 webPrice = priceFromMatrix.Amount.ToString("F2");
539 }
540
541 if (priceFromMatrix.CurrencyCode == "DKK" && string.IsNullOrEmpty(userToTakePriceFrom.Currency))
542 {
543 webPrice = priceFromMatrix.Amount.ToString("F2");
544 }
545 }
546 }
547
548 <div class="d-flex justify-content-between align-items-end mt-3">
549 <div>
550 <div class="text-center" style="margin-left: 10px; font-size: 12px;">
551 @Translate("Bruttopris", "Bruttopris") @salesPrice
552 </div>
553
554 <div class="text-center" style="margin-left: 8px; font-size: 12px;">
555 @Translate("Webpris", "Webpris") @webPrice
556 </div>
557 </div>
558 <div class="product-item__details">
559 <img src="@image" class="product-item__details__image">
560 <div class="product-item__details__tooltip">
561 <div class="row">
562 <div class="col-7">
563 @Translate("Bruttopris", "Bruttopris"):
564 </div>
565 <div class="col-5">
566 @salesPrice
567 </div>
568 <div class="col-7">
569 @Translate("Webrabat", "Webrabat") %:
570 </div>
571 <div class="col-5">
572 @webDiscount
573 </div>
574 <div class="col-7">
575 @Translate("Webpris", "Webpris"):
576 </div>
577 <div class="col-5">
578 @webPrice
579 </div>
580 <div class="col-7">
581 @Translate("Cost", "Kostpris"):
582 </div>
583 <div class="col-5">
584 @cost
585 </div>
586 <div class="col-7">
587 @Translate("Manufacturer's number", "Leverandørens varenr"):
588 </div>
589 <div class="col-5">
590 @externalNumber
591 </div>
592 <div class="col-7">
593 @Translate("Manufacturer", "Levenrandør"):
594 </div>
595 <div class="col-5">
596 @manufacturer
597 </div>
598 <div class="col-7">
599 @Translate("DiscountGroup", "Varerabatgruppe"):
600 </div>
601 <div class="col-5">
602 @discountGroup
603 </div>
604 </div>
605 </div>
606 </div>
607 </div>
608 }
609 </div>
610 </div>
611 }
612 }
613
614 @helper ContentRendering(LoopItem item, string loopName, bool isSmallSpot = false, string productUrl = "", bool checkoutPage = false)
615 {
616 User mainUserHeader = Pageview.User?.CurrentSecondaryUser != null ? Pageview.User.CurrentSecondaryUser : Pageview.User;
617
618 //set URL for page. To get correct URL all places in regards to list
619 //fetch pages from shop
620 var pageService = new Dynamicweb.Content.PageService();
621 var pages = pageService.GetPagesForItems(new string[] { "PageShopList" }).Where(p => p.AreaId == Pageview.AreaID);
622 string productPrice = GetString("Ecom:Product.Price.PriceWithoutVATFormatted").Replace(",00", ",-");
623 var group = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(item.GetString("Ecom:Product.PrimaryOrFirstGroupID"));
624 int pageId = 0;
625 foreach (var page in pages)
626 {
627 var shopGroupPage = Dynamicweb.Core.Converter.ToString(page.Item["ShopCategoryNumber"]);
628 if (shopGroupPage == group.Number && page.AreaId.Equals(Pageview.AreaID))
629 {
630 pageId = page.ID;
631 break;
632 }
633 }
634
635 productUrl = "/Default.aspx?ID=" + pageId + "&ProductID=" + item.GetString("Ecom:Product.ID");
636 if (pageId == 0)
637 {
638 productUrl = item.GetString("Ecom:Product.Link.Clean");
639 }
640
641 // Images
642 string grpId = string.Empty;
643 string grpQtyDiscount5 = string.Empty;
644 string grpQtyDiscount10 = string.Empty;
645
646 foreach (LoopItem subItem in item.GetLoop("AssociatedGroups"))
647 {
648 grpId = subItem.GetString("Ecom:Group.ID");
649 }
650
651 if (!string.IsNullOrEmpty(grpId))
652 {
653 var productApi = Dynamicweb.Ecommerce.Services.Products.GetProductById(item.GetString("Ecom:Product.ID"), null, false);
654 double minQuantity = item.GetDouble("Ecom:Product.PurchaseMinimumQuantity");
655 if (minQuantity < 1)
656 {
657 minQuantity = 1;
658 }
659
660 double quantityStep = item.GetDouble("Ecom:Product.PurchaseQuantityStep");
661 if (quantityStep < 1)
662 {
663 quantityStep = 1;
664 }
665
666 bool internalProduct = item.GetBoolean("Ecom:Product:Field.InternalProduct");
667 bool webshopOK = item.GetBoolean("Ecom:Product:Field.WebshopOK");
668 string productName = item.GetString("Ecom:Product.Name");
669 string productImage = Website.Helpers.Product.GetMainProductImage(productApi);
670 if (String.IsNullOrEmpty(productImage))
671 {
672 productImage = "/Files/System/Images/Shop/na-image.jpg";
673 }
674
675 var deleteLink = item.GetString("Ecom:Order:OrderLine.DeleteLink");
676
677 var newDeleteLink = deleteLink;
678 if (!string.IsNullOrEmpty(deleteLink) && deleteLink.ToLower().Contains("&productid"))
679 {
680 var deleteLinkParts = deleteLink.ToLowerInvariant().Split('&');
681 var productItemPart = deleteLinkParts.FirstOrDefault(p => p.Contains("productid"));
682 var productId = item.GetString("Ecom:Product.ID");
683 deleteLinkParts[Array.IndexOf(deleteLinkParts, productItemPart)] = "productid=" + productId;
684 newDeleteLink = string.Join("&", deleteLinkParts);
685 }
686
687 int jungStockAmount = Dynamicweb.Core.Converter.ToInt32(item.GetString("Ecom:Product:Field.jung_stock").Replace("D", ""));
688 string productFabrikat = item.GetString("Ecom:Product:Field.fabrikat").ToLower();
689
690 //get campaign name
691 string campaignName = "";
692 var prices = productApi.Prices;
693 foreach (var priceFromMatrix in productApi.Prices)
694 {
695 if (priceFromMatrix.Amount == item.GetDouble("Ecom:Product.Price.PriceWithoutVAT.Value"))
696 {
697 campaignName = priceFromMatrix.Periods.FirstOrDefault()?.Name;
698 }
699 }
700
701 //has to be done like this and not tags. tags will make more calls via live integrayion.
702 bool hasCombinations = productApi.VariantCombinations.Any();
703
704 var smallSpotClasses = "product-item__price";
705
706 if (isSmallSpot)
707 {
708 smallSpotClasses = "text-success font-weight-bold ml-auto";
709
710 if (checkoutPage)
711 {
712 <a href="@item.GetString("Ecom:Order:OrderLine.DeleteLink")" class="product-item__closebtn btn p-0">
713 <span class="icon icon-close m-0"></span>
714 </a>
715 }
716 else
717 {
718 <a href="#" class="product-item__closebtn btn js-product-state-submit p-0" data-action="@newDeleteLink">
719 <span class="icon icon-close m-0"></span>
720 </a>
721 }
722 }
723
724 if (!string.IsNullOrEmpty(campaignName))
725 {
726 string discountImage = ""; //@TODO hvad skal vi gøre med billeder?
727 bool blackFriday = false; //@TODO hvad skal vi gøre med black friday?
728
729 if (!String.IsNullOrEmpty(discountImage))
730 {
731 <div class="product-item__badge image-badge">
732 <img src="@discountImage" alt="Kampagne billede" width="150px"/>
733 </div>
734 }
735 else if (blackFriday)
736 {
737 <div class="product-item__badge blackfriday-badge text-uppercase">@Translate("ecom-campaigne-blackfriday", "Black Friday")</div>
738 }
739 else
740 {
741 <div class="product-item__badge text-uppercase">@Translate("Campaign-" + campaignName, campaignName)</div>
742 }
743 }
744
745 if (internalProduct && !webshopOK)
746 {
747 <div class="product-item__badge image-badge">
748 <img src="/Files/System/Images/Shop/Webshop_logo_intern.jpg" alt="Internt produkt" height="50px"/>
749 </div>
750 }
751
752 if (loopName == "Products")
753 {
754 <picture class="product-item__photo mr-md-7 mr-5" onclick="window.location = '@productUrl';" style="cursor:pointer">
755 <source srcset="/Admin/Public/GetImage.ashx?Image=@productImage&width=146&height=128&background=ffffff&format=webP&Compression=75&fillcanvas=true" media="(min-width: 576px)">
756 <img class="img-fluid w-100" src="/Admin/Public/GetImage.ashx?Image=@productImage&width=345&height=300&background=ffffff&format=webP&Compression=75&fillcanvas=true" alt="@productName">
757
758
759 </picture>
760 }
761
762
763 <div class="h-100 d-flex flex-column result-item__product-content">
764 <div class="d-flex flex-row">
765 <div class="d-flex flex-column mb-3" onclick="window.location = '@productUrl';" style="cursor:pointer">
766 <div class="product-item__title">@productName</div>
767 <div class="product-item__description">
768 @Translate("ProductNumber", "Varenummer") @item.GetString("Ecom:Product.Number")
769 @if ((jungStockAmount > 0 && jungStockAmount < 3) || item.GetInteger("Ecom:Product.Stock") > 0)
770 {
771 <svg height="20" width="20"> <circle cx="8" cy="8" r="6" stroke="#92D053" stroke-width="3" fill="#92D053"/> Sorry, your browser does not support inline SVG. </svg>
772
773 if (mainUserHeader != null && mainUserHeader.HasGroup(24))
774 {
775 <span>
776
777 (@item.GetInteger("Ecom:Product.Stock") @Translate("stk."))
778 </span>
779 }
780 }
781 </div>
782 @{
783 if (minQuantity > 1)
784 {
785 <div>
786 <strong>@Translate("Minimumskøb:", "Minimumskøb:")</strong> @minQuantity @Translate("stk.")
787 </div>
788 }
789 }
790 @foreach (LoopItem subItem in item.GetLoop("Order.OrderLineFields"))
791 {
792 <div class="product-item__description">
793 @if (subItem.GetString("Ecom:Order:OrderLine.OrderLineField.SystemName") == "DeliveryPromised")
794 {
795 @subItem.GetString("Ecom:Order:OrderLine.OrderLineField.Value")
796 }
797 else if (subItem.GetString("Ecom:Order:OrderLine.OrderLineField.SystemName") == "customSizeAdded")
798 {
799 @Translate("customSize", "Størrelse")
800 @subItem.GetString("Ecom:Order:OrderLine.OrderLineField.Value")<span>mm</span>
801 }
802 </div>
803 }
804
805 @if (mainUserHeader != null && mainUserHeader.HasGroup(24) && !isSmallSpot)
806 {
807 string image = VestjyskMarketing.Helpers.ImageHelper.ResizeImage(new ResizeImageSettings()
808 {
809 Image = "/Files/Files/Images/img_calculator.png",
810 Height = 96,
811 Width = 96,
812 Quality = 85
813 });
814
815 string salesPrice = item.GetDouble("Ecom:Product.DBPrice").ToString("F2");
816 string webPrice = salesPrice;
817 string webDiscount = Dynamicweb.Core.Converter.ToDouble(productApi.GetProductFieldValue("WebDiscount")).ToString("F2");
818 string cost = Dynamicweb.Core.Converter.ToString(productApi.Cost);
819 string externalNumber = Dynamicweb.Core.Converter.ToString(productApi.GetProductFieldValue("ExterntNummer"));
820 string manufacturer = productApi.Manufacturer != null ? productApi.Manufacturer.Name : "";
821 string discountGroup = Dynamicweb.Core.Converter.ToString(productApi.GetProductFieldValue("ItemDiscGroup"));
822
823
824 foreach (var priceFromMatrix in productApi.Prices)
825 {
826 if (Helpers.Product.IsPriceValid(priceFromMatrix))
827 {
828 var userToTakePriceFrom = Pageview.User;
829
830 if (!string.IsNullOrEmpty(userToTakePriceFrom.Currency) && priceFromMatrix.CurrencyCode == userToTakePriceFrom.Currency)
831 {
832 webPrice = priceFromMatrix.Amount.ToString("F2");
833 }
834
835 if (priceFromMatrix.CurrencyCode == "DKK" && string.IsNullOrEmpty(userToTakePriceFrom.Currency))
836 {
837 webPrice = priceFromMatrix.Amount.ToString("F2");
838 }
839 }
840 }
841
842 <div class="d-flex align-items-end flex-row">
843 <div>
844 <div class="text-center" style="font-size: 10px;">
845 @Translate("Salgspris", "Salgspris"): @salesPrice
846 </div>
847
848 <div class="text-center" style="font-size: 10px;">
849 @Translate("Webpris", "Webpris"): @webPrice
850 </div>
851 </div>
852 <div class="product-item__details ml-6">
853 <img src="@image" class="product-item__details__image">
854 <div class="product-item__details__tooltip">
855 <div class="row">
856 <div class="col-7">
857 @Translate("Salgspris", "Salgspris"):
858 </div>
859 <div class="col-5">
860 @salesPrice
861 </div>
862 <div class="col-7">
863 @Translate("Webrabat", "Webrabat") %:
864 </div>
865 <div class="col-5">
866 @webDiscount
867 </div>
868 <div class="col-7">
869 @Translate("Webpris", "Webpris"):
870 </div>
871 <div class="col-5">
872 @webPrice
873 </div>
874 <div class="col-7">
875 @Translate("Cost", "Kostpris"):
876 </div>
877 <div class="col-5">
878 @cost
879 </div>
880 <div class="col-7">
881 @Translate("Manufacturer's number", "Leverandørens varenr"):
882 </div>
883 <div class="col-5">
884 @externalNumber
885 </div>
886 <div class="col-7">
887 @Translate("Manufacturer", "Levenrandør"):
888 </div>
889 <div class="col-5">
890 @manufacturer
891 </div>
892 <div class="col-7">
893 @Translate("DiscountGroup", "Varerabatgruppe"):
894 </div>
895 <div class="col-5">
896 @discountGroup
897 </div>
898 </div>
899 </div>
900 </div>
901 </div>
902 }
903 </div>
904 </div>
905 <div class="d-flex align-items-center justify-content-start mt-auto flex-row">
906 <input type="hidden" name="ProdId" class="js-reorder-product-id" value="@item.GetString("Ecom:Product.ID")"/>
907 @if (loopName != "Products")
908 {
909 <div class="input-group product-item__quantity-wrapper">
910 <span class="input-group-btn">
911 @if (checkoutPage)
912 {
913 <a href="@item.GetString("Ecom:Order:OrderLine.DecrementLink")" role="button" class="btn btn-buy d-inline-flex align-items-center justify-content-center">
914 <span class="icon icon-minus"></span>
915 </a>
916 }
917 else
918 {
919 <a href="#" role="button" class="btn btn-buy d-inline-flex align-items-center justify-content-center js-product-state-submit" data-action="@item.GetString("Ecom:Order:OrderLine.DecrementLink")">
920 <span class="icon icon-minus"></span>
921 </a>
922 }
923 </span>
924 <input id="Quantity" type="text" autocomplete="off" class="form-control js-quantity-input text-center" name="Quantity" min="@minQuantity" value="@item.GetString("Ecom:Order:OrderLine.Quantity")" data-step="@quantityStep" data-type="order">
925 <span class="input-group-btn">
926 @if (checkoutPage)
927 {
928 <a href="@item.GetString("Ecom:Order:OrderLine.IncrementLink")" role="button" class="btn btn-buy d-inline-flex align-items-center justify-content-center">
929 <span class="icon icon-plus"></span>
930 </a>
931 }
932 else
933 {
934 <a href="#" role="button" class="btn btn-buy d-inline-flex align-items-center justify-content-center js-product-state-submit" data-action="@item.GetString("Ecom:Order:OrderLine.IncrementLink")">
935 <span class="icon icon-plus"></span>
936 </a>
937 }
938
939 </span>
940 </div>
941 }
942 else if (!hasCombinations)
943 {
944 <div class="input-group product-item__quantity-wrapper d-md-none">
945 <span class="input-group-btn">
946 <button class="btn btn-buy js-reorder-quantity-subtract" type="button">
947 <span class="icon icon-minus"></span>
948 </button>
949 </span>
950 <input type="text" autocomplete="off" class="form-control js-reorder-quantity-input text-center" name="Quantity" min="0" max="20" value="1">
951 <span class="input-group-btn">
952 <button class="btn btn-buy js-reorder-quantity-add" type="button">
953 <span class="icon icon-plus"></span>
954 </button>
955 </span>
956 </div>
957 }
958
959
960 @if (productFabrikat != "leitz")
961 {
962 <div class="@smallSpotClasses" onclick="window.location = '@productUrl';" style="cursor:pointer">
963 @if (false) //TODO campaign prices
964 {
965 <div class="product-details__price-container">
966 @if (hasCombinations && loopName != "OrderLines")
967 {
968 <div class="from-price">@Translate("ProductFromPrice", "Fra")</div>
969 }
970 <div>@item.GetString("Ecom:Product.Discount.Price.PriceWithoutVATFormatted").Replace(",00", ",-")</div>
971 <div class="product-item__price--old">@item.GetString("Ecom:Product.Price.PriceWithoutVATFormatted").Replace(",00", ",-")</div>
972 </div>
973 }
974 else
975 {
976 if (hasCombinations && loopName != "OrderLines")
977 {
978 <div class="from-price without-discount">
979 @Translate("ProductFromPrice", "Fra")<span> </span>
980 </div>
981 }
982
983 <div class="without-discount lazyload-price" data-id="@item.GetString("Ecom:Product.ID")" data-variantid='@(hasCombinations ? "variantid" : "")'>
984 <img src="/Files/Images/loading.gif">
985 @if (loopName == "OrderLines")
986 {
987 @item.GetString("Ecom:Order:OrderLine.UnitPrice.PriceWithoutVATFormatted").Replace(",00", ",-")
988 }
989 else
990 {
991 @item.GetString("Ecom:Product.Price.PriceWithoutVATFormatted").Replace(",00", ",-")
992 }
993 </div>
994 }
995 </div>
996 }
997 else if (User.IsExtranetUserLoggedIn())
998 {
999 <div class="@smallSpotClasses" onclick="window.location = '@productUrl';" style="cursor:pointer">
1000
1001 @if (hasCombinations && loopName != "OrderLines")
1002 {
1003 <div class="from-price without-discount">@Translate("ProductFromPrice", "Fra")</div>
1004 }
1005
1006 <div class="without-discount lazyload-price" data-id="@item.GetString("Ecom:Product.ID")" data-variantid='@(hasCombinations ? "variantid" : "")'>
1007 <img src="/Files/Images/loading.gif">
1008 @if (loopName == "OrderLines")
1009 {
1010 @item.GetString("Ecom:Order:OrderLine.UnitPrice.PriceWithoutVATFormatted").Replace(",00", ",-")
1011 }
1012 else
1013 {
1014 @item.GetString("Ecom:Product.Price.PriceWithoutVATFormatted").Replace(",00", ",-")
1015 }
1016
1017 </div>
1018
1019 </div>
1020 }
1021
1022 @if (loopName == "Products")
1023 {
1024 if (productFabrikat != "leitz" || User.IsExtranetUserLoggedIn())
1025 {
1026 <div class="product-item__infowrapper d-inline-block no-wrap ml-auto flex-row">
1027 <button type="button" class="btn btn-link align-self-end d-none d-md-inline-block mr-2 px-4" onclick="window.location = '@productUrl';">INFO</button>
1028 @if (!hasCombinations)
1029 {
1030 <button type="submit" class="js-reorder-add-to-basket w-100 btn btn-sm btn-success align-self-end d-md-none ml-auto">
1031 <span class="icon icon-cart mr-4"></span>
1032 </button>
1033 }
1034 else
1035 {
1036 <button type="submit" class="w-100 btn btn-sm btn-success align-self-end d-md-none ml-auto" onclick="window.location = '@productUrl';">
1037 <span class="icon icon-cart mr-4"></span>
1038 </button>
1039 }
1040 <button type="button" class="btn btn-success align-self-end d-none d-md-inline-block px-4" onclick="window.location = '@productUrl';">
1041 <span class="icon icon-shopping-cart mr-2"></span>@Translate("BESTIL")
1042 </button>
1043
1044
1045 </div>
1046 }
1047 else
1048 {
1049 <div class="d-flex">
1050
1051 <div class="align-self-end d-none d-md-inline-block px-4" style="font-size: 12px">@Translate("Log ind for at se prisen")</div>
1052
1053 <button type="button" class="btn btn-success align-self-end d-md-inline-block js-aside-btn px-4" href="#" data-view="login">@Translate("HeaderLoginButton", "Login")</button>
1054
1055 </div>
1056 }
1057 }
1058 </div>
1059
1060 @if (loopName == "Products")
1061 {
1062 if (prices.Count > 1 && false)
1063 {
1064 int counterPrices = 0;
1065 string marginLeft = string.Empty;
1066 <div class="d-flex flex-column mb-md-7 font-weight-bolder my-5">
1067 <h4 class="font-weight-bold">
1068 Køb flere og spar:
1069 </h4>
1070
1071 <div>
1072 <div class="font-small d-flex flex-column flex-lg-row">
1073
1074 @foreach (Dynamicweb.Ecommerce.Prices.Price priceInMatrix in prices.OrderBy(x => x.Quantity))
1075 {
1076 if (!Helpers.Product.IsCampaingPrice(priceInMatrix) && Helpers.Product.IsPriceValid(priceInMatrix) && priceInMatrix.Quantity > 1)
1077 {
1078 if (counterPrices > 0)
1079 {
1080 marginLeft = "ml-lg-3";
1081 }
1082
1083 double productPriceDouble = item.GetDouble("Ecom:Product.Price.PriceWithoutVAT");
1084 double percentageSaved = (productPriceDouble - priceInMatrix.Amount) / productPriceDouble * 100;
1085 <div class="d-flex flex-row @marginLeft">
1086 <span class="text-success">
1087 @priceInMatrix.Quantity stk. af @priceInMatrix.Amount,-
1088 </span>
1089 <span class="text-danger ml-2">
1090 Du sparer @Math.Round(percentageSaved)%
1091 </span>
1092 </div>
1093 counterPrices++;
1094 }
1095 }
1096 </div>
1097 </div>
1098 </div>
1099 }
1100 }
1101 </div>
1102 }
1103 }
1104
1105 @helper RenderProductListNew(string loopName, int limit = 0, bool isSmallSpot = false, bool productPage = false, List<Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>>.LoopItem> newLoop = null)
1106 {
1107 var loop = GetLoop(loopName);
1108
1109
1110 if (newLoop != null)
1111 {
1112 loop = newLoop;
1113 }
1114
1115 //fetch pages from shop
1116 var pageService = new Dynamicweb.Content.PageService();
1117 var pages = pageService.GetPagesForItems(new string[] { "PageShopList" }).Where(p => p.AreaId == Pageview.AreaID);
1118
1119 foreach (LoopItem item in limit == 0 ? loop : loop.Take(limit))
1120 {
1121 if (!string.IsNullOrEmpty(item.GetString("Ecom:Product.PrimaryOrFirstGroupID")))
1122 {
1123 //set URL for page. To get correct URL all places in regards to list
1124 var group = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(item.GetString("Ecom:Product.PrimaryOrFirstGroupID"));
1125 int pageId = 0;
1126 foreach (var page in pages)
1127 {
1128 var shopGroupPage = Dynamicweb.Core.Converter.ToString(page.Item["ShopCategoryNumber"]);
1129 if (shopGroupPage == group.Number && page.AreaId.Equals(Pageview.AreaID))
1130 {
1131 pageId = page.ID;
1132 break;
1133 }
1134 }
1135
1136 string productPageUrl = "/Default.aspx?ID=" + pageId + "&ProductID=" + item.GetString("Ecom:Product.ID");
1137 if (pageId == 0)
1138 {
1139 productPageUrl = item.GetString("Ecom:Product.Link.Clean");
1140 }
1141
1142 var cols = "col-md-6 col-lg-4";
1143
1144 if (productPage)
1145 {
1146 cols = "col-md-6 col-lg-3";
1147 }
1148
1149 if (loopName.Equals("Products") || loopName.Equals("Item.ProductDisplay"))
1150 {
1151 //get campaign name
1152 string campaignName = "";
1153 var productApi = Dynamicweb.Ecommerce.Services.Products.GetProductById(item.GetString("Ecom:Product.ID"), null, false);
1154 var prices = productApi.Prices;
1155 foreach (var priceFromMatrix in productApi.Prices)
1156 {
1157 if (priceFromMatrix.Amount == item.GetDouble("Ecom:Product.Price.PriceWithoutVAT.Value"))
1158 {
1159 campaignName = priceFromMatrix.Periods.FirstOrDefault()?.Name;
1160 }
1161 }
1162
1163
1164 <div class="@cols d-none d-md-flex js-product-list-item position-relative" style="padding: 8px 8px 0 8px; justify-content: center;">
1165 <a href="@productPageUrl" class="product-item box-shadow-sm box-shadow-sm-hoover mb-3" style="width: 100%; padding: 10px; position: relative;">
1166 @if (!string.IsNullOrEmpty(campaignName))
1167 {
1168 <div onclick="window.location = '@productPageUrl'" class="campaign-container" style="position: absolute; height: 120px; top: 0; left: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center;">
1169 <img src="/Admin/Public/GetImage.ashx?Image=/Files/Files/Images/discount_label2.png&Format=png&Width=587&Height=628&Resolution=99&Crop=0" style="height: 120px;">
1170 <div class="text-uppercase" style="margin-bottom: 39px; font-size: 12px; margin-right: 30px; color: white; font-weight: 600; position: absolute; z-index: 5; transform: rotate(-46deg); transform-origin: center center; white-space: nowrap">@Translate("Campaign-" + campaignName, campaignName)</div>
1171 </div>
1172 }
1173 @ContentRenderingNew(item, loopName, false, productPageUrl)
1174 </a>
1175 </div>
1176 }
1177 else
1178 {
1179 <a href="@productPageUrl" class="product-item box-shadow-sm box-shadow-sm-hoover js-product-list-item mb-3">
1180 @ContentRenderingNew(item, loopName, false, productPageUrl)
1181 </a>
1182 }
1183 }
1184 }
1185 }
1186
1187 @helper RenderProductList(string loopName, int limit = 0, bool isSmallSpot = false, bool isSearch = false)
1188 {
1189 var loop = GetLoop(loopName);
1190
1191 //fetch pages from shop
1192 var pageService = new Dynamicweb.Content.PageService();
1193 var pages = pageService.GetPagesForItems(new string[] { "PageShopList" }).Where(p => p.AreaId == Pageview.AreaID);
1194 var productService = new ProductService();
1195
1196 foreach (LoopItem item in limit == 0 ? loop : loop.Take(limit))
1197 {
1198 if (!string.IsNullOrEmpty(item.GetString("Ecom:Product.PrimaryOrFirstGroupID")))
1199 {
1200 //set URL for page. To get correct URL all places in regards to list
1201 var group = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(item.GetString("Ecom:Product.PrimaryOrFirstGroupID"));
1202 int pageId = 0;
1203 foreach (var page in pages)
1204 {
1205 var shopGroupPage = Dynamicweb.Core.Converter.ToString(page.Item["ShopCategoryNumber"]);
1206 if (shopGroupPage == group.Number && page.AreaId.Equals(Pageview.AreaID))
1207 {
1208 pageId = page.ID;
1209 break;
1210 }
1211 }
1212
1213 string productPageUrl = "/Default.aspx?ID=" + pageId + "&ProductID=" + item.GetString("Ecom:Product.ID");
1214 if (pageId == 0)
1215 {
1216 productPageUrl = item.GetString("Ecom:Product.Link.Clean");
1217 }
1218
1219 if (loopName.Equals("Products"))
1220 {
1221 var displays = isSearch ? "" : "d-flex d-md-none";
1222
1223
1224 <a href="@productPageUrl" class="@displays product-item box-shadow-sm box-shadow-sm-hoover js-product-list-item mb-3">
1225 @ContentRendering(item, loopName, false, productPageUrl)
1226
1227 <span href="@productPageUrl" class="product-item__label d-md-none">
1228 <span>@Translate("Læs mere")</span>
1229 </span>
1230
1231 </a>
1232 }
1233 }
1234 }
1235 }
1236
1237 <div class="product-list">
1238 <div class="container-fluid">
1239 <div class="row no-gutters">
1240 <div class="col-12 col-md-4 col-lg-3">
1241 <div class="d-none d-md-block">
1242 <div class="filters-login d-flex flex-column">
1243 @if (string.IsNullOrWhiteSpace(GetGlobalValue("Global:Extranet.Email")))
1244 {
1245 <h4 class="mb-5">@Translate("login-teaser-text", "Log ind for at se dine nettopriser")</h4>
1246 <div>
1247 <button type="button" class="btn btn-sm btn-outline-primary d-md-none px-4"><span class="icon icon-user"></span> @Translate("login-text", "LOG IND")</button>
1248 <button type="button" class="btn btn-outline-primary d-none d-md-inline-block js-aside-btn px-4" href="#" data-view="login"><span class="icon icon-user"></span> @Translate("logout", "LOG IND")</button>
1249 </div>
1250 <hr class="w-100 my-7" />
1251 }
1252 </div>
1253
1254 @if (GetLoop("FacetGroups").Any(item => item.GetLoop("Facets").Any(subitem => subitem.GetLoop("FacetOptions").Any())))
1255 {
1256 <div class="filters-list d-flex flex-column">
1257 <!--
1258 <span class="mb-7 h2">@Translate("ecom-product-filter", "Product filter")</span>
1259 -->
1260 @if (GetLoop("FacetGroups").Any(item => item.GetLoop("Facets").Any(subitem => subitem.GetLoop("FacetOptions").Any())))
1261 {
1262 var getCurrentPageId = new Dynamicweb.Content.Page();
1263 var getFriendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(getCurrentPageId.ParentPageId);
1264 string producturl = getFriendlyUrl.ToString();
1265 <div class="filter js-ajax-refresh">
1266 <div class="filter__container">
1267 <form class="filter__form js-filter-form" action="@producturl" method="GET">
1268
1269 @foreach (LoopItem facetGroupLoop in GetLoop("FacetGroups"))
1270 {
1271 foreach (LoopItem facetItem in facetGroupLoop.GetLoop("Facets"))
1272 {
1273
1274 if (!facetItem.GetLoop("FacetOptions").Any())
1275 {
1276 continue;
1277 }
1278
1279 string FacetName = facetItem.GetString("Facet.Name");
1280 string FacetQueryParameter = facetItem.GetString("Facet.QueryParameter");
1281 string isActive = facetItem.GetLoop("FacetOptions").Exists(item => item.GetBoolean("FacetOption.Selected")) ? "is-mobile-active" : null;
1282 bool isCollapse = facetItem.GetLoop("FacetOptions").Count > 5;
1283
1284 <div class="d-flex flex-column ">
1285 <div class="">
1286 <div class="filter-list__facets mb-2 js-filter-list-@FacetQueryParameter">
1287 <span class="mb-5 h4 @isActive">@Translate(FacetName, FacetName)</span>
1288 @{
1289
1290 bool first = true;
1291 var mt = "";
1292
1293 }
1294
1295 @foreach (LoopItem FacetOption in facetItem.GetLoop("FacetOptions"))
1296 {
1297 string FacetOptionValue = FacetOption.GetString("FacetOption.Value");
1298 string FacetOptionName = FacetOption.GetString("FacetOption.Name");
1299 string FacetOptionLabel = (FacetOption.GetString("FacetOption.Label") == "True" || FacetOption.GetString("FacetOption.Label") == "False" ? Translate(FacetOption.GetString("FacetOption.Label")) : FacetOption.GetString("FacetOption.Label"));
1300 var state = FacetOption.GetBoolean("FacetOption.Selected") ? "checked='true'" : null;
1301 int FacetCounter = FacetOption.GetInteger("FacetOption.Count");
1302 string parameterAndValue = (FacetQueryParameter + FacetOptionValue).Replace(" ", string.Empty);
1303 if (!string.IsNullOrEmpty(FacetOptionValue) && !string.IsNullOrEmpty(FacetOptionName) && FacetOptionValue != "0" && FacetOptionValue != "00" && FacetOptionName != "0" && FacetOptionName != "00" && !string.IsNullOrEmpty(FacetOptionValue) && FacetOptionValue != "0")
1304 {
1305
1306 if (first)
1307 {
1308
1309 mt = "mt-5";
1310 }
1311 else
1312 {
1313 mt = "";
1314 }
1315
1316 <div class="form-check @mt">
1317 <div class="custom-control custom-checkbox p-0 w-100 ">
1318 <input type="checkbox" data-name="@FacetOptionLabel" name="@FacetQueryParameter" class="custom-control-input js-filter__input js-apply-filter" id="@parameterAndValue" value="[@FacetOptionValue]" @state>
1319 <label class="custom-control-label d-flex custom-checkbox" for="@parameterAndValue">
1320 <span class="custom-control-description">@FacetOptionLabel</span>
1321 <span class="custom-control-underline"></span>
1322 <span class="custom-control-count">@FacetCounter</span>
1323 </label>
1324 </div>
1325 </div>
1326
1327 first = false;
1328 }
1329 }
1330 </div>
1331 <button class="@(!isCollapse ? "d-none" : "js-toggle-class") btn btn-more-filters float-right pr-0 pl-2 p-0 btnout" type="button" data-view-more="@Translate("ecom-show-more")" data-view-less="@Translate("ecom-show-less")" data-target=".js-filter-list-@FacetQueryParameter"><span class="icon icon-chevron-right mr-3"></span><span class="js-toggle-translation">@Translate("ecom-show-more")</span></button>
1332 </div>
1333 </div>
1334 }
1335 }
1336
1337
1338
1339
1340 </form>
1341 </div>
1342 </div>
1343 }
1344 </div>
1345 }
1346 </div>
1347 @if (facetGroup.Any())
1348 {
1349 <div class="d-md-none">
1350 <div class="js-append-filter"></div>
1351 <button type="button" class="btn btn-primary align-self-end w-100 js-aside-btn js-filter-panel-button mb-7 px-4" data-view="filters"><small class="d-md-none">@Translate("ecom-filter-headline-mobile", "FILTER")</small><span class="icon icon-settings mr-4"></span><small class="d-none d-md-block">@Translate("ecom-filter-headline", "PRODUKTFILTER")</small></button>
1352 </div>
1353 }
1354 </div>
1355 <div class="col-12 col-md-8 pl-md-4 pl-lg-0 col-lg-8 ml-auto">
1356 <div class="d-flex flex-column flex-lg-row align-items-center mb-md-7 mb-5">
1357 <span class="h2">@Translate("ecom-filter-text-one", "Vi fandt") <span class="text-secondary"><span class="js-result-counter">@GetString("Ecom:ProductList.PageProdCnt")</span> @Translate("ecom-filter-text-two", "produkter")</span> @Translate("ecom-filter-text-three", "der matcher")</span>
1358 @{
1359 var path = GetGlobalValue("Global:Pageview.Url");
1360 if (path.IndexOf("?") != -1)
1361 {
1362 path = path.Substring(0, path.IndexOf("?"));
1363 }
1364 }
1365 <div class="product-list__sorting d-flex flex-row align-items-center ml-lg-auto">
1366 <div class="product-list__sorting-title">@Translate("Sorter efter", "Sorter efter")</div>
1367 <div class="product-list__sorting-select">
1368
1369 <form name="sorting" method="GET" action="@path" class="js-product-list-sorting">
1370 <select class="custom-select js-product-list-sorting-sort-by">
1371 <option @(GetString("Ecom:ProductList.SortBy") == "SortingField" ? "selected" : "") value="SortBy=Created&SortOrder=DESC">@Translate("Vælg sortering", "Vælg sortering")</option>
1372 <option @(GetString("Ecom:ProductList.SortBy") == "SortBy=Price&SortOrder=ASC" ? "selected" : "") value="SortBy=Price&SortOrder=ASC">@Translate("Billigste Pris", "Billigste Pris")</option>
1373 <option @(GetString("Ecom:ProductList.SortBy") == "SortBy=Stock&SortOrder=DESC" ? "selected" : "") value="SortBy=Stock&SortOrder=DESC">@Translate("På lager", "På lager")</option>
1374 </select>
1375 </form>
1376 <span class="icon icon-chevron-down"></span>
1377 </div>
1378 </div>
1379
1380 </div>
1381 <div class="d-block d-md-none p-0">
1382 <div class="list-unstyled js-product-list js-product-list-loader p-0" data-page-url="@pathName">
1383 @RenderProductList("Products")
1384 @if( GetInteger("Ecom:ProductList.TotalPages") > 1 )
1385 {
1386 <div class="product-list__pagination js-product-list-item">
1387 <a class="product-list__previous-button @(!string.IsNullOrWhiteSpace(prevPage) ? "is-active" : null)" data-icon="arrow-left" href="@(!string.IsNullOrWhiteSpace(prevPage) ? prevPage : null)"></a>
1388 <div class="product-list__counter-wrapper">
1389 <select id="pageSelector" class="product-list__counter js-select">
1390 <option>@Translate("productlist-count-text", "Page") @GetString("Ecom:ProductList.CurrentPage") @Translate("productlist-count-text-2", "out of") @GetString("Ecom:ProductList.TotalPages")</option>
1391 @foreach (LoopItem page in GetLoop("Ecom:ProductList.Pages"))
1392 {
1393 string pageUrl = page.GetString("Ecom:ProductList.Pages.Page.Url");
1394 <option class="pagination__item" value="@pageUrl">@Translate("productlist-count-text", "Page") @page.GetValue("Ecom:ProductList.Pages.Page.Number") @Translate("productlist-count-text-2", "out of") @GetString("Ecom:ProductList.TotalPages")</option>
1395 }
1396 </select>
1397 </div>
1398 <a class="product-list__next-button @(!string.IsNullOrWhiteSpace(nextPage) ? "is-active" : null)" data-icon="arrow-right" href="@(!string.IsNullOrWhiteSpace(nextPage) ? nextPage : null)"></a>
1399 </div>
1400 }
1401
1402 <script>
1403 document.addEventListener('DOMContentLoaded', function() {
1404 document.body.addEventListener('change', function(event) {
1405 var element = event.target;
1406 if (element && element.id === 'pageSelector') {
1407 var url = element.value;
1408 if (url) {
1409 window.location.href = url;
1410 }
1411 }
1412 });
1413 });
1414 </script>
1415
1416 </div>
1417 </div>
1418 <div class="d-none d-md-block p-0">
1419 <div style="flex-flow: wrap; justify-content: start" class="d-flex list-unstyled js-product-list js-product-list-loader col-12 p-0" data-page-url="@pathName">
1420 @RenderProductListNew("Products")
1421 @if( GetInteger("Ecom:ProductList.TotalPages") > 1 )
1422 {
1423 <div class="product-list__pagination js-product-list-item">
1424 <a class="product-list__previous-button @(!string.IsNullOrWhiteSpace(prevPage) ? "is-active" : null)" data-icon="arrow-left" href="@(!string.IsNullOrWhiteSpace(prevPage) ? prevPage : null)"></a>
1425 <div class="product-list__counter-wrapper">
1426 <select id="pageSelector" class="product-list__counter js-select">
1427 <option>@Translate("productlist-count-text", "Page") @GetString("Ecom:ProductList.CurrentPage") @Translate("productlist-count-text-2", "out of") @GetString("Ecom:ProductList.TotalPages")</option>
1428 @foreach (LoopItem page in GetLoop("Ecom:ProductList.Pages"))
1429 {
1430 string pageUrl = page.GetString("Ecom:ProductList.Pages.Page.Url");
1431 <option class="pagination__item" value="@pageUrl">@Translate("productlist-count-text", "Page") @page.GetValue("Ecom:ProductList.Pages.Page.Number") @Translate("productlist-count-text-2", "out of") @GetString("Ecom:ProductList.TotalPages")</option>
1432 }
1433 </select>
1434 </div>
1435 <a class="product-list__next-button @(!string.IsNullOrWhiteSpace(nextPage) ? "is-active" : null)" data-icon="arrow-right" href="@(!string.IsNullOrWhiteSpace(nextPage) ? nextPage : null)"></a>
1436 </div>
1437 }
1438
1439 <script>
1440 document.addEventListener('DOMContentLoaded', function() {
1441 document.body.addEventListener('change', function(event) {
1442 var element = event.target;
1443 if (element && element.id === 'pageSelector') {
1444 var url = element.value;
1445 if (url) {
1446 window.location.href = url;
1447 }
1448 }
1449 });
1450 });
1451 </script>
1452
1453 </div>
1454 </div>
1455
1456 @if (GetInteger("Ecom:ProductList.PageProdCnt") == 0)
1457 {
1458 var pageId = GetInteger("Ecom:ProductList:Page.ID");
1459 var page = pageService.GetPage(pageId);
1460
1461 if (page.Item["FormToShowIfEmpty"] != null)
1462 {
1463
1464 if (page.Item["FormToShowIfEmpty"].ToString().Split('#').Length > 1)
1465 {
1466 var paragraphId = int.Parse(page.Item["FormToShowIfEmpty"].ToString().Split('#')[1]);
1467 @RenderParagraphContent(paragraphId)
1468 }
1469
1470 }
1471
1472 }
1473
1474 </div>
1475 </div>
1476 <span><p style="float:right;"><svg height="20" width="20"> <circle cx="8" cy="8" r="6" stroke="#92D053" stroke-width="3" fill="#92D053" /> Sorry, your browser does not support inline SVG. </svg> = Varen er på lager</p></span>
1477 </div>
1478 </div>
1479
1480
1481 @if (GetLoop("FacetGroups").Any(item => item.GetLoop("Facets").Any(subitem => subitem.GetLoop("FacetOptions").Any())))
1482 {
1483 var getCurrentPageId = new Dynamicweb.Content.Page();
1484 var getFriendlyUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(getCurrentPageId.ParentPageId);
1485 string producturl = getFriendlyUrl.ToString();
1486 <section class="aside-panel js-aside js-view-filters js-ajax-refresh-mobile">
1487 <form class="filter__form js-filter-form-mobile" action="@producturl" method="GET">
1488 <div class="aside-panel__bcg js-aside-bcg js-aside-close-btn" data-view="filters"></div>
1489 <div class="side-modal aside-panel__content flex-column js-view-filters">
1490 <span class="mb-7 h2 filters-title">
1491 <strong>@(Pageview.Page.MenuText)</strong><br/>
1492 @Translate("Filtrer efter", "Filtrer efter")
1493 </span>
1494 <button type="button" class="btn btn-link btn-close js-aside-close-btn" data-view="filters">@Translate("FilterCloseButton", "LUK") <span class="icon icon-close ml-2"></span></button>
1495 <div class="container-fluid aside-panel__container">
1496 <div class="aside-panel__scroll-content">
1497 <div class="filters-list d-flex flex-column">
1498
1499 @{
1500 int facetsCounter = 0;
1501 }
1502
1503 @foreach (LoopItem facetGroupLoop in GetLoop("FacetGroups"))
1504 {
1505
1506 foreach (LoopItem facetItem in facetGroupLoop.GetLoop("Facets"))
1507 {
1508
1509 if (!facetItem.GetLoop("FacetOptions").Any())
1510 {
1511 continue;
1512 }
1513
1514 facetsCounter++;
1515
1516 string FacetName = facetItem.GetString("Facet.Name");
1517 string FacetQueryParameter = facetItem.GetString("Facet.QueryParameter");
1518 string isActive = facetItem.GetLoop("FacetOptions").Exists(item => item.GetBoolean("FacetOption.Selected")) ? "is-mobile-active" : null;
1519 bool isCollapse = true;//facetItem.GetLoop("FacetOptions").Count > 5;
1520 int FacetTotalCount = facetItem.GetInteger("Facet.OptionResultTotalCount"); // Facet.OptionCount Facet.OptionResultTotalCount Facet.OptionWithResultCount
1521
1522
1523 <div class="d-flex flex-column">
1524 <div class="filter-list__facets js-filter-list-@FacetQueryParameter@(facetsCounter == 1 ? " is-active" : string.Empty)">
1525 @foreach (LoopItem FacetOption in facetItem.GetLoop("FacetOptions").OrderBy(FacetOption => FacetOption.GetString("FacetOption.Label").Length).ThenBy(FacetOption => FacetOption.GetString("FacetOption.Label")))
1526 {
1527 string FacetOptionValue = FacetOption.GetString("FacetOption.Value");
1528 string FacetOptionName = FacetOption.GetString("FacetOption.Name");
1529 string FacetOptionLabel = (FacetOption.GetString("FacetOption.Label") == "True" || FacetOption.GetString("FacetOption.Label") == "False" ? Translate(FacetOption.GetString("FacetOption.Label")) : FacetOption.GetString("FacetOption.Label"));
1530 var state = FacetOption.GetBoolean("FacetOption.Selected") ? "checked='true'" : null;
1531 int FacetCounter = FacetOption.GetInteger("FacetOption.Count");
1532 string parameterAndValue = (FacetQueryParameter + FacetOptionValue).Replace(" ", string.Empty);
1533
1534 <div class="form-check">
1535 <div class="custom-control custom-checkbox w-100">
1536 <label class="custom-control-label d-flex js-filter-label" for="@parameterAndValue">
1537 <span class="custom-control-description">@FacetOptionLabel</span>
1538 <span class="custom-control-underline"></span>
1539 <span class="custom-control-count">@FacetCounter</span>
1540 </label>
1541 </div>
1542 </div>
1543 }
1544 </div>
1545 <div class="mb-md-10 mb-5">
1546 <h4 class="mb-5">@Translate(FacetName, FacetName)</h4>
1547 <button class="@(!isCollapse ? " d-none" : "js-toggle-class" ) filter__show-filter btn btn-more-filters float-right pr-0 pl-2" type="button" data-reset=".filter-list__facets" data-target=".js-filter-list-@FacetQueryParameter"><span class="icon icon-chevron-right mr-3"></span>@Translate("ecom-show-more")</button>
1548 <span>@FacetTotalCount</span>
1549 </div>
1550 </div>
1551 }
1552 }
1553 </div>
1554 </div>
1555 </div>
1556 <div class="px-5 pb-4">
1557 <button type="reset" class="btn btn-primary btn-lg align-self-end px-4 mb-4 w-100 js-aside-close-btn" onclick="window.location = '/Default.aspx?Id=@(Pageview.Page.ID.ToString())';">@Translate("FilterResetButtonTextMobile", "NULSTIL")</button>
1558 <button type="button" class="btn btn-primary btn-lg align-self-end px-4 mb-4 w-100 js-aside-close-btn" data-view="filters">@Translate("FilterApplyButtonTextMobile", "ANVEND FILTER")</button>
1559 </div>
1560 </div>
1561 </form>
1562 </section>
1563 }
1564
1565
1566 @SnippetStart("BeforeBodyEndScripts")
1567
1568 @if (products.Count > 0)
1569 {
1570 <script>
1571 document.addEventListener("DOMContentLoaded", function () {
1572 var listitemLd =
1573 {
1574 "@@context": "https://schema.org/",
1575 "@@type": "ItemList",
1576 "itemListElement": [
1577 @foreach (var productScheme in products)
1578 {
1579
1580 //URL
1581 string host = "https://" + GetGlobalValue("Global:Request.Host");
1582 var group = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(productScheme.GetString("Ecom:Product.PrimaryOrFirstGroupID"));
1583 int pageId = 0;
1584 foreach (var page in pages)
1585 {
1586 var shopGroupPage = Dynamicweb.Core.Converter.ToString(page.Item["ShopCategoryNumber"]);
1587 if (shopGroupPage == group.Number && page.AreaId.Equals(Pageview.AreaID))
1588 {
1589 pageId = page.ID;
1590 break;
1591 }
1592 }
1593
1594 string productUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?ID=" + pageId + "&ProductID=" + productScheme.GetString("Ecom:Product.ID"));
1595 if (pageId == 0)
1596 {
1597 productUrl = productScheme.GetString("Ecom:Product.Link.Clean");
1598 }
1599
1600 productUrl = host + productUrl;
1601
1602 //image
1603 string productImage = "/Files/System/Images/Shop/na-image.jpg";
1604 string getImageForProductList = group.LargeImage;
1605 string myFormat = string.Format("/Files/{0}", getImageForProductList);
1606
1607 if (!string.IsNullOrEmpty(productScheme.GetString("Ecom:Product.Image.Master")))
1608 {
1609 productImage = productScheme.GetString("Ecom:Product.Image.Master");
1610 }
1611 else if (!string.IsNullOrEmpty(getImageForProductList))
1612 {
1613 productImage = myFormat;
1614 }
1615 productImage = host + productImage;
1616
1617 //availability
1618 string availability = "";
1619 double productStock = productScheme.GetDouble("Ecom:Product.Stock");
1620 if (productStock > 0)
1621 {
1622 availability = "https://schema.org/InStock";
1623 }
1624 else
1625 {
1626 availability = "https://schema.org/OutOfStock";
1627 }
1628
1629 <text>
1630 {
1631 "@@type": "ListItem",
1632 "position": @productScheme.Index,
1633 "item": {
1634 "@@type": "Product",
1635 "name": "@productScheme.GetString("Ecom:Product.Name")",
1636 "url": "@productUrl",
1637 "image": "@productImage",
1638 "offers": {
1639 "@@type": "Offer",
1640 "priceCurrency": "@productScheme.GetString("Ecom:Product.Currency.Code")",
1641 "availability": "@availability",
1642 "price": @Dynamicweb.Core.Converter.ToString(productScheme.GetDouble("Ecom:Product.Price.PriceWithoutVAT")).Replace(",", ".")
1643 }
1644 }
1645 },
1646 </text>
1647 }
1648 ]
1649 }
1650
1651 var jsonLdScript = document.createElement('script');
1652 jsonLdScript.type = 'application/ld+json';
1653 jsonLdScript.text = JSON.stringify(listitemLd);
1654 document.head.appendChild(jsonLdScript);
1655 });
1656 </script>
1657 }
1658 @SnippetEnd("BeforeBodyEndScripts")