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_dbd7695e2a994c2d8951d316c95f7530.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 @* for custom link to dealers from json file *@ @using FlexMedia.Plastmo.Integration.Frontend.Models @functions { string? DoubleToString(double? value) { if (value.HasValue) { return value.Value.ToString(CultureInfo.InvariantCulture); } return null; } // to replace the product tags in Dealer links string RelpaceProductTags(string value , ProductViewModel product) { value = value .Replace("[ProductID]",product.Id) .Replace("[ProductNumber]",product.Number) .Replace("[ProductDB]",product.ProductFields["TUN"].Value.ToString()) .Replace("[ProductVVS]",product.ProductFields["VVS_nummer"].Value.ToString()) .Replace("[VariantID]",product.VariantId) .Replace("[ProductName]",product.Name); return value; } } @{ 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; @* for custom link to dealers from json file *@ bool hasDealer = false; bool hasPlastmoDealer = false; bool singleDealer = false; List<string> DealersIDs = new(); if(!Pageview.IsVisualEditorMode){ string fieldName = "Dealers"; var fieldOptions = Dynamicweb.Ecommerce.Services.FieldOptions.GetOptionsByFieldId(fieldName); bool fieldExist = product.ProductFields.TryGetValue(fieldName, out FieldValueViewModel field); if (fieldExist && field?.Value != null){ List<FieldOptionValueViewModel> options = field?.Value as List<FieldOptionValueViewModel>; DealersIDs = options.Select(o => o.Value).ToList(); } } var DealerList = FlexMedia.Plastmo.Integration.Frontend.DealersHelper.GetDealers(DealersIDs,true); // FlexMedia.Plastmo.Integration.Frontend.GetDealer(string dealerId, bool cached = true) int cntLinks = 0; string firstDealerWithLink = ""; foreach (var dealer in DealerList){ if((!string.IsNullOrEmpty(dealer.DealerAddtoCartLink) || !string.IsNullOrEmpty(dealer.DealerProductLink))&&dealer.DealerIsPlastmo!="True"){ cntLinks++;firstDealerWithLink = dealer.DealerID; } if(dealer.DealerIsPlastmo=="True"){hasPlastmoDealer=true;} } if(DealerList.Count()>=1 && (cntLinks>=1)){hasDealer=true;} if(DealerList.Count()==1 || (cntLinks==1)){singleDealer=true;} // foreach (var dealer in DealerList){} } @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; string test = "https://www.10-4.dk/ten_four/custom_orders/add_lines?plasmo&p[]=[ProductDB]&q[]=1&t[]=[ProductName]&i=[ProductID]&n=[ProductNumber]&d=[ProductDB]&vv=[ProductVVS]&v=[VariantID]"; // Dealer Direct Link // if no dealer then no link // if only 1 dealer then "add to cart" // if not Plastmo the "show at dealer" // if multible then [open list] and "add to cart" for each // if multible then [open list] and "show at dealer" for each if(!Pageview.IsVisualEditorMode){ <small title="Dealers" style="display:none;"> <p title="stock"> hideAddToCart:@hideAddToCart<br> product.StockLevel:@product.StockLevel<br> DealerList.Count():@DealerList.Count()<br> DealerList.FirstOrDefault():@DealerList.FirstOrDefault()<br> </p> <p title="cnt"> cntLinks:@cntLinks<br> firstDealerWithLink:@firstDealerWithLink<br> </p> <p title="dealers"> hasDealer:@hasDealer<br> hasPlastmoDealer:@hasPlastmoDealer<br> singleDealer:@singleDealer<br> DealersIDs:@DealersIDs<br> </p> <p title="prod"> product.Name:@product.Name<br> product.Id:@product.Id<br> product.Number:@product.Number<br> product.ProductFields["TUN"].Value:@product.ProductFields["TUN"].Value<br> product.ProductFields["VVS_nummer"].Value:@product.ProductFields["VVS_nummer"].Value<br> </p> <p> @RelpaceProductTags(test,product)s </p> </small> } // foreach (var dealer in DealerList){<small style="display:none;">@dealer.DealerIsPlastmo @dealer.DealerCountry @dealer.DealerDomain</small>} <div class="offcanvas offcanvas-end overflow-y-auto" tabindex="-1" data-dw-colorscheme="lightgrey1" id="DealerOffcanvas" style="visibility: visible;" aria-modal="true" role="dialog"> <div class="modal-header sticky-top py-1 py-lg-3 ps-lg-4 pe-0 pe-lg-3" data-dw-colorscheme="light" style="box-shadow: 0 10px 10px -12px var(--bs-gray-300);"> <span class="h5 m-0 flex-fill">@Translate("Select your dealer","Vælg din forhandler")</span> <button type="button" class="btn btn-sm p-2 d-flex align-items-center justify-content-bottom" data-bs-dismiss="offcanvas" aria-label="Close" id="CloseDealerOffcanvas" onclick="offCanvasDealerList();"> <span>Luk</span> <span class="icon-4 mb-1"> <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" class="feather feather-x"><line x1="18" y1="6" x2="6" y2="18"></line><line x1="6" y1="6" x2="18" y2="18"></line></svg> </span> </button> </div> <div class="dealerlist p-2 p-lg-3 h-100;"> @* @if(!Pageview.IsVisualEditorMode && hasDealer && !singleDealer){*@ @if(!Pageview.IsVisualEditorMode && hasDealer){ foreach (var dealer in DealerList){ bool DealerIsPlastmo = dealer.DealerIsPlastmo=="True" ? true : false; bool hasAddTocartLink = !string.IsNullOrEmpty(dealer.DealerAddtoCartLink) ? true : false; bool hasProdLink = !string.IsNullOrEmpty(dealer.DealerProductLink) ? true : false; bool hasLogo = !string.IsNullOrEmpty(dealer.DealerLogo) ? true : false; if((hasAddTocartLink || hasProdLink) && !DealerIsPlastmo){ <div class="my-2 py-1 py-lg-3 ps-lg-4 pe-0 pe-lg-3" data-dw-colorscheme="light" did="@dealer.DealerID" dn="@dealer.DealerName" dc="@dealer.DealerCountry" dip="@dealer.DealerIsPlastmo" dcl="dealer.DealerCollectionLink"> <div data-swift-container="" class="d-flex m-0 py-2" data-dw-container-width="2"> @if(hasLogo){ <figure class="m-0" data-swift-gridcolumn=""> <a href="@dealer.DealerDomain" title="@dealer.DealerName" target="_blank" rel="noopener"><img src="@dealer.DealerLogo" alt="@dealer.DealerName" style="width:75px"></a> </figure> } <div class="m-0 align-items-right flex-fill"> <div class="h6 m-0 mb-2 align-items-left justify-content-top" data-swift-gridcolumn=""><strong>@dealer.DealerName</strong></div> <div class="m-0 align-items-right justify-content-bottom d-flex" data-dw-container-width="2"> @if(hasProdLink){ string prodLink = RelpaceProductTags(dealer.DealerProductLink,product); <a href="@prodLink" target="_blank" rel="noopener" class="btn btn-secondary flex-fill" data-dw-button="secondary">@Translate("See product","Se produktet")</a> } @if(hasAddTocartLink){ string AddTocartLink = RelpaceProductTags(dealer.DealerAddtoCartLink,product); <a href="@AddTocartLink" target="_blank" rel="noopener" class="btn btn-primary align-items-right ms-2" data-dw-button="primary">@Translate("Add to cart","Læg i kurv")</a> } </div> </div> </div> </div> } } } </div> </div> @*<small style="display:none;" title="hidden under construction">*@ @* @if(!Pageview.IsVisualEditorMode && hasDealer && !singleDealer){*@ @if(!Pageview.IsVisualEditorMode && hasDealer){ // button and function for slide in dealer list <div class="title mb-3 btn btn-outline-primary theme" data-dw-button="primary" onclick="offCanvasDealerList();">@Translate("buy at dealer","Køb hos en forhandler")</div> <script> function offCanvasDealerList(){ var d=document.getElementById("DealerOffcanvas"); if(d.classList.contains("show")){ d.classList.remove("show");document.body.getElementsByClassName("offcanvas-backdrop")[0].remove(); }else{ var e=document.createElement('div');e.className="offcanvas-backdrop fade show";e.onclick=function (){offCanvasDealerList();};document.body.appendChild(e);d.classList.add("show"); } } </script> } @{ @* // if only one dealer if(!Pageview.IsVisualEditorMode && hasDealer && singleDealer && 1==2){ var dealer = DealerList.Find(c => c.DealerID == firstDealerWithLink); // var dealer = DealerList.FirstOrDefault(); bool hasAddTocartLink = !string.IsNullOrEmpty(dealer.DealerAddtoCartLink) ? true : false; bool hasProdLink = !string.IsNullOrEmpty(dealer.DealerProductLink) ? true : false; <div class="dealersingle" did="@dealer.DealerID" dn="@dealer.DealerName" dc="@dealer.DealerCountry" dip="@dealer.DealerIsPlastmo"> @if(hasAddTocartLink){ string AddTocartLink = dealer.DealerAddtoCartLink.Replace("[ProductID]",product.Id).Replace("[VariantId]",product.VariantId); <a href="@AddTocartLink" class="btn btn-primary" title="kun test">Køb hos @dealer.DealerName</a> } @if(hasProdLink){ string prodLink = dealer.DealerProductLink.Replace("[ProductID]",product.Id).Replace("[VariantId]",product.VariantId); <a href="@prodLink" class="btn btn-outline-primary" title="kun test">se hos @dealer.DealerName</a> } </div> <style> .dealersingle{ position:relative; z-index:1; display:block; cursor:pointer; } </style> } *@ } @*</small>*@ if(!hasDealer || hasPlastmoDealer){ 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 ? "disabled" : disableAddToCart; maxQty = product.StockLevel; } 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> } } }