Error executing template "/Designs/Swift-v2/Paragraph/Custom_Swift-v2_ProductHeader.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_dcd488c3b5304105afc89d15891333ea.ExecuteAsync() at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader) at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag) at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer) at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter) at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag) at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template) at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template) at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using Dynamicweb.Ecommerce.ProductCatalog 3 4 @{ 5 ProductViewModel product = null; 6 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 7 { 8 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 9 } 10 else if (!string.IsNullOrEmpty(Pageview.Page.Item["DummyProduct"]?.ToString()) && Pageview.IsVisualEditorMode) 11 { 12 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 13 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 14 15 if (productList?.Products is object) 16 { 17 product = productList.Products[0]; 18 } 19 } 20 else if (Pageview.IsVisualEditorMode) 21 { 22 product = new ProductViewModel(); 23 product.Name = Translate("My product"); 24 product.Number = "12345"; 25 } 26 27 string manufacturer = null; 28 if (product?.ProductFields != null && product.ProductFields.TryGetValue("ManufacturerField", out var fv)) 29 { 30 manufacturer = fv?.Value?.ToString(); 31 } 32 if (string.IsNullOrWhiteSpace(manufacturer) && Pageview.IsVisualEditorMode) 33 { 34 manufacturer = Translate("Manufacturer"); 35 } 36 37 //Marked Products 38 string markedItem = string.Empty; 39 bool isPunchoutUser = false; 40 FieldValueViewModel specPrice; 41 bool hasSpecPrice = false; 42 43 if (!Pageview.IsVisualEditorMode && Pageview.User != null) 44 { 45 isPunchoutUser = Pageview.User.CustomFieldValues.SingleOrDefault(x => x.CustomField.SystemName == "AccessUser_IsPunchoutUser").Value.ToString().Equals("True"); 46 hasSpecPrice = product.ProductFields.TryGetValue("SpecPrice", out specPrice); 47 markedItem = specPrice != null && specPrice.Value.ToString() == "yes" && isPunchoutUser ? "markeditem" : ""; 48 } 49 50 string lastPurchaseDate = null; 51 if (product?.ProductFields != null && product.ProductFields.TryGetValue("LastPurchaseDate", out var fvDate)) 52 { 53 lastPurchaseDate = fvDate?.Value?.ToString(); 54 } 55 if (string.IsNullOrWhiteSpace(lastPurchaseDate) && Pageview.IsVisualEditorMode) 56 { 57 lastPurchaseDate = Translate("01-01-2025"); 58 } 59 60 string lastPurchaseQuantity = null; 61 if (product?.ProductFields != null && product.ProductFields.TryGetValue("LastPurchaseQuantity", out var fvQty)) 62 { 63 lastPurchaseQuantity = fvQty?.Value?.ToString(); 64 } 65 if (string.IsNullOrWhiteSpace(lastPurchaseQuantity) && Pageview.IsVisualEditorMode) 66 { 67 lastPurchaseQuantity = "10"; 68 } 69 70 string clickProductLink = ""; 71 72 if (Pageview.IsVisualEditorMode) 73 { 74 clickProductLink = ""; 75 } 76 else 77 { 78 clickProductLink = "onclick=\"return clickProductLink('" + @product.Id + "', '" + @product.Name + "', '" + @product.VariantName + "', '" + @product.Price.CurrencyCode + "', '" + @product.Price.ToStringInvariant() + "', '" + @product.Discount.ToStringInvariant() + "')\""; 79 } 80 string link = product.GetProductLink(GetPageIdByNavigationTag("Shop"), false); 81 if (!Pageview.IsVisualEditorMode) 82 { 83 string ReplacementProduct = !string.IsNullOrEmpty(product.ReplacementProduct.ProductId) ? product.ReplacementProduct.GetProduct().GetProductLink(GetPageIdByNavigationTag("Shop"), false) : ""; 84 link = !string.IsNullOrEmpty(ReplacementProduct) ? ReplacementProduct : link; 85 } 86 } 87 88 <div class="position-relative"> 89 90 <a href="@link" class="stretched-link" onmouseover="swift.Image.swapImage(event)" onmouseout="swift.Image.swapImage(event)" @clickProductLink> 91 <span class="visually-hidden">@product.Name</span> 92 </a> 93 94 <script> 95 function clickProductLink(productId, productName, productVariant, productCurrency, productPrice, productDiscount) { 96 if (typeof gtag !== "undefined") { 97 gtag("event", "select_item", { 98 item_list_id: "product_list_item_repeater", 99 item_list_name: "Product list (Item Repeater)", 100 items: [ 101 { 102 item_id: productId, 103 item_name: productName, 104 currency: productCurrency, 105 item_list_id: "product_list_item_repeater", 106 item_list_name: "Product list (Item Repeater)", 107 item_variant: productVariant, 108 price: productPrice, 109 discount: productDiscount 110 } 111 ] 112 }); 113 } 114 } 115 </script> 116 117 @if (product is object) 118 { 119 string titleFontSize = Model.Item.GetRawValueString("FontSize", "fs-6"); 120 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 121 horizontalAlign = horizontalAlign == "center" ? "text-center" : horizontalAlign; 122 horizontalAlign = horizontalAlign == "end" ? "text-end" : horizontalAlign; 123 124 string headingLevel = Model.Item.GetString("HeadingLevel", "h2"); 125 string headingLevelStart = $"<{headingLevel} class=\"{titleFontSize} {horizontalAlign} {markedItem} fw-bold m-0 item_{Model.Item.SystemName.ToLower()}\" itemprop=\"name\">"; 126 string headingLevelStop = $"</{headingLevel}>"; 127 128 @headingLevelStart 129 @product.Name 130 @headingLevelStop 131 132 <span class="fs-7 opacity-85 @horizontalAlign fw-bold"> 133 @product.Number 134 @if (!string.IsNullOrWhiteSpace(manufacturer)) 135 { 136 @($" Producent: {manufacturer}") 137 } 138 </span> 139 140 @if (!string.IsNullOrWhiteSpace(lastPurchaseDate) || !string.IsNullOrWhiteSpace(lastPurchaseQuantity)) 141 { 142 <span class="fs-7 opacity-85 @horizontalAlign d-block fw-bold"> 143 @Translate("Last purchase"): @lastPurchaseDate, @Translate("Quantity"): @lastPurchaseQuantity 144 </span> 145 } 146 } 147 </div> 148
Error executing template "Designs/Swift-v2/Paragraph/Swift-v2_ProductAddToCart.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_2ef195dcd19e4d47b88c04f02e7f89e8.<>c__DisplayClass0_0.<ExecuteAsync>b__0(String key) at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate) at CompiledRazorTemplates.Dynamic.RazorEngine_2ef195dcd19e4d47b88c04f02e7f89e8.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.Core.Encoders @using System.Globalization @functions { string? DoubleToString(double? value) { if (value.HasValue) { return value.Value.ToString(CultureInfo.InvariantCulture); } return null; } } @{ 2 bool isProductDetailPage = Dynamicweb.Context.Current.Request.QueryString.AllKeys?.Contains("ProductId") ?? false; 3 ProductViewModel product = null; if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) { product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; } else if (!string.IsNullOrEmpty(Pageview.Page.Item["DummyProduct"]?.ToString()) && Pageview.IsVisualEditorMode) { var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); if (productList?.Products is object) { product = productList.Products[0]; } } else if (Pageview.IsVisualEditorMode) { product = new ProductViewModel(); product.Id = "1"; product.VariantId = "394041"; product.PurchaseMinimumQuantity = 1; product.PurchaseQuantityStep = 1; product.StockLevel = 10; product.DefaultUnitId = "1"; product.ProductType = Dynamicweb.Ecommerce.Products.ProductType.Stock; product.NeverOutOfstock = false; product.Discontinued = false; 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 }; } string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); bool anonymousUser = Pageview.User == null; bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser; hideAddToCart = Pageview.IsVisualEditorMode ? false : hideAddToCart; 4 5 bool hasEcoLabel = true; 6 string[] ecoLabelKeys = { "EcoLabelShoppingWithCare1", "EcoLabelShoppingWithCare2", "EcoLabelShoppingWithCare3", "EcoLabelShoppingWithCare4", "EcoLabelShoppingWithCare5" }; 7 if (!Pageview.IsVisualEditorMode) 8 { 9 hasEcoLabel = ecoLabelKeys.Any(key => 10 product.ProductFields.TryGetValue(key, out var field) && 11 field?.Value?.ToString() == "1" 12 ); 13 } } @if (product is object && hideAddToCart) 14 { 15 string link = product.GetProductLink(GetPageIdByNavigationTag("Shop"), false); 16 string ReplacementProduct = !string.IsNullOrEmpty(product.ReplacementProduct.ProductId) ? product.ReplacementProduct.GetProduct().GetProductLink(GetPageIdByNavigationTag("Shop"), false) : ""; 17 link = !string.IsNullOrEmpty(ReplacementProduct) ? ReplacementProduct : link; @if (!isProductDetailPage) 18 { <div class="d-flex align-items-center"> @if (hasEcoLabel) 19 { <img class="eco-label mx-3" src="/Files/Images/EcoLabel/EcoLabel.png" alt="EcoLable" /> } <a href="@link" class="btn btn-secondary" data-dw-button="secondary" style="white-space: nowrap" title="@Translate("Se mere")" id="AddToCartButton@(product.Id)_@Pageview.CurrentParagraph.ID"> <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> @Translate("Se mere") </span> </a> </div> } } @if (product is object && !hideAddToCart) { string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; bool favoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowAddToFavorites")) ? Model.Item.GetBoolean("ShowAddToFavorites") : false; bool quantitySelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowQuantitySelector")) ? Model.Item.GetBoolean("ShowQuantitySelector") : false; bool unitsSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowUnitsSelector")) ? Model.Item.GetBoolean("ShowUnitsSelector") : false; bool hideInventory = !string.IsNullOrEmpty(Model.Item.GetString("HideInventory")) ? Model.Item.GetBoolean("HideInventory") : false; bool hideStockState = !string.IsNullOrEmpty(Model.Item.GetString("HideStockState")) ? Model.Item.GetBoolean("HideStockState") : false; string iconPath = "/Files/Images/Icons/"; string url = "/Default.aspx?ID=" + (GetPageIdByNavigationTag("CartService")); if (!url.Contains("LayoutTemplate")) { url += url.Contains("?") ? "&LayoutTemplate=Swift-v2_MiniCart.cshtml" : "?LayoutTemplate=Swift-v2_MiniCart.cshtml"; } string whenVariantsExist = Model.Item.GetRawValueString("WhenVariantsExist", "hide"); string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; string addToCartIcon = Model.Item.GetRawValueString("Icon", iconPath + "cart-shopping.svg"); string addToCartLabel = !addToCartIcon.Contains("_none") ? $"<span class=\"icon-2\">{ReadFile(addToCartIcon)}</span>" : ""; addToCartLabel += !addToCartIcon.Contains("_none") && !Model.Item.GetBoolean("HideButtonText") ? " " : ""; addToCartLabel += !Model.Item.GetBoolean("HideButtonText") ? $"<span class=\"d-none d-md-inline\">{Translate("Add to cart")}</span><span class=\"d-inline d-md-none\">{Translate("Add")}</span>" : ""; bool userHasPendingQuote = Dynamicweb.Ecommerce.Common.Context.Cart != null && Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote; if (product.VariantInfo?.VariantInfo == null || whenVariantsExist == "disable") { string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : product.DefaultUnitId; if (string.IsNullOrEmpty(unitId) && product?.UnitOptions != null) { if (product.UnitOptions?.FirstOrDefault<UnitOptionViewModel>() != null) { unitId = product.UnitOptions.FirstOrDefault<UnitOptionViewModel>().Id; } } double? stepQty = product.PurchaseQuantityStep > 0 ? product.PurchaseQuantityStep : 1; double? minQty = product.PurchaseMinimumQuantity > 0 ? product.PurchaseMinimumQuantity : 1; double? valueQty = minQty > stepQty ? minQty : stepQty; string? disableAddToCart = null; double? maxQty = null; if (Dynamicweb.Context.Current.Items.Contains("ProductQuantity")) { valueQty = Convert.ToDouble(Dynamicweb.Context.Current.Items["ProductQuantity"].ToString()); } if (product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock && !product.NeverOutOfstock) { disableAddToCart = product.StockLevel <= 0 ? "" : disableAddToCart; 20 maxQty = int.MaxValue; // Default to max int value product.StockLevel 21 } disableAddToCart = whenVariantsExist == "disable" && product.VariantInfo?.VariantInfo != null && string.IsNullOrEmpty(product.VariantId) ? "disabled" : disableAddToCart; disableAddToCart = product.Discontinued ? "disabled" : disableAddToCart; if (unitsSelector && product.UnitOptions?.Count > 0) { <form method="post" action="/Default.aspx?ID=@(Pageview.Page.ID)&ProductId=@product.Id" id="UnitSelectorForm_@(product.Id)_@(product.VariantId?.Replace(".", "_"))_@Model.ID"> <input type="hidden" name="redirect" value="false"> <input type="hidden" name="VariantID" value="@product.VariantId"> <input type="hidden" name="UnitID" class="js-unit-id" value="@unitId"> </form> } <div class="d-flex @fullWidth js-input-group item_@Model.Item.SystemName.ToLower()"> <div class="d-flex @fullWidth @horizontalAlign flex-wrap flex-lg-nowrap gap-2"> <form method="post" action="@url" class="@fullWidth" style="z-index: 1"> <input type="hidden" name="redirect" value="false"> <input type="hidden" name="ProductId" value="@product.Id"> <input type="hidden" name="ProductName" value="@HtmlEncoder.HtmlEncode(product.Name)"> <input type="hidden" name="ProductVariantName" value="@product.VariantName"> <input type="hidden" name="ProductCurrency" value="@Dynamicweb.Ecommerce.Common.Context.Currency.Code"> <input type="hidden" name="ProductPrice" value="@product.Price.ToStringInvariant()"> <input type="hidden" name="ProductDiscount" value="@product.Discount.ToStringInvariant()"> <input type="hidden" name="ProductReferer" value="component_ProductAddToCart"> <input type="hidden" name="cartcmd" value="add"> <input type="submit" class="d-none" onclick="event.preventDefault(); swift.Cart.Update(event)"> @* Fix for enterKey should not redirect to minicart page *@ @if (!string.IsNullOrEmpty(product.VariantId)) { <input type="hidden" name="VariantId" value="@product.VariantId"> } <template class="js-step-quantity-warning"> <div class="modal-header"> <h1 class="modal-title fs-5">@Translate("The quantity is not valid")</h1> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> @Translate("Please select a quantity that is dividable by") @stepQty </div> </template> <template class="js-min-quantity-warning"> <div class="modal-header"> <h1 class="modal-title fs-5">@Translate("The product could not be added to the cart")</h1> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> @Translate("The quantity is not valid. You must buy at least") @product.PurchaseMinimumQuantity </div> </template> <template class="js-value-missing-warning"> <div class="modal-header"> <h1 class="modal-title fs-5">@Translate("No amount specified")</h1> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> </div> <div class="modal-body"> @Translate("Specify an amount to add to the cart") </div> </template> @if (userHasPendingQuote) { <input type="hidden" name="PendingQuote" value="true"> <template class="js-pending-quote-notice"> <div class="modal-header"> <h1 class="modal-title fs-5">@Translate("Pending Quote")</h1> <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> </div> <div class="modal-body"> @Translate("You need to complete your current quote or empty the cart before adding this product to cart.") </div> </template> } @if (quantitySelector || (!anonymousUser && product.VariantInfo?.VariantInfo != null) || (!anonymousUser && favoritesSelector)) { <input type="hidden" id="Unit_@(product.Id)_@product.VariantId?.Replace(".", "_")" name="UnitID" value="@unitId" /> } <div class="d-flex flex-wrap gap-2"> @if (!quantitySelector) { <input id="Quantity_@(product.Id)_@product.VariantId?.Replace(".", "_")" class="swift_quantity_field" name="Quantity" value="@valueQty" type="hidden" @disableAddToCart> } @if (unitsSelector && product.UnitOptions?.Count > 0) { string selectedUnitName = !string.IsNullOrEmpty(unitId) && product?.UnitOptions != null ? unitId : product.UnitOptions.FirstOrDefault<UnitOptionViewModel>().Name; foreach (var unitOption in product.UnitOptions) { if (unitOption.Id == unitId) { selectedUnitName = unitOption.Name; } } <button class="btn btn-secondary @flexFill dropdown-toggle" data-dw-button="secondary" type="button" data-bs-toggle="dropdown" aria-expanded="false"> @selectedUnitName </button> <ul class="dropdown-menu swift_unit-field"> @foreach (var unitOption in product.UnitOptions) { var selectedUnit = unitOption.Id == unitId ? "selected" : ""; <li> <button type="button" class="btn dropdown-item" data-value="@unitOption.Id" onclick="document.querySelector('#UnitSelectorForm_@(product.Id)_@(product.VariantId.Replace(".", "_"))_@Model.ID').querySelector('.js-unit-id').value = this.getAttribute('data-value'); document.querySelector('#Unit_@(product.Id)_@product.VariantId?.Replace(".", "_")').value = this.getAttribute('data-value'); swift.PageUpdater.Update(document.querySelector('#UnitSelectorForm_@(product.Id)_@(product.VariantId?.Replace(".", "_"))_@Model.ID'))"> <span>@unitOption.Name</span> <span> @if (unitOption.StockLevel > 0 || unitOption.NeverOutOfStock) { if (!Model.Item.GetBoolean("HideInventory") && !unitOption.NeverOutOfStock) { <span class="small text-success">@unitOption.StockLevel @Translate("In stock")</span> } else { <span class="small text-success">@Translate("In stock")</span> } } else { <span class="small text-danger">@Translate("Out of Stock")</span> } </span> </button> </li> } </ul> } @if (quantitySelector) { @RenderPartial("Components/QuantitySelector.cshtml", product) } <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-primary @flexFill js-add-to-cart-button" data-dw-button="primary" style="white-space: nowrap" @disableAddToCart title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)_@Pageview.CurrentParagraph.ID"> @if (!Model.Item.GetBoolean("HideButtonText")) { <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> @addToCartLabel </span> } else { @addToCartLabel } </button> </div> </form> @if (!anonymousUser && favoritesSelector) { @RenderPartial("Components/ToggleFavorite.cshtml", product) } </div> </div> } else if (whenVariantsExist == "modal") { string ButtonShape = Model.Item.GetRawValueString("VariantButtonShape", "square"); string buttonAspectRatio = Model.Item.GetRawValueString("VariantImageAspectRatio", "56%"); string buttonText = Translate("Select"); string variantId = !string.IsNullOrWhiteSpace(product.VariantId) ? product.VariantId : product.DefaultVariantId; string variantSelectorServicePageId = !string.IsNullOrEmpty(Model.Item.GetString("VariantSelectorServicePageId")) ? Model.Item.GetLink("VariantSelectorServicePageId").PageId.ToString() : ""; variantSelectorServicePageId = variantSelectorServicePageId != "" ? variantSelectorServicePageId : GetPageIdByNavigationTag("VariantSelectorService").ToString(); <div class="d-flex @horizontalAlign w-100 item_@Model.Item.SystemName.ToLower()"> @if (!anonymousUser && favoritesSelector) { @RenderPartial("Components/ToggleFavorite.cshtml", product) } <form action="/Default.aspx?ID=@variantSelectorServicePageId" data-response-target-element="DynamicModalContent" data-preloader="inline" style="z-index: 1" class="@fullWidth"> <input type="hidden" name="ProductID" value="@product.Id"> <input type="hidden" name="VariantID" value="@variantId"> <input type="hidden" name="QuantitySelector" value="@quantitySelector.ToString()"> <input type="hidden" name="HideInventory" value="@hideInventory.ToString()"> <input type="hidden" name="HideStockState" value="@hideStockState.ToString()"> <input type="hidden" name="ButtonLayout" value="@ButtonShape"> <input type="hidden" name="ButtonAspectRatio" value="@buttonAspectRatio"> <input type="hidden" name="VariantSelectorServicePage" value="@variantSelectorServicePageId"> <input type="hidden" name="ViewType" value="ModalContent"> <button type="button" onclick="swift.PageUpdater.Update(event)" class="btn btn-primary @fullWidth" data-dw-button="primary" title="@Translate("Select")" data-bs-toggle="modal" data-bs-target="#DynamicModal" id="OpenVariantSelectorModal@(product.Id)_@Pageview.CurrentParagraph.ID">@buttonText</button> </form> </div> } }