Komponent editor til: Product list card
Error executing template "Designs/Swift/Paragraph/Swift_ProductDefaultImage.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_cce62b418d86416b9e8a9413e376658d.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_ProductDefaultImage.cshtml:line 33 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 Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 4 5 @{ 6 ProductViewModel product = new ProductViewModel(); 7 8 ProductViewModelSettings productSetting = new ProductViewModelSettings 9 { 10 LanguageId = Dynamicweb.Ecommerce.Common.Context.LanguageID, 11 CurrencyCode = Dynamicweb.Ecommerce.Common.Context.Currency.Code, 12 CountryCode = Dynamicweb.Ecommerce.Common.Context.Country.Code2, 13 ShopId = Pageview.Area.EcomShopId 14 }; 15 16 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 17 { 18 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 19 } 20 else if (Pageview.Item["DummyProduct"] != null) 21 { 22 string dummyProductId = ""; 23 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 24 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 25 if (productList.Products != null) 26 { 27 foreach (var p in productList.Products) { dummyProductId = p.Id; } 28 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 29 product = dummyProduct; 30 } 31 else 32 { 33 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 34 } 35 } 36 else if (Pageview.Item["DummyProduct"] == null) 37 { 38 product = ViewModelFactory.CreateView(productSetting, Dynamicweb.Ecommerce.Services.Products.GetLastActiveProducts(1, Dynamicweb.Ecommerce.Common.Context.LanguageID, false).FirstOrDefault().Id); 39 } 40 41 string imagePath = product?.DefaultImage?.Value ?? ""; 42 imagePath = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 43 44 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 45 ratio = ratio != "0" ? ratio : ""; 46 string ratioCssClass = ratio != "" ? " ratio" : ""; 47 string ratioVariable = ratio != "" ? "--bs-aspect-ratio: " + ratio : ""; 48 49 string width = Model.Item.GetRawValueString("Width", "auto"); 50 int smallImageSize = 640; 51 int largeImageSize = width == "auto" ? 1280 : Convert.ToInt32(width); 52 53 string imagePathXs = "/Admin/Public/GetImage.ashx?width=" + smallImageSize + "&image=" + imagePath + "&format=webp"; 54 string imagePathS = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + imagePath + "&format=webp"; 55 string imagePathFallBack = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + imagePath + "&format=webp"; 56 57 var badgeParms = new Dictionary<string, object>(); 58 badgeParms.Add("size", "h7"); 59 badgeParms.Add("saleBadgeType", Model.Item.GetRawValue("SaleBadgeType")); 60 badgeParms.Add("saleBadgeCssClassName", Model.Item.GetRawValue("SaleBadgeDesign")); 61 badgeParms.Add("newBadgeCssClassName", Model.Item.GetRawValue("NewBadgeDesign")); 62 badgeParms.Add("newPublicationDays", Model.Item.GetInt32("NewPublicationDays")); 63 badgeParms.Add("campaignBadgesValues", Model.Item.GetRawValueString("CampaignBadges")); 64 65 string badgeSize = Model.Item.GetRawValueString("BadgeSize", "fs-2"); 66 67 bool showFavoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowAddToFavorites")) ? Model.Item.GetBoolean("ShowAddToFavorites") : false; 68 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 69 bool anonymousUser = Pageview.User == null; 70 71 var favoriteParameters = new Dictionary<string, object>(); 72 if (!anonymousUser && showFavoritesSelector) 73 { 74 int defaultFavoriteListId = 0; 75 76 IEnumerable<FavoriteList> favoreiteLists = Pageview.User.GetFavoriteLists(); 77 if (favoreiteLists.Count() == 1) 78 { 79 foreach (FavoriteList list in favoreiteLists) 80 { 81 defaultFavoriteListId = list.ListId; 82 } 83 } 84 85 favoriteParameters.Add("ListId", defaultFavoriteListId); 86 } 87 88 var selectedImageCategories = Model.Item.GetRawValueString("GetAlternativeImageFrom").Split(',').ToList(); 89 List<MediaViewModel> allAssetsImages = product.AssetCategories.Where(x => selectedImageCategories.Contains(x.SystemName)).SelectMany(x => x.Assets).ToList(); 90 allAssetsImages.RemoveAll(x => x.Value == product.DefaultImage.Value); 91 MediaViewModel alternativeImage = allAssetsImages.FirstOrDefault(); 92 93 string altImagePathXs = string.Empty; 94 string altImagePathS = string.Empty; 95 96 if (!string.IsNullOrEmpty(alternativeImage?.Value)) 97 { 98 altImagePathXs = "/Admin/Public/GetImage.ashx?width=" + smallImageSize + "&image=" + Dynamicweb.Context.Current.Server.UrlEncode(alternativeImage.Value) + "&format=webp"; 99 altImagePathS = "/Admin/Public/GetImage.ashx?width=" + largeImageSize + "&image=" + Dynamicweb.Context.Current.Server.UrlEncode(alternativeImage.Value) + "&format=webp"; 100 } 101 102 @* Theme settings *@ 103 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 104 string themeBorder = !string.IsNullOrWhiteSpace(theme) ? "border: 1px solid rgba(0,0,0,0)" : ""; 105 string themePadding = !string.IsNullOrWhiteSpace(theme) ? "p-2 p-lg-3" : ""; 106 } 107 108 @if (product.Id != null) 109 { 110 string imageId = "ProductImage_" + product.Id + product.VariantId; 111 112 bool saleBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("SaleBadgeDesign")) && Model.Item.GetRawValueString("SaleBadgeDesign") != "none" ? true : false; 113 bool newBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("NewBadgeDesign")) && Model.Item.GetRawValueString("NewBadgeDesign") != "none" ? true : false; 114 DateTime createdDate = product.Created.Value; 115 bool showBadges = saleBadgeEnabled && product.Discount.Price != 0 ? true : false; 116 showBadges = (newBadgeEnabled && Model.Item.GetInt32("NewPublicationDays") == 0) || (newBadgeEnabled && (createdDate.AddDays(Model.Item.GetInt32("NewPublicationDays")) > DateTime.Now)) ? true : showBadges; 117 showBadges = !string.IsNullOrEmpty(Model.Item.GetRawValueString("CampaignBadges")) ? true : showBadges; 118 119 string fullWidth = width == "auto" ? "w-100" : ""; 120 string customWidth = width != "auto" ? "style=\"width: " + width + "px\"" : "style=\"min-width: 60px\""; 121 122 123 if (!string.IsNullOrEmpty(imagePath)) 124 { 125 <div class="h-100 @fullWidth @theme position-relative item_@Model.Item.SystemName.ToLower()" @customWidth> 126 <div class="ratio" style="@(ratioVariable)"> 127 <div class="d-flex justify-content-center align-items-center"> 128 <img id="@imageId" 129 srcset=" 130 @imagePathXs @(smallImageSize)w, 131 @imagePathS @(largeImageSize)w" 132 sizes="(min-width: 992px) 33vw, 50vw" 133 src="@imagePathFallBack" 134 @if (!string.IsNullOrEmpty(alternativeImage?.Value)) { <text> 135 data-alternative-image=" 136 @altImagePathXs @(smallImageSize)w, 137 @altImagePathS @(largeImageSize)w" 138 onmouseover="swift.Image.swapImage(event)" 139 onmouseout="swift.Image.swapImage(event)" 140 </text> } 141 loading="lazy" 142 decoding="async" 143 class="h-100 w-100 @themePadding" 144 style="object-fit: contain; @themeBorder" 145 alt="@product.Name"> 146 </div> 147 </div> 148 149 @if (showBadges) 150 { 151 <div class="position-absolute top-0 left-0 p-2 p-lg-3 ps-0 ps-lg-0 @badgeSize"> 152 @RenderPartial("Components/EcommerceBadge.cshtml", product, badgeParms) 153 </div> 154 } 155 156 @if (!anonymousUser) 157 { 158 if (showFavoritesSelector) 159 { 160 <div class="position-absolute top-0 end-0 my-3" style="z-index: 2"> 161 @RenderPartial("Components/ToggleFavorite.cshtml", product, favoriteParameters) 162 </div> 163 } 164 } 165 </div> 166 } 167 } 168 else if (Pageview.IsVisualEditorMode) 169 { 170 <div class="alert alert-dark m-0">@Translate("No products available")</div> 171 } 172
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_cb5780544d93421792c3061d87687613.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.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/Paragraph/Swift_ProductNumber.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_3bfdab0d1b9d4e14a3fd587bfbeab8a7.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\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 <div class="fs-7 opacity-85 @horizontalAlign item_@Model.Item.SystemName.ToLower()" itemprop="sku">@product.Number</div> 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_ProductPrice_custom.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_8b2eab837e5442ff8fd9242830c50eee.Execute() in D:\dynamicweb.net\Solutions\Dynamicweb\scrouples.cloud.dynamicweb-cms.com\files\Templates\Designs\Swift\Paragraph\Swift_ProductPrice_custom.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 { 17 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 18 } else if (Pageview.Item["DummyProduct"] != null) { 19 20 string dummyProductId = ""; 21 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 22 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 23 if (productList.Products != null) 24 { 25 foreach (var p in productList.Products) { dummyProductId = p.Id; } 26 ProductViewModel dummyProduct = dummyProductId != "" ? ViewModelFactory.CreateView(productSetting, dummyProductId) : new ProductViewModel(); 27 product = dummyProduct; 28 } else { 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 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 36 bool anonymousUser = Pageview.User == null; 37 bool isErpConnectionDown = !Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsWebServiceConnectionAvailable(); 38 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHidePrices") && isErpConnectionDown; 39 40 bool showInformativePrice = Model.Item.GetBoolean("ShowInformativePrice"); 41 string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : string.Empty; 42 43 string priceFontSize = Model.Item.GetRawValueString("PriceSize", "fs-2"); 44 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 45 string layout = Model.Item.GetRawValueString("Layout", "horizontal"); 46 string textAlign = horizontalAlign == "center" ? "text-center" : string.Empty; 47 textAlign = horizontalAlign == "end" ? "text-end" : textAlign; 48 49 horizontalAlign = horizontalAlign == "center" && layout == "horizontal" ? "justify-content-center" : horizontalAlign; 50 horizontalAlign = horizontalAlign == "end" && layout == "horizontal" ? "justify-content-end" : horizontalAlign; 51 horizontalAlign = horizontalAlign == "center" && layout == "vertical" ? "align-items-center" : horizontalAlign; 52 horizontalAlign = horizontalAlign == "end" && layout == "vertical" ? "align-items-end" : horizontalAlign; 53 54 string flexDirection = layout == "horizontal" ? string.Empty : "flex-column"; 55 string flexGap = layout == "horizontal" ? "gap-3" : string.Empty; 56 string order = layout == "horizontal" ? string.Empty : "order-2"; 57 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? "theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 58 theme = GetViewParameter("theme") != null ? GetViewParameterString("theme") : theme; 59 60 string contentPadding = Model.Item.GetRawValueString("ContentPadding", ""); 61 contentPadding = contentPadding == "none" ? "p-0" : contentPadding; 62 contentPadding = contentPadding == "small" ? "p-1 px-md-2 py-md-1" : contentPadding; 63 contentPadding = contentPadding == "large" ? "p-2 px-md-3 py-md-2" : contentPadding; 64 } 65 66 @if (!hidePrice && product.Id != null) 67 { 68 string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower(); 69 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 70 71 string priceMin = ""; 72 string priceMax = ""; 73 74 string liveInfoClass = ""; 75 string productInfoFeed = ""; 76 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Ecommerce.DynamicwebLiveIntegration.TemplatesHelper.IsLazyLoadingForProductInfoEnabled; 77 if (isLazyLoadingForProductInfoEnabled) 78 { 79 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 80 { 81 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 82 if (!string.IsNullOrEmpty(productInfoFeed)) 83 { 84 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 85 } 86 } 87 liveInfoClass = "js-live-info"; 88 } 89 90 <div class="@textAlign @liveInfoClass item_@Model.Item.SystemName.ToLower()" data-product-id="@product.Id" @productInfoFeed> 91 @if (showInformativePrice && product.PriceInformative.Price != 0) 92 { 93 <div class="opacity-50"> 94 <span>@Translate("RRP") </span> 95 <span class="text-decoration-line-through text-price">@product.PriceInformative.PriceFormatted</span> 96 </div> 97 } 98 <div class="@priceFontSize m-0 d-flex @flexDirection @flexGap @horizontalAlign" itemprop="offers" itemscope itemtype="https://schema.org/Offer"> 99 <span itemprop="priceCurrency" content="@product.Price.CurrencyCode" class="d-none"></span> 100 101 102 @if (showPricesWithVat == "false" && !neverShowVat) 103 { 104 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 105 { 106 <span itemprop="price" content="" class="d-none"></span> 107 <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> 108 } 109 else 110 { 111 string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceWithoutVatFormatted : product.PriceBeforeDiscount.PriceWithoutVatFormatted; 112 113 <span itemprop="price" content="@product.Price.PriceWithoutVat" class="d-none"></span> 114 if (product.Price.Price != product.PriceBeforeDiscount.Price) 115 { 116 <span class="text-decoration-line-through opacity-75 @order">@beforePrice</span> 117 } 118 } 119 } 120 else 121 { 122 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 123 { 124 <span itemprop="price" content="" class="d-none"></span> 125 <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> 126 } 127 else 128 { 129 string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceFormatted : product.PriceBeforeDiscount.PriceFormatted; 130 131 <span itemprop="price" content="@product.Price.Price" class="d-none"></span> 132 133 if (product.Price.Price != product.PriceBeforeDiscount.Price) 134 { 135 <span class="text-decoration-line-through opacity-75 @order"> 136 <span class="text-price">@beforePrice</span> 137 </span> 138 } 139 } 140 } 141 142 @if (showPricesWithVat == "false" && !neverShowVat) 143 { 144 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 145 { 146 <span class="text-price js-text-price"> 147 <span class="spinner-border" role="status"></span> 148 </span> 149 } 150 else 151 { 152 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceWithoutVatFormatted : product.Price.PriceWithoutVatFormatted; 153 154 if (product?.VariantInfo?.VariantInfo != null) 155 { 156 priceMin = product?.VariantInfo?.PriceMin?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithoutVatFormatted : ""; 157 priceMax = product?.VariantInfo?.PriceMax?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithoutVatFormatted : ""; 158 } 159 if (priceMin != priceMax) 160 { 161 price = priceMin + " - " + priceMax; 162 } 163 <span class="@theme @contentPadding"> 164 <span class="text-price">@price</span> 165 </span> 166 } 167 } 168 else 169 { 170 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 171 { 172 <span class="text-price js-text-price"> 173 <span class="spinner-border" role="status"></span> 174 </span> 175 } 176 else 177 { 178 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceFormatted : product.Price.PriceFormatted; 179 180 if (product?.VariantInfo?.VariantInfo != null) 181 { 182 priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted != null ? product.VariantInfo.PriceMin.PriceFormatted : ""; 183 priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted != null ? product.VariantInfo.PriceMax.PriceFormatted : ""; 184 } 185 if (priceMin != priceMax) 186 { 187 price = priceMin + " - " + priceMax; 188 } 189 <span class="@theme @contentPadding"> 190 <span class="text-price">@price</span> 191 </span> 192 } 193 } 194 195 @* Stock state for Schema.org, start *@ 196 @{ 197 Uri url = Dynamicweb.Context.Current.Request.Url; 198 } 199 200 <link itemprop="url" href="@url"> 201 202 @{ 203 bool IsNeverOutOfStock = product.NeverOutOfstock; 204 } 205 206 @if (IsNeverOutOfStock) 207 { 208 <span itemprop="availability" class="d-none">@Translate("Available in stock")</span> 209 } 210 else 211 { 212 if (product.StockLevel > 0) 213 { 214 <span itemprop="availability" class="d-none">InStock</span> 215 } 216 else 217 { 218 <span itemprop="availability" class="d-none">OutOfStock</span> 219 } 220 } 221 @* Stock state for Schema.org, stop *@ 222 223 </div> 224 @if (false) //showPricesWithVat == "false" && !neverShowVat) 225 { 226 if (isLazyLoadingForProductInfoEnabled && !Pageview.IsVisualEditorMode) 227 { 228 <small class="opacity-85 fst-normal js-text-price-with-vat d-none" data-suffix="@Translate("Incl. VAT")"></small> 229 } 230 else 231 { 232 string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceWithVatFormatted : product.Price.PriceWithVatFormatted; 233 234 if (product?.VariantInfo?.VariantInfo != null) 235 { 236 priceMin = product?.VariantInfo?.PriceMin?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithVatFormatted : ""; 237 priceMax = product?.VariantInfo?.PriceMax?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithVatFormatted : ""; 238 } 239 if (priceMin != priceMax) 240 { 241 price = priceMin + " - " + priceMax; 242 } 243 <small class="opacity-85 fst-normal">@price @Translate("Incl. VAT")</small> 244 } 245 } 246 </div> 247 } else if (Pageview.IsVisualEditorMode) { 248 <div class="alert alert-dark m-0" role="alert"> 249 <span>@Translate("No products available")</span> 250 </div> 251 } 252