Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_ProductMedia.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_ffbe162092a5429e970e73b5e2189238.<ExecuteAsync>b__0_3(MediaViewModel asset) at System.Linq.Enumerable.Count[TSource](IEnumerable`1 source, Func`2 predicate) at CompiledRazorTemplates.Dynamic.RazorEngine_ffbe162092a5429e970e73b5e2189238.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> @using Dynamicweb.Ecommerce.ProductCatalog @using Dynamicweb.Frontend @using System.IO @using System.Text.RegularExpressions; @functions { public ProductViewModel product { get; set; } = new ProductViewModel(); public string galleryLayout { get; set; } public string[] supportedImageFormats { get; set; } public string[] supportedVideoFormats { get; set; } public string[] supportedDocumentFormats { get; set; } public string[] allSupportedFormats { get; set; } public class RatioSettings { public string Ratio { get; set; } public string CssClass { get; set; } public string CssVariable { get; set; } public string Fill { get; set; } } public RatioSettings GetRatioSettings(string size = "desktop") { var ratioSettings = new RatioSettings(); string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); ratio = ratio != "0" ? ratio : ""; string cssClass = ratio != "" && ratio != "fill" ? " ratio" : ""; string cssVariable = ratio != "" && ratio != "fill" ? "--bs-aspect-ratio: " + ratio : ""; cssClass = ratio == "fill" && size == "mobile" ? " ratio" : cssClass; cssVariable = ratio == "fill" && size == "mobile" ? "--bs-aspect-ratio: 66%" : cssVariable; ratioSettings.Ratio = ratio; ratioSettings.CssClass = cssClass; ratioSettings.CssVariable = cssVariable; ratioSettings.Fill = ratio == "fill" ? " h-100" : ""; return ratioSettings; } public string GetArrowsColor() { var invertColor = Model.Item.GetBoolean("InvertModalArrowsColor"); var arrowsColor = invertColor ? " carousel-dark" : string.Empty; return arrowsColor; } public string GetThumbnailPlacement() { return Model.Item.GetRawValueString("ThumbnailPlacement", "bottom"); } public string GetThumbnailRowSettingCss() { switch (GetThumbnailPlacement()) { case "bottom": return "d-flex flex-wrap"; case "left": return "d-flex flex-column order-first"; case "right": return "d-flex flex-column order-last"; default: return "d-flex flex-wrap"; } } public string GetVideoType(string assetValue) { string type = assetValue.IndexOf("youtu.be", StringComparison.OrdinalIgnoreCase) >= 0 || assetValue.IndexOf("youtube", StringComparison.OrdinalIgnoreCase) >= 0 ? "youtube" : string.Empty; type = assetValue.IndexOf("vimeo", StringComparison.OrdinalIgnoreCase) >= 0 ? "vimeo" : type; type = string.IsNullOrEmpty(type) ? "selfhosted" : type; return type; } public string GetYoutubeScreenDump(string assetValue, string quality) { var regex = new Regex(@"(?:youtube\.com\/.*[\?&]v=|youtu\.be\/|youtube\.com\/embed\/)([\w-]+)(?:\?.*)?"); Match match = regex.Match(assetValue); string videoId = match.Success ? match.Groups[1].Value : string.Empty; string youtubeThumbnail = $"https://img.youtube.com/vi/{videoId}/{quality}.jpg"; return youtubeThumbnail; } public string GetFileTypeIcon(string filePath) { string fileType = Path.GetExtension(filePath).ToLower(); string fileTypeIconPath = "/Files/Templates/Designs/Swift-v2/Assets/images/FileTypes/"; var iconMap = new Dictionary<string, string> { { ".pdf", $"{fileTypeIconPath}pdf.svg" }, { ".docx", $"{fileTypeIconPath}docx.svg" }, { ".xlsx", $"{fileTypeIconPath}xlsx.svg" }, { ".ppt", $"{fileTypeIconPath}ppt.svg" } }; return iconMap.ContainsKey(fileType) ? iconMap[fileType] : $"/Files/Images/Icons/download.svg"; } public bool MatchesFormat(string assetValue, string[] formats) { return formats.Any(format => assetValue.IndexOf(format, StringComparison.OrdinalIgnoreCase) >= 0); } } @{ ProductViewModel product = null; if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) { product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; } } @if (product is object) { @* Supported formats *@ supportedImageFormats = new string[] { ".jpg", ".jpeg", ".webp", ".png", ".gif", ".bmp", ".tiff" }; supportedVideoFormats = new string[] { "youtu.be", "youtube", "vimeo", ".mp4", ".webm" }; supportedDocumentFormats = new string[] { ".pdf", ".docx", ".xlsx", ".ppt", "pptx" }; allSupportedFormats = supportedImageFormats.Concat(supportedVideoFormats).Concat(supportedDocumentFormats).ToArray(); @* Collect the assets *@ var selectedAssetCategories = Model.Item.GetList("ImageAssets")?.GetRawValue().OfType<string>(); bool includeImagePatternImages = Model.Item.GetBoolean("ImagePatternImages"); @* Needed image data collection to support both DefaultImage, ImagePatterns and Image Assets *@ string defaultImage = product.DefaultImage != null ? product.DefaultImage.Value : ""; IEnumerable<MediaViewModel> assetsImages = product.AssetCategories.Where(x => selectedAssetCategories.Contains(x.SystemName)).SelectMany(x => x.Assets); assetsImages = assetsImages.OrderByDescending(x => x.Value.Equals(defaultImage)); IEnumerable<MediaViewModel> assetsList = new MediaViewModel[] { }; assetsList = assetsList.Union(assetsImages); assetsList = includeImagePatternImages ? assetsList.Union(product.ImagePatternImages) : assetsList; assetsList = includeImagePatternImages && assetsList.Count() == 0 ? assetsList.Append(product.DefaultImage) : assetsList; bool defaultImageFallback = Model.Item.GetBoolean("DefaultImageFallback"); bool showOnlyPrimaryImage = Model.Item.GetBoolean("ShowOnlyPrimaryImage"); int totalAssets = 0; if (showOnlyPrimaryImage == false) { totalAssets = assetsList.Count(asset => MatchesFormat(asset.Value, allSupportedFormats)); } if ((totalAssets == 0 && product.DefaultImage != null && selectedAssetCategories.Count() == 0) || (showOnlyPrimaryImage == true && product.DefaultImage != null) || totalAssets == 0 && defaultImageFallback) { assetsList = new List<MediaViewModel>() { product.DefaultImage }; totalAssets = 1; } @* Get assets from selected categories or get all assets *@ if (totalAssets != 0) { int assetNumber = 0; int thumbnailNumber = 0; int modalAssetNumber = 0; string thumbnailAxisCss = GetThumbnailPlacement() == "bottom" ? "flex-column" : string.Empty; <div class="d-flex gap-3 h-100 @(thumbnailAxisCss) item_@Model.Item.SystemName.ToLower()" data-dw-colorscheme="@Model.ColorScheme?.Id"> <div id="SmallScreenImages_@Model.ID" class="carousel@(GetArrowsColor()) col position-relative" data-bs-ride="carousel"> <div class="carousel-inner h-100"> @foreach (MediaViewModel asset in assetsList) { var assetValue = asset.Value; foreach (string format in allSupportedFormats) { if (assetValue.IndexOf(format, StringComparison.OrdinalIgnoreCase) >= 0) { string activeSlide = assetNumber == 0 ? "active" : ""; <div class="carousel-item @activeSlide" data-bs-interval="99999"> @{ string size = "mobile"; <div class="h-100"> @foreach (string imageFormat in supportedImageFormats) { //Images if (assetValue.IndexOf(imageFormat, StringComparison.OrdinalIgnoreCase) >= 0) { if (product is object) { string productName = product.Name; string imagePath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; RatioSettings ratioSettings = GetRatioSettings(size); var parms = new Dictionary<string, object>(); parms.Add("alt", productName + asset.Keywords); parms.Add("itemprop", "image"); parms.Add("columns", Model.GridRowColumnCount); parms.Add("eagerLoadNewImages", Model.Item.GetBoolean("DisableLazyLoading")); parms.Add("doNotUseGetimage", Model.Item.GetBoolean("DisableGetImage")); if (!string.IsNullOrEmpty(asset.DisplayName)) { parms.Add("title", asset.DisplayName); } if (ratioSettings.Ratio == "fill" && galleryLayout != "grid") { parms.Add("cssClass", "w-100 h-100 image-zoom-lg-l-hover"); } else { parms.Add("cssClass", "mw-100 mh-100"); } <a href="@imagePath" class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)" data-bs-toggle="modal" data-bs-target="#modal_@Model.ID"> <div class="d-flex align-items-center justify-content-center overflow-hidden h-100" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide-to="@assetNumber"> @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) </div> </a> } } } @foreach (string videoFormat in supportedVideoFormats) { //Videos if (assetValue.IndexOf(videoFormat, StringComparison.OrdinalIgnoreCase) >= 0) { if (product is object) { var video = asset.GetVideoViewModel(); if (Model.Item.GetString("OpenVideoInModal") == "true") { string iconPath = "/Files/Images/Icons/"; string productName = product.Name; productName += !string.IsNullOrEmpty(asset.Keywords) ? " " + asset.Keywords : ""; string assetTitle = !string.IsNullOrEmpty(asset.DisplayName) ? "title=\"" + asset.DisplayName + "\"" : ""; RatioSettings ratioSettings = GetRatioSettings(size); string type = GetVideoType(asset.Value); string videoScreendumpPath = type == "youtube" ? GetYoutubeScreenDump(asset.Value, "maxresdefault") : string.Empty; string videoJsClass = type == "vimeo" ? "js-vimeo-video-thumbnail" : ""; <div class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable); cursor: pointer" data-bs-toggle="modal" data-bs-target="#modal_@Model.ID"> <div class="d-flex align-items-center justify-content-center overflow-hidden h-100" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide-to="@assetNumber"> <div class="icon-5 position-absolute" style="z-index: 1">@ReadFile(iconPath + "play-circle.svg")</div> @if (video.IsExternalLink()) { <img src="@videoScreendumpPath" loading="lazy" decoding="async" alt="@productName" @assetTitle class="@videoJsClass mw-100 mh-100" data-asset-value="@asset.Value" style="object-fit: cover;"> } else { <video preload="auto" class="h-100 w-100" style="object-fit: contain;"> <source src="@(asset.Value)#t=0.001" type="@video.GetVideoType()"> </video> } </div> </div> } else { @RenderPartial("Components/VideoPlayer.cshtml", video) } } } } @foreach (string documentFormat in supportedDocumentFormats) { //Documents if (assetValue.IndexOf(documentFormat, StringComparison.OrdinalIgnoreCase) >= 0) { if (product is object) { string productName = product.Name; string imagePath = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; string fileTypeIcon = GetFileTypeIcon(asset.Value); RatioSettings ratioSettings = GetRatioSettings(size); var parms = new Dictionary<string, object>(); parms.Add("alt", productName + asset.Keywords); parms.Add("itemprop", "image"); parms.Add("fullwidth", true); parms.Add("columns", Model.GridRowColumnCount); if (!string.IsNullOrEmpty(asset.DisplayName)) { parms.Add("title", asset.DisplayName); } if (ratioSettings.Ratio == "fill" && galleryLayout != "grid") { parms.Add("cssClass", "w-100 h-100 image-zoom-lg-l-hover"); } else { parms.Add("cssClass", "mw-100 mh-100"); } <a href="@imagePath" class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)" download title="@Translate("Download"): @(asset.Name)@Path.GetExtension(asset.Value).ToLower()"> <div class="d-flex align-items-center justify-content-center text-center overflow-hidden h-100 border"> <div class="icon-5 position-absolute" style="z-index: 1"> @ReadFile(fileTypeIcon) </div> </div> </a> } } } </div> } </div> assetNumber++; } } } </div> </div> @if (totalAssets > 1) { <div class="@(GetThumbnailRowSettingCss()) gap-3" id="SmallScreenImagesThumbnails_@Model.ID"> @foreach (MediaViewModel asset in assetsList) { var assetValue = asset.Value; string assetName = asset.Name; assetName += !string.IsNullOrEmpty(asset.Keywords) ? " " + asset.Keywords : ""; string assetTitle = !string.IsNullOrEmpty(asset.DisplayName) ? asset.DisplayName : null; string iconPath = "/Files/Images/Icons/"; string imagePath = assetValue; imagePath = assetValue.IndexOf("youtu.be", StringComparison.OrdinalIgnoreCase) >= 0 || assetValue.IndexOf("youtube", StringComparison.OrdinalIgnoreCase) >= 0 ? "https://img.youtube.com/vi/" + assetValue.Substring(assetValue.LastIndexOf('/') + 1) + "/mqdefault.jpg" : imagePath; string imagePathThumb = assetValue.StartsWith("/Files/", StringComparison.OrdinalIgnoreCase) ? imagePath.IndexOf("youtube", StringComparison.OrdinalIgnoreCase) < 0 && imagePath.IndexOf(".mp4", StringComparison.OrdinalIgnoreCase) < 0 ? $"/Admin/Public/GetImage.ashx?image={imagePath}&width=180&format=webp" : imagePath : assetValue; RatioSettings ratioSettings = GetRatioSettings("desktop"); <div class="border outline-none position-relative flex-grow-0 flex-shrink-0 @(ratioSettings.CssClass)" style="@(ratioSettings.CssVariable); cursor: pointer; width: clamp(4.5rem, 18vw, 8rem);" data-bs-target="#SmallScreenImages_@Model.ID" data-bs-slide-to="@thumbnailNumber"> @foreach (string imageFormat in supportedImageFormats) { //Images if (assetValue.IndexOf(imageFormat, StringComparison.OrdinalIgnoreCase) >= 0) { <img src="@imagePathThumb" alt="@assetName" class="p-0 p-lg-1 w-100 h-100" style="object-fit: contain;"> thumbnailNumber++; } } @foreach (string videoFormat in supportedVideoFormats) { //Videos if (assetValue.IndexOf(videoFormat, StringComparison.OrdinalIgnoreCase) >= 0) { var video = asset.GetVideoViewModel(); string type = GetVideoType(asset.Value); string videoScreendumpPath = type == "youtube" ? GetYoutubeScreenDump(asset.Value, "mqdefault") : ""; videoScreendumpPath = type == "vimeo" ? string.Empty : videoScreendumpPath; string videoJsClass = type == "vimeo" ? "js-vimeo-video-thumbnail" : string.Empty; <div class="icon-5 position-absolute top-50 start-50 translate-middle" style="z-index: 1">@ReadFile(iconPath + "play-circle.svg")</div> if (video.IsExternalLink()) { <img src="@videoScreendumpPath" loading="lazy" decoding="async" alt="@assetTitle" @assetTitle class="@videoJsClass mw-100 mh-100" data-asset-value="@asset.Value" style="object-fit: cover;" /> } else { <video preload="auto" class="h-100 w-100" style="object-fit: contain;"> <source src="@(asset.Value)#t=0.001" type="@video.GetVideoType()"> </video> } thumbnailNumber++; } } @foreach (string documentFormat in supportedDocumentFormats) { //Documents if (assetValue.IndexOf(documentFormat, StringComparison.OrdinalIgnoreCase) >= 0) { string fileTypeIcon = GetFileTypeIcon(asset.Value); <a href="@assetValue" class="ratio ratio-4x3 border outline-none" style="cursor: pointer; min-width: 4rem; max-width: 8rem;" download title="@Translate("Download"): @(asset.Name)@Path.GetExtension(asset.Value).ToLower()"> <div class="d-flex align-items-center justify-content-center text-center overflow-hidden h-100 border"> <div class="icon-5 position-absolute" style="z-index: 1">@ReadFile(fileTypeIcon)</div> </div> </a> thumbnailNumber++; } } </div> } </div> } </div> @* Modal with slides *@ <div class="modal fade" id="modal_@Model.ID" tabindex="-1" aria-labelledby="mediaModalTitle_@Model.ID" aria-hidden="true"> <div class="modal-dialog modal-dialog-centered modal-xl"> <div class="modal-content"> <div class="modal-header visually-hidden"> <h5 class="modal-title" id="mediaModalTitle_@Model.ID">@product.Title</h5> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body p-2 p-lg-3 h-100"> <div id="ModalCarousel_@Model.ID" class="carousel@(GetArrowsColor()) h-100" data-bs-ride="carousel"> <div class="carousel-inner h-100" data-dw-colorscheme="@Model.ColorScheme?.Id"> @foreach (MediaViewModel asset in assetsList) { var assetValue = !string.IsNullOrEmpty(asset.Value) ? asset.Value : product.DefaultImage.Value; foreach (string supportedFormat in supportedImageFormats.Concat(supportedVideoFormats).ToArray()) { if (assetValue.IndexOf(supportedFormat, StringComparison.OrdinalIgnoreCase) >= 0) { string imagePath = assetValue; string activeSlide = modalAssetNumber == 0 ? "active" : ""; var parms = new Dictionary<string, object>(); parms.Add("cssClass", "d-block mw-100 mh-100 m-auto"); parms.Add("fullwidth", true); parms.Add("columns", Model.GridRowColumnCount); <div class="carousel-item @activeSlide h-100" data-bs-interval="99999"> @foreach (string imageFormat in supportedImageFormats) { //Images if (assetValue.IndexOf(imageFormat, StringComparison.OrdinalIgnoreCase) >= 0) { @RenderPartial("Components/Image.cshtml", new FileViewModel { Path = imagePath }, parms) } } @foreach (string videoFormat in supportedVideoFormats) { //Videos if (assetValue.IndexOf(videoFormat, StringComparison.OrdinalIgnoreCase) >= 0) { @RenderPartial("Components/VideoPlayer.cshtml", asset.GetVideoViewModel()) } } </div> modalAssetNumber++; } } } <button class="carousel-control-prev carousel-control-area" type="button" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide="prev"> <span class="carousel-control-prev-icon" aria-hidden="true"></span> <span class="visually-hidden">@Translate("Previous")</span> </button> <button class="carousel-control-next carousel-control-area" type="button" data-bs-target="#ModalCarousel_@Model.ID" data-bs-slide="next"> <span class="carousel-control-next-icon" aria-hidden="true"></span> <span class="visually-hidden">@Translate("Next")</span> </button> </div> </div> </div> </div> </div> </div> } else if (Pageview.IsVisualEditorMode) { RatioSettings ratioSettings = GetRatioSettings("desktop"); <div class="h-100" data-dw-colorscheme="@Model.ColorScheme?.Id"> <div class="d-block @(ratioSettings.CssClass)@(ratioSettings.Fill)" style="@(ratioSettings.CssVariable)"> <img src="/Files/Images/nopic.png" loading="lazy" decoding="async" class="mh-100 mw-100" style="object-fit: cover;"> </div> </div> } } else if (Pageview.IsVisualEditorMode) { <div class="alert alert-dark m-0">@Translate("The images will be shown here, if any")</div> }
GTw Avalanche 3.0 Disc Ladies
Error compiling template "Designs/Swift-v2/Paragraph/Swift-v2_ProductPrice.cshtml" Line 84: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. Line 85: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source. Line 148: 'PriceViewModel' does not contain a definition for 'TryGetVatLabel' and no accessible extension method 'TryGetVatLabel' accepting a first argument of type 'PriceViewModel' could be found (are you missing a using directive or an assembly reference?)
1 // <auto-generated/> 2 #pragma warning disable 1591 3 namespace CompiledRazorTemplates.Dynamic 4 { 5 #line hidden 6 using System.Threading.Tasks; 7 using System; 8 using System.Collections.Generic; 9 using System.Linq; 10 using Dynamicweb.Ecommerce.ProductCatalog; 11 using Dynamicweb.Ecommerce.Products; 12 internal class RazorEngine_2f751356dd7746bda12e8e72b41ef082 : Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 13 { 14 #pragma warning disable 1998 15 public async override global::System.Threading.Tasks.Task ExecuteAsync() 16 { 17 WriteLiteral("\n"); 18 ProductViewModel product = null; if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) { product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; } else if (Pageview.IsVisualEditorMode) { product = new ProductViewModel(); product.Price = new PriceViewModel() { Price = 99, PriceFormatted = "99 " + Pageview.Area.EcomCurrencyId, PriceWithoutVat = 99, PriceWithoutVatFormatted = "99 " + Pageview.Area.EcomCurrencyId, PriceWithVat = 99, PriceWithVatFormatted = "99 " + Pageview.Area.EcomCurrencyId }; product.PriceInformative = new PriceViewModel() { Price = 49, PriceFormatted = "49 " + Pageview.Area.EcomCurrencyId, PriceWithoutVat = 49, PriceWithoutVatFormatted = "49 " + Pageview.Area.EcomCurrencyId, PriceWithVat = 49, PriceWithVatFormatted = "49 " + Pageview.Area.EcomCurrencyId }; product.PriceBeforeDiscount = new PriceViewModel() { Price = 199, PriceFormatted = "199 " + Pageview.Area.EcomCurrencyId, PriceWithoutVat = 199, PriceWithoutVatFormatted = "199 " + Pageview.Area.EcomCurrencyId, PriceWithVat = 199, PriceWithVatFormatted = "99 " + Pageview.Area.EcomCurrencyId }; } string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); bool anonymousUser = Pageview.User == null; bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser; bool productIsDiscontinued = product is object && product.Discontinued; bool doNotShowPriceIfProductIsDiscontinued = Model.Item.GetBoolean("DoNotShowPriceIfProductIsDiscontinued"); var isDiscontinued = productIsDiscontinued && doNotShowPriceIfProductIsDiscontinued; string priceType = string.Empty; if (Dynamicweb.Context.Current.Items.Contains("PriceType")) { priceType = Dynamicweb.Context.Current.Items["PriceType"].ToString().ToLower(); } WriteLiteral("\n"); 19 if (product is object && !hidePrice && !isDiscontinued && priceType != "fixedprice") { bool showInformativePrice = Model.Item.GetBoolean("ShowInformativePrice"); string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : string.Empty; string priceFontSize = Model.Item.GetRawValueString("PriceSize", "fs-2"); string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); string layout = Model.Item.GetRawValueString("Layout", "horizontal"); string textAlign = horizontalAlign == "center" ? "text-center" : string.Empty; textAlign = horizontalAlign == "end" ? "text-end" : textAlign; horizontalAlign = horizontalAlign == "center" && layout == "horizontal" ? "justify-content-center" : horizontalAlign; horizontalAlign = horizontalAlign == "end" && layout == "horizontal" ? "justify-content-end" : horizontalAlign; horizontalAlign = horizontalAlign == "center" && layout == "vertical" ? "align-items-center" : horizontalAlign; horizontalAlign = horizontalAlign == "end" && layout == "vertical" ? "align-items-end" : horizontalAlign; string flexDirection = layout == "horizontal" ? "align-items-end" : "flex-column"; string flexGap = layout == "horizontal" ? "gap-3" : string.Empty; string order = layout == "horizontal" ? string.Empty : "order-2"; string? priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted; string? priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted; string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceFormatted : product?.Price.PriceFormatted; price = priceMin != priceMax ? price = priceMin + " - " + priceMax : price; string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceFormatted : product?.PriceBeforeDiscount.PriceFormatted; Uri url = Dynamicweb.Context.Current.Request.Url; bool IsNeverOutOfStock = product.NeverOutOfstock; WriteLiteral("\t<div"); 20 BeginWriteAttribute("class", " class=\"", 4037, "\"", 4095, 3); 21 WriteAttributeValue("", 4045, textAlign, 4045, 10, false); 22 WriteAttributeValue(" ", 4055, "item_", 4056, 6, true); 23 WriteAttributeValue("", 4061, Model.Item?.SystemName?.ToLower(), 4061, 34, false); 24 EndWriteAttribute(); 25 WriteLiteral(" data-product-id=\""); 26 Write(product?.Id); 27 WriteLiteral("\" data-variant-id=\""); 28 Write(product?.VariantId); 29 WriteLiteral("\">\n"); 30 if (showInformativePrice && product?.PriceInformative.Price != 0) { WriteLiteral("\t\t\t<div class=\"opacity-50\">\n\t\t\t\t<span>"); 31 Write(Translate("RRP")); 32 WriteLiteral(" </span>\n\t\t\t\t<span class=\"text-decoration-line-through text-price\">"); 33 Write(product?.PriceInformative.PriceFormatted); 34 WriteLiteral("</span>\n\t\t\t</div>\n"); 35 } WriteLiteral("\t\t<div"); 36 BeginWriteAttribute("class", " class=\"", 4431, "\"", 4515, 7); 37 WriteAttributeValue("", 4439, priceFontSize, 4439, 14, false); 38 WriteAttributeValue(" ", 4453, "m-0", 4454, 4, true); 39 WriteAttributeValue(" ", 4457, "d-flex", 4458, 7, true); 40 WriteAttributeValue(" ", 4464, "flex-wrap", 4465, 10, true); 41 WriteAttributeValue(" ", 4474, flexDirection, 4475, 14, false); 42 WriteAttributeValue(" ", 4489, flexGap, 4490, 8, false); 43 WriteAttributeValue(" ", 4498, horizontalAlign, 4499, 16, false); 44 EndWriteAttribute(); 45 WriteLiteral(" style=\"row-gap: 0 !important\" itemprop=\"offers\" itemscope itemtype=\"https://schema.org/Offer\">\n\t\t\t<span itemprop=\"priceCurrency\""); 46 BeginWriteAttribute("content", " content=\"", 4645, "\"", 4683, 1); 47 WriteAttributeValue("", 4655, product?.Price.CurrencyCode, 4655, 28, false); 48 EndWriteAttribute(); 49 WriteLiteral(" class=\"d-none\"></span>\n\t\t\t<span itemprop=\"price\""); 50 BeginWriteAttribute("content", " content=\"", 4733, "\"", 4764, 1); 51 WriteAttributeValue("", 4743, product?.Price.Price, 4743, 21, false); 52 EndWriteAttribute(); 53 WriteLiteral(" class=\"d-none\"></span>\n\n"); 54 if (product.HasDiscount()) { WriteLiteral("\t\t\t\t<span"); 55 BeginWriteAttribute("class", " class=\"", 4835, "\"", 4889, 3); 56 WriteAttributeValue("", 4843, "text-decoration-line-through", 4843, 28, true); 57 WriteAttributeValue(" ", 4871, "opacity-75", 4872, 11, true); 58 WriteAttributeValue(" ", 4882, order, 4883, 6, false); 59 EndWriteAttribute(); 60 WriteLiteral(">\n\t\t\t\t\t<span class=\"text-price\">"); 61 Write(beforePrice); 62 WriteLiteral("</span>\n\t\t\t\t</span>\n"); 63 } WriteLiteral("\t\t\t\n\t\t\t<span class=\"text-price\">"); 64 Write(price); 65 WriteLiteral("</span>\n"); 66 if (product.Price.TryGetVatLabel(out string vatLabel)) { WriteLiteral("\t\t\t\t<small class=\"opacity-85 fst-normal order-3\">"); 67 Write(Translate(vatLabel)); 68 WriteLiteral("</small>\n"); 69 } WriteLiteral("\t\t\t<link itemprop=\"url\""); 70 BeginWriteAttribute("href", " href=\"", 5216, "\"", 5227, 1); 71 WriteAttributeValue("", 5223, url, 5223, 4, false); 72 EndWriteAttribute(); 73 WriteLiteral(">\n\n"); 74 if (IsNeverOutOfStock) { WriteLiteral("\t\t\t\t<span itemprop=\"availability\" class=\"d-none\">"); 75 Write(Translate("Available in stock")); 76 WriteLiteral("</span>\n"); 77 } else if (product.StockLevel > 0) { WriteLiteral("\t\t\t\t<span itemprop=\"availability\" class=\"d-none\">"); 78 Write(Translate("In stock")); 79 WriteLiteral("</span>\n"); 80 } else { WriteLiteral("\t\t\t\t<span itemprop=\"availability\" class=\"d-none\">"); 81 Write(Translate("Out of stock")); 82 WriteLiteral("</span>\n"); 83 } WriteLiteral("\t\t</div>\n\t</div>\n"); 84 } else if (Pageview.IsVisualEditorMode) { WriteLiteral("\t<div class=\"alert alert-dark m-0\" role=\"alert\">\n\t\t<span>"); 85 Write(Translate("No products available")); 86 WriteLiteral("</span>\n\t</div>\n"); 87 } } 88 #pragma warning restore 1998 89 } 90 } 91 #pragma warning restore 1591 92
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> @using Dynamicweb.Ecommerce.ProductCatalog @using Dynamicweb.Ecommerce.Products @{ ProductViewModel product = null; if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) { product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; } else if (Pageview.IsVisualEditorMode) { product = new ProductViewModel(); product.Price = new PriceViewModel() { Price = 99, PriceFormatted = "99 " + Pageview.Area.EcomCurrencyId, PriceWithoutVat = 99, PriceWithoutVatFormatted = "99 " + Pageview.Area.EcomCurrencyId, PriceWithVat = 99, PriceWithVatFormatted = "99 " + Pageview.Area.EcomCurrencyId }; product.PriceInformative = new PriceViewModel() { Price = 49, PriceFormatted = "49 " + Pageview.Area.EcomCurrencyId, PriceWithoutVat = 49, PriceWithoutVatFormatted = "49 " + Pageview.Area.EcomCurrencyId, PriceWithVat = 49, PriceWithVatFormatted = "49 " + Pageview.Area.EcomCurrencyId }; product.PriceBeforeDiscount = new PriceViewModel() { Price = 199, PriceFormatted = "199 " + Pageview.Area.EcomCurrencyId, PriceWithoutVat = 199, PriceWithoutVatFormatted = "199 " + Pageview.Area.EcomCurrencyId, PriceWithVat = 199, PriceWithVatFormatted = "99 " + Pageview.Area.EcomCurrencyId }; } string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); bool anonymousUser = Pageview.User == null; bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser; bool productIsDiscontinued = product is object && product.Discontinued; bool doNotShowPriceIfProductIsDiscontinued = Model.Item.GetBoolean("DoNotShowPriceIfProductIsDiscontinued"); var isDiscontinued = productIsDiscontinued && doNotShowPriceIfProductIsDiscontinued; string priceType = string.Empty; if (Dynamicweb.Context.Current.Items.Contains("PriceType")) { priceType = Dynamicweb.Context.Current.Items["PriceType"].ToString().ToLower(); } } @if (product is object && !hidePrice && !isDiscontinued && priceType != "fixedprice") { bool showInformativePrice = Model.Item.GetBoolean("ShowInformativePrice"); string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : string.Empty; string priceFontSize = Model.Item.GetRawValueString("PriceSize", "fs-2"); string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); string layout = Model.Item.GetRawValueString("Layout", "horizontal"); string textAlign = horizontalAlign == "center" ? "text-center" : string.Empty; textAlign = horizontalAlign == "end" ? "text-end" : textAlign; horizontalAlign = horizontalAlign == "center" && layout == "horizontal" ? "justify-content-center" : horizontalAlign; horizontalAlign = horizontalAlign == "end" && layout == "horizontal" ? "justify-content-end" : horizontalAlign; horizontalAlign = horizontalAlign == "center" && layout == "vertical" ? "align-items-center" : horizontalAlign; horizontalAlign = horizontalAlign == "end" && layout == "vertical" ? "align-items-end" : horizontalAlign; string flexDirection = layout == "horizontal" ? "align-items-end" : "flex-column"; string flexGap = layout == "horizontal" ? "gap-3" : string.Empty; string order = layout == "horizontal" ? string.Empty : "order-2"; string? priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted; string? priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted; string price = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).Price.PriceFormatted : product?.Price.PriceFormatted; price = priceMin != priceMax ? price = priceMin + " - " + priceMax : price; string beforePrice = !string.IsNullOrEmpty(unitId) ? product.GetPrice(unitId).PriceBeforeDiscount.PriceFormatted : product?.PriceBeforeDiscount.PriceFormatted; Uri url = Dynamicweb.Context.Current.Request.Url; bool IsNeverOutOfStock = product.NeverOutOfstock; <div class="@textAlign item_@Model.Item?.SystemName?.ToLower()" data-product-id="@product?.Id" data-variant-id="@product?.VariantId"> @if (showInformativePrice && product?.PriceInformative.Price != 0) { <div class="opacity-50"> <span>@Translate("RRP") </span> <span class="text-decoration-line-through text-price">@product?.PriceInformative.PriceFormatted</span> </div> } <div class="@priceFontSize m-0 d-flex flex-wrap @flexDirection @flexGap @horizontalAlign" style="row-gap: 0 !important" itemprop="offers" itemscope itemtype="https://schema.org/Offer"> <span itemprop="priceCurrency" content="@product?.Price.CurrencyCode" class="d-none"></span> <span itemprop="price" content="@product?.Price.Price" class="d-none"></span> @if (product.HasDiscount()) { <span class="text-decoration-line-through opacity-75 @order"> <span class="text-price">@beforePrice</span> </span> } <span class="text-price">@price</span> @if (product.Price.TryGetVatLabel(out string vatLabel)) { <small class="opacity-85 fst-normal order-3">@Translate(vatLabel)</small> } @* Stock state for Schema.org, start *@ <link itemprop="url" href="@url"> @if (IsNeverOutOfStock) { <span itemprop="availability" class="d-none">@Translate("Available in stock")</span> } else if (product.StockLevel > 0) { <span itemprop="availability" class="d-none">@Translate("In stock")</span> } else { <span itemprop="availability" class="d-none">@Translate("Out of stock")</span> } @* Stock state for Schema.org, stop *@ </div> </div> } else if (Pageview.IsVisualEditorMode) { <div class="alert alert-dark m-0" role="alert"> <span>@Translate("No products available")</span> </div> }
- Brakes: Shimano Ultegra
- Gender: Women
- Brand name: GT bicycles
- Additional equipment: Bell Luggage racks Pump
- Brake type: Linear-pull
- Brakes: Shimano Ultegra
- Color:
- Frame: Synapse BallisTec Carbon
- Gear: 18
- Gear model: Shimano Deore M591
- Gear type: External Derailleur
- Gender: Women
- Material usage: Aluminum Steel
- Recommended use:
- Tires: Schwalbe Spicer (700x35c) m
- Wheel: Alunav - Bontrager Tubeless
- Wheel size: 700c
- Volume: 0 m³
- Weight: 0 kg
- Width: 0 mm
- Height: 0 mm
- Brake type: Linear-pull
- Gear: 18
- Wheel size: 700c
- Gear (# of): 18
Similar products