New 15km bike park in the heart of Pines forrest
This is a legitimate expert-level trail, but much of the difficulty can be mitigated by slowing down and picking your line carefully.
Error executing template "/Designs/Swift/Grid/Page/RowTemplates/2ColumnsFlex.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_42af2d090ab24cbfaf5bedb3cbfea11f.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.GridRowViewModel> 2 3 @{ 4 string containerClass = "container-xl"; 5 6 string width = Model.Item.GetRawValueString("Width", "").ToLower(); 7 if (width == "stretch") 8 { 9 containerClass = "container-fluid"; 10 } 11 if (width == "none") 12 { 13 containerClass = "container-fluid px-0"; 14 } 15 16 string rowClass = "gap-3"; 17 string spaceBetweenColumns = Model.Item.GetRawValueString("SpaceBetweenColumns", "").ToLower(); 18 19 if (spaceBetweenColumns == "stick") 20 { 21 rowClass = "gap-0"; 22 } 23 if (spaceBetweenColumns == "spacing-large") 24 { 25 rowClass = "gap-1 gap-md-4 gap-lg-5"; 26 } 27 28 string columnPosition = Model.Item.GetRawValueString("ColumnPosition", "align-items-center").ToLower(); 29 if (columnPosition == "top") 30 { 31 columnPosition = "align-items-start"; 32 } 33 if (columnPosition == "center") 34 { 35 columnPosition = "align-items-center"; 36 } 37 if (columnPosition == "bottom") 38 { 39 columnPosition = "align-items-end"; 40 } 41 42 string rowHeight = Model.Item.GetRawValueString("RowHeight", "0").ToLower(); 43 rowHeight = "py-" + rowHeight; 44 45 string column1width = Model.Item.GetRawValueString("Column_1Width", "").ToLower(); 46 column1width = column1width == "grow" ? "flex-grow-1" : "flex-grow-0"; 47 48 string column2width = Model.Item.GetRawValueString("Column_2Width", "").ToLower(); 49 column2width = column2width == "grow" ? "flex-grow-1" : "flex-grow-0"; 50 51 string hideOnScroll = Model.Item.GetRawValueString("HideOnScroll", "").ToLower(); 52 hideOnScroll = hideOnScroll == "hide" ? "js-hide-on-scroll" : ""; 53 54 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 55 string alternativeTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("AlternativeTheme")) ? " theme " + Model.Item.GetRawValueString("AlternativeTheme").Replace(" ", "").Trim().ToLower() : ""; 56 string mainTheme = theme; 57 58 string headerCssClass = "sticky-top"; 59 if (Pageview.Page.PropertyItem != null) { 60 headerCssClass = Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"] != null ? Pageview.Page.PropertyItem["MoveThisPageBehindTheHeader"].ToString() : "sticky-top"; 61 } 62 headerCssClass = headerCssClass == "" ? "sticky-top" : headerCssClass; 63 headerCssClass = Pageview.IsVisualEditorMode ? "" : headerCssClass; 64 65 string themeSwitchers = ""; 66 string themeAnimated = ""; 67 if (headerCssClass == "fixed-top") 68 { 69 theme = alternativeTheme; 70 themeSwitchers = "data-main-theme=\"" + mainTheme + "\" data-alternative-theme=\"" + alternativeTheme + "\""; 71 themeAnimated = "theme-animated "; 72 } 73 74 var decorations = Model.Item?.GetList("CssDecorations")?.GetRawValue().OfType<string>() ?? Enumerable.Empty<string>(); 75 var css = string.Empty; 76 var cssClasses = new List<string> { }; 77 78 foreach (var itemId in decorations) 79 { 80 var item = Dynamicweb.Content.Services.Items.GetItem("Swift_Css", itemId); 81 item.TryGetValue("Class", out object classes); 82 if (classes is null) 83 { 84 continue; 85 } 86 87 var cssString = (string)classes; 88 if (cssString.StartsWith("[")) 89 { 90 var cssArray = Dynamicweb.Core.Converter.Deserialize<string[]>(cssString); 91 cssClasses.AddRange(cssArray); 92 } 93 else 94 { 95 cssClasses.Add(cssString.Replace(",", " ")); 96 } 97 } 98 css = string.Join(" ", cssClasses).Trim(); 99 100 var columnContent1 = Model.Column(1).Output(); 101 var columnContent2 = Model.Column(2).Output(); 102 103 if (Pageview.IsVisualEditorMode || !string.IsNullOrWhiteSpace(columnContent1) || !string.IsNullOrWhiteSpace(columnContent2)) 104 { 105 <div class="@rowHeight @themeAnimated @theme @hideOnScroll @(css) item_@Model.Item.SystemName.ToLower()" @themeSwitchers data-swift-gridrow> 106 <div class="@containerClass"> 107 <div class="d-flex flex-row @rowClass @columnPosition"> 108 <div class="col @column1width"> 109 @columnContent1 110 </div> 111 <div class="col @column2width"> 112 @columnContent2 113 </div> 114 </div> 115 </div> 116 </div> 117 } 118 } 119
Error executing template "Designs/Swift/Paragraph/Swift_ProductAddToCart.cshtml" System.NullReferenceException: Object reference not set to an instance of an object. at CompiledRazorTemplates.Dynamic.RazorEngine_38bb0e612fc6488589d8829e945e4a6d.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 @using Dynamicweb.Core.Encoders 4 @using System.Globalization 5 6 @functions { 7 string DoubleToString(double? value) 8 { 9 if (value.HasValue) 10 { 11 return value.Value.ToString(CultureInfo.InvariantCulture); 12 } 13 return null; 14 } 15 } 16 17 @{ 18 ProductViewModel product = null; 19 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 20 { 21 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 22 } 23 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 24 { 25 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 26 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 27 28 if (productList?.Products is object) 29 { 30 product = productList.Products[0]; 31 } 32 } 33 34 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 35 bool anonymousUser = Pageview.User == null; 36 bool isErpConnectionDown = !Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsWebServiceConnectionAvailable"]); 37 bool hideAddToCart = anonymousUsersLimitations.Contains("cart") && anonymousUser || Pageview.AreaSettings.GetBoolean("ErpDownHideAddToCart") && isErpConnectionDown; 38 hideAddToCart = Pageview.IsVisualEditorMode ? false : hideAddToCart; 39 } 40 41 @if (product is object && !hideAddToCart) 42 { 43 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 44 horizontalAlign = horizontalAlign == "center" ? "justify-content-center" : horizontalAlign; 45 horizontalAlign = horizontalAlign == "end" ? "justify-content-end" : horizontalAlign; 46 horizontalAlign = horizontalAlign == "full" ? "" : horizontalAlign; 47 48 bool favoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowAddToFavorites")) ? Model.Item.GetBoolean("ShowAddToFavorites") : false; 49 bool quantitySelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowQuantitySelector")) ? Model.Item.GetBoolean("ShowQuantitySelector") : false; 50 bool unitsSelector = !string.IsNullOrEmpty(Model.Item.GetString("ShowUnitsSelector")) ? Model.Item.GetBoolean("ShowUnitsSelector") : false; 51 bool hideInventory = !string.IsNullOrEmpty(Model.Item.GetString("HideInventory")) ? Model.Item.GetBoolean("HideInventory") : false; 52 bool hideStockState = !string.IsNullOrEmpty(Model.Item.GetString("HideStockState")) ? Model.Item.GetBoolean("HideStockState") : false; 53 54 string buttonSize = Model.Item.GetRawValueString("ButtonSize", "regular"); 55 string inputSize = string.Empty; 56 57 switch (buttonSize) 58 { 59 case "small": 60 inputSize = " input-group-sm"; 61 buttonSize = " btn-sm"; 62 break; 63 case "regular": 64 buttonSize = string.Empty; 65 break; 66 case "large": 67 inputSize = " input-group-lg"; 68 buttonSize = " btn-lg"; 69 break; 70 } 71 72 string iconPath = "/Files/icons/"; 73 string url = "/Default.aspx?ID=" + (GetPageIdByNavigationTag("CartService")); 74 if (!url.Contains("LayoutTemplate")) 75 { 76 url += url.Contains("?") ? "&LayoutTemplate=Swift_MiniCart.cshtml" : "?LayoutTemplate=Swift_MiniCart.cshtml"; 77 } 78 79 string whenVariantsExist = Model.Item.GetRawValueString("WhenVariantsExist", "hide"); 80 string flexFill = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "flex-fill" : ""; 81 string fullWidth = Model.Item.GetRawValueString("HorizontalAlignment", "") == "full" ? "w-100" : ""; 82 string addToCartIcon = Model.Item.GetRawValueString("Icon", iconPath + "shopping-cart.svg"); 83 string addToCartLabel = !addToCartIcon.Contains("_none") ? $"<span class=\"icon-2\">{ReadFile(addToCartIcon)}</span>" : ""; 84 addToCartLabel += !addToCartIcon.Contains("_none") && !Model.Item.GetBoolean("HideButtonText") ? " " : ""; 85 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>" : ""; 86 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 87 88 bool userHasPendingQuote = Dynamicweb.Ecommerce.Common.Context.Cart != null && Dynamicweb.Ecommerce.Common.Context.Cart.IsQuote; 89 90 string liveInfoClass = isLazyLoadingForProductInfoEnabled ? "js-live-info" : ""; 91 92 if (product.VariantInfo.VariantInfo == null || whenVariantsExist == "disable") 93 { 94 string unitId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.Form.Get("UnitId")) ? Dynamicweb.Context.Current.Request.Form.Get("UnitId") : product.DefaultUnitId; 95 if (string.IsNullOrEmpty(unitId) && product?.UnitOptions != null) 96 { 97 if (product.UnitOptions.FirstOrDefault<UnitOptionViewModel>() != null) 98 { 99 unitId = product.UnitOptions.FirstOrDefault<UnitOptionViewModel>().Id; 100 } 101 } 102 103 double? stepQty = product.PurchaseQuantityStep > 0 ? product.PurchaseQuantityStep : 1; 104 double? minQty = product.PurchaseMinimumQuantity > 0 ? product.PurchaseMinimumQuantity : 1; 105 double? valueQty = minQty > stepQty ? minQty : stepQty; 106 string disableAddToCart = null; 107 double? maxQty = null; 108 109 if (product.ProductType == Dynamicweb.Ecommerce.Products.ProductType.Stock && !product.NeverOutOfstock) 110 { 111 disableAddToCart = (product.StockLevel <= 0) || (!product.NeverOutOfstock && isLazyLoadingForProductInfoEnabled) ? "disabled" : disableAddToCart; 112 maxQty = product.StockLevel; 113 } 114 115 disableAddToCart = whenVariantsExist == "disable" && product.VariantInfo.VariantInfo != null && string.IsNullOrEmpty(product.VariantId) ? "disabled" : disableAddToCart; 116 disableAddToCart = product.Discontinued ? "disabled" : disableAddToCart; 117 118 if (unitsSelector && product.UnitOptions.Count > 0) 119 { 120 <form method="post" action="/Default.aspx?ID=@(Pageview.Page.ID)&ProductId=@product.Id" id="UnitSelectorForm_@(product.Id)_@(product.VariantId.Replace(".", "_"))_@Model.ID"> 121 <input type="hidden" name="redirect" value="false"> 122 <input type="hidden" name="VariantID" value="@product.VariantId"> 123 <input type="hidden" name="UnitID" class="js-unit-id" value="@unitId"> 124 </form> 125 } 126 127 <div class="d-flex @horizontalAlign @fullWidth @liveInfoClass js-input-group item_@Model.Item.SystemName.ToLower()"> 128 @if (!anonymousUser && favoritesSelector) 129 { 130 @RenderPartial("Components/ToggleFavorite.cshtml", product) 131 } 132 133 <form method="post" action="@url" class="@fullWidth" style="z-index: 1"> 134 <input type="hidden" name="redirect" value="false"> 135 <input type="hidden" name="ProductId" value="@product.Id"> 136 <input type="hidden" name="ProductName" value="@HtmlEncoder.HtmlEncode(product.Name)"> 137 <input type="hidden" name="ProductVariantName" value="@product.VariantName"> 138 <input type="hidden" name="ProductCurrency" value="@Dynamicweb.Ecommerce.Common.Context.Currency.Code"> 139 <input type="hidden" name="ProductPrice" value="@product.Price.ToStringInvariant()"> 140 <input type="hidden" name="ProductDiscount" value="@product.Discount.ToStringInvariant()"> 141 <input type="hidden" name="ProductReferer" value="component_ProductAddToCart"> 142 <input type="hidden" name="cartcmd" value="add"> 143 <input type="submit" class="d-none" onclick="event.preventDefault(); swift.Cart.Update(event)"> @* Fix for enterKey should not redirect to minicart page *@ 144 145 @if (!string.IsNullOrEmpty(product.VariantId)) 146 { 147 <input type="hidden" name="VariantId" value="@product.VariantId"> 148 } 149 150 <template class="js-step-quantity-warning"> 151 <div class="modal-header"> 152 <h1 class="modal-title fs-5">@Translate("The quantity is not valid")</h1> 153 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 154 </div> 155 <div class="modal-body"> 156 @Translate("Please select a quantity that is dividable by") @stepQty 157 </div> 158 </template> 159 160 161 <template class="js-min-quantity-warning"> 162 <div class="modal-header"> 163 <h1 class="modal-title fs-5">@Translate("The product could not be added to the cart")</h1> 164 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 165 </div> 166 <div class="modal-body"> 167 @Translate("The quantity is not valid. You must buy at least") @product.PurchaseMinimumQuantity 168 </div> 169 </template> 170 171 <template class="js-value-missing-warning"> 172 <div class="modal-header"> 173 <h1 class="modal-title fs-5">@Translate("No amount specified")</h1> 174 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button> 175 </div> 176 <div class="modal-body"> 177 @Translate("Specify an amount to add to the cart") 178 </div> 179 </template> 180 181 182 @if (userHasPendingQuote) 183 { 184 <input type="hidden" name="PendingQuote" value="true"> 185 186 <template class="js-pending-quote-notice"> 187 <div class="modal-header"> 188 <h1 class="modal-title fs-5">@Translate("Pending Quote")</h1> 189 <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="@Translate("Close")"></button> 190 </div> 191 <div class="modal-body"> 192 @Translate("You need to complete your current quote or empty the cart before adding this product to cart.") 193 </div> 194 </template> 195 } 196 197 @if (quantitySelector || (!anonymousUser && product.VariantInfo.VariantInfo != null) || (!anonymousUser && favoritesSelector)) 198 { 199 <input type="hidden" id="Unit_@(product.Id)_@product.VariantId.Replace(".", "_")" name="UnitID" value="@unitId" /> 200 } 201 202 <div class="d-flex flex-row w-100"> 203 @if (!quantitySelector) 204 { 205 <input id="Quantity_@(product.Id)_@product.VariantId.Replace(".", "_")" class="swift_quantity_field" name="Quantity" value="@valueQty" type="hidden" @disableAddToCart> 206 } 207 208 @if (unitsSelector && product.UnitOptions.Count > 0) 209 { 210 string selectedUnitName = !string.IsNullOrEmpty(unitId) && product?.UnitOptions != null ? unitId : product.UnitOptions.FirstOrDefault<UnitOptionViewModel>().Name; 211 212 foreach (var unitOption in product.UnitOptions) 213 { 214 if (unitOption.Id == unitId) 215 { 216 selectedUnitName = unitOption.Name; 217 } 218 } 219 220 <div class="d-flex flex-column gap-2 w-100"> 221 <div class="input-group input-primary-button-group flex-nowrap@(inputSize)"> 222 223 @if (quantitySelector) 224 { 225 <input id="Quantity_@(product.Id)_@product.VariantId.Replace(".", "_")" name="Quantity" value="@DoubleToString(valueQty)" step="@DoubleToString(stepQty)" min="@DoubleToString(minQty)" max="@DoubleToString(maxQty)" class="form-control swift_quantity-field" style="min-width: 60px; max-width: 100px; z-index: 1" type="number" @disableAddToCart> 226 } 227 228 <button class="btn btn-secondary @flexFill dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false"> 229 @selectedUnitName 230 </button> 231 232 <ul class="dropdown-menu swift_unit-field"> 233 @foreach (var unitOption in product.UnitOptions) 234 { 235 var selectedUnit = unitOption.Id == unitId ? "selected" : ""; 236 237 <li> 238 <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'); 239 document.querySelector('#Unit_@(product.Id)_@product.VariantId.Replace(".", "_")').value = this.getAttribute('data-value'); 240 swift.PageUpdater.Update(document.querySelector('#UnitSelectorForm_@(product.Id)_@(product.VariantId.Replace(".", "_"))_@Model.ID'))"> 241 <span>@unitOption.Name</span> 242 <span> 243 @if (unitOption.StockLevel > 0 || unitOption.NeverOutOfStock) 244 { 245 if (!Model.Item.GetBoolean("HideInventory") && !unitOption.NeverOutOfStock) 246 { 247 <span class="small text-success">@unitOption.StockLevel @Translate("In stock")</span> 248 } 249 else 250 { 251 <span class="small text-success">@Translate("In stock")</span> 252 } 253 } 254 else 255 { 256 <span class="small text-danger">@Translate("Out of Stock")</span> 257 } 258 </span> 259 </button> 260 </li> 261 } 262 </ul> 263 </div> 264 <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-primary @(buttonSize) js-add-to-cart-button" style="white-space: nowrap" @disableAddToCart title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)_@Pageview.CurrentParagraph.ID"> 265 @if (!Model.Item.GetBoolean("HideButtonText")) 266 { 267 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 268 @addToCartLabel 269 </span> 270 } 271 else 272 { 273 @addToCartLabel 274 } 275 </button> 276 </div> 277 } 278 else 279 { 280 <div class="input-group input-primary-button-group flex-nowrap@(inputSize)"> 281 @if (quantitySelector) 282 { 283 <input id="Quantity_@(product.Id)_@product.VariantId.Replace(".", "_")" name="Quantity" value="@DoubleToString(valueQty)" step="@DoubleToString(stepQty)" min="@DoubleToString(minQty)" max="@DoubleToString(maxQty)" class="form-control swift_quantity-field" style="min-width: 60px; max-width: 100px; z-index: 1" type="number" @disableAddToCart> 284 } 285 286 <button type="button" onclick="swift.Cart.Update(event)" class="btn btn-primary @(buttonSize) @flexFill js-add-to-cart-button" style="white-space: nowrap" @disableAddToCart title="@Translate("Add to cart")" id="AddToCartButton@(product.Id)_@Pageview.CurrentParagraph.ID"> 287 @if (!Model.Item.GetBoolean("HideButtonText")) 288 { 289 <span class="text-nowrap d-flex align-items-center justify-content-center gap-2"> 290 @addToCartLabel 291 </span> 292 } 293 else 294 { 295 @addToCartLabel 296 } 297 </button> 298 </div> 299 } 300 </div> 301 </form> 302 </div> 303 } 304 else if (whenVariantsExist == "modal") 305 { 306 string ButtonShape = Model.Item.GetRawValueString("VariantButtonShape", "square"); 307 string buttonAspectRatio = Model.Item.GetRawValueString("VariantImageAspectRatio", "56%"); 308 309 string buttonText = Translate("Select"); 310 string variantId = !string.IsNullOrWhiteSpace(product.VariantId) ? product.VariantId : product.DefaultVariantId; 311 312 string variantSelectorServicePageId = !string.IsNullOrEmpty(Model.Item.GetString("VariantSelectorServicePageId")) ? Model.Item.GetLink("VariantSelectorServicePageId").PageId.ToString() : ""; 313 variantSelectorServicePageId = variantSelectorServicePageId != "" ? variantSelectorServicePageId : GetPageIdByNavigationTag("VariantSelectorService").ToString(); 314 315 <div class="d-flex @horizontalAlign w-100 item_@Model.Item.SystemName.ToLower()"> 316 @if (!anonymousUser && favoritesSelector) 317 { 318 @RenderPartial("Components/ToggleFavorite.cshtml", product) 319 } 320 <form action="/Default.aspx?ID=@variantSelectorServicePageId" data-response-target-element="DynamicModalContent" data-preloader="inline" style="z-index: 1" class="@fullWidth"> 321 <input type="hidden" name="ProductID" value="@product.Id"> 322 <input type="hidden" name="VariantID" value="@variantId"> 323 <input type="hidden" name="QuantitySelector" value="@quantitySelector.ToString()"> 324 <input type="hidden" name="HideInventory" value="@hideInventory.ToString()"> 325 <input type="hidden" name="HideStockState" value="@hideStockState.ToString()"> 326 <input type="hidden" name="ButtonLayout" value="@ButtonShape"> 327 <input type="hidden" name="ButtonAspectRatio" value="@buttonAspectRatio"> 328 <input type="hidden" name="VariantSelectorServicePage" value="@variantSelectorServicePageId"> 329 <input type="hidden" name="ViewType" value="ModalContent"> 330 @if (isLazyLoadingForProductInfoEnabled) 331 { 332 @* If lazy loading is enabled, bypass it because we're loading a modal window, so render everything as if it was server-side *@ 333 <input type="hidden" name="getproductinfo" value="true"> 334 } 335 <button type="button" onclick="swift.PageUpdater.Update(event)" class="btn btn-primary@(buttonSize) @fullWidth" title="@Translate("Select")" data-bs-toggle="modal" data-bs-target="#DynamicModal" id="OpenVariantSelectorModal@(product.Id)_@Pageview.CurrentParagraph.ID">@buttonText</button> 336 </form> 337 </div> 338 } 339 } 340 else if (Pageview.IsVisualEditorMode) 341 { 342 <div class="alert alert-dark m-0">@Translate("No products available")</div> 343 } 344
Error compiling template "Designs/Swift/Paragraph/SwiftRizzo_StockState.cshtml" Line 64: 'StockService.StockService()' is obsolete: 'This is no longer suitable for manual construction. Please either use constructor injection or Dynamicweb.Ecommerce.Services.StockService.'
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 using Dynamicweb.Ecommerce.Stocks; 13 internal class RazorEngine_7e1ee7eda4394b76bbe42195b7b45ff3 : Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 14 { 15 #pragma warning disable 1998 16 public async override global::System.Threading.Tasks.Task ExecuteAsync() 17 { 18 WriteLiteral("\r\n"); 19 WriteLiteral("\r\n"); 20 21 ProductViewModel product = null; 22 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 23 { 24 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 25 } 26 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 27 { 28 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 29 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 30 31 if (productList?.Products is object) 32 { 33 product = productList.Products[0]; 34 } 35 } 36 37 bool hasDeliveryTime = Model.Item.GetBoolean("IncludeDeliveryTimeInStockMessage"); 38 string defaultStockGroupId = Model.Item.GetRawValueString("DefaultStockState", string.Empty); 39 bool forceStockStateDefault = Model.Item.GetBoolean("ForceStockStateToDefault"); 40 string neverOutOfStockBehavior = Model.Item.GetRawValueString("NeverOutOfStockBehavior"); 41 42 string layout = Model.Item.GetRawValueString("Layout", "icon-top"); 43 string contentPadding = Model.Item.GetRawValueString("SpaceAround", ""); 44 contentPadding = contentPadding == "none" ? " px-0 py-3" : contentPadding; 45 contentPadding = contentPadding == "small" ? " px-3 py-3" : contentPadding; 46 contentPadding = contentPadding == "large" ? " ps-5 pe-3 py-3" : contentPadding; 47 48 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 49 horizontalAlign = horizontalAlign == "center" ? "text-center" : horizontalAlign; 50 horizontalAlign = horizontalAlign == "end" ? "text-end" : horizontalAlign; 51 52 var languageId = Dynamicweb.Ecommerce.Common.Context.LanguageID; 53 54 StockStatus productStockStatus = null; 55 Product prod = Dynamicweb.Ecommerce.Services.Products.GetProductById(product?.Id,product?.VariantId,true); 56 string productStockGroupId = forceStockStateDefault ? defaultStockGroupId : prod.StockGroupId; 57 58 if (forceStockStateDefault) 59 { 60 productStockStatus = GetStockDefaultState(productStockGroupId, product?.StockLevel); 61 } 62 if (neverOutOfStockBehavior == "highestAmount" && product != null && product.NeverOutOfstock) 63 { 64 StockService stockService = new StockService(); 65 productStockStatus = stockService.GetStockStatuses(productStockGroupId, true).LastOrDefault(); 66 } 67 68 string stockStatus = productStockStatus != null ? productStockStatus.GetText(languageId) : product?.StockStatus; 69 string deliveryTimeText = productStockStatus != null ? productStockStatus.GetExpectedDeliveryText(languageId) : product?.StockDeliveryText; 70 string deliveryTime = hasDeliveryTime && !string.IsNullOrEmpty(deliveryTimeText) ? " - " + Translate("Delivery in ") + deliveryTimeText + " " + (productStockStatus != null ? productStockStatus.GetExpectedDeliveryValue(languageId) : product.StockDeliveryValue) : string.Empty; 71 string stockIcon = productStockStatus?.Icon; 72 73 bool doDoRenderNeverOutOfStockProduct = product != null && product.NeverOutOfstock && neverOutOfStockBehavior == "doNotRenderAnything"; 74 75 string imageWidth = Model.Item.GetRawValueString("ImageWidth", string.Empty); 76 77 string liveInfoClass = ""; 78 string productInfoFeed = ""; 79 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 80 if (isLazyLoadingForProductInfoEnabled) 81 { 82 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 83 { 84 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 85 if (!string.IsNullOrEmpty(productInfoFeed)) 86 { 87 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 88 } 89 } 90 liveInfoClass = "js-live-info"; 91 } 92 WriteLiteral("\r\n"); 93 if (isLazyLoadingForProductInfoEnabled && !forceStockStateDefault) 94 { 95 WriteLiteral("\t<div"); 96 BeginWriteAttribute("class", " class=\"", 4773, "\"", 4884, 6); 97 WriteAttributeValue("", 4781, "js-stock-status", 4781, 15, true); 98 WriteAttributeValue(" ", 4796, contentPadding, 4797, 17, false); 99 WriteAttributeValue(" ", 4814, horizontalAlign, 4815, 16, false); 100 WriteAttributeValue(" ", 4831, "item_", 4832, 6, true); 101 WriteAttributeValue("", 4837, Model.Item.SystemName.ToLower(), 4837, 32, false); 102 WriteAttributeValue(" ", 4869, liveInfoClass, 4870, 14, false); 103 EndWriteAttribute(); 104 WriteLiteral(" "); 105 Write(productInfoFeed); 106 WriteLiteral(">\r\n\t\t<div class=\"spinner-border\">\r\n"); 107 switch (layout) 108 { 109 case "iconOnly": 110 if (!string.IsNullOrEmpty(stockIcon)) 111 { 112 WriteLiteral("\t\t\t\t\t\t<span class=\"d-none\" data-show-if=\"LiveProductInfo.product.stockStatus != null\">\r\n\t\t\t\t\t\t\t<img"); 113 BeginWriteAttribute("src", " src=\"", 5137, "\"", 5239, 5); 114 WriteAttributeValue("", 5143, "/Admin/Public/GetImage.ashx?image=", 5143, 34, true); 115 WriteAttributeValue("", 5177, stockIcon, 5177, 10, false); 116 WriteAttributeValue("", 5187, "&width=", 5187, 7, true); 117 WriteAttributeValue("", 5194, imageWidth, 5194, 11, false); 118 WriteAttributeValue("", 5205, "&crop=0&format=webp&compression=75", 5205, 34, true); 119 EndWriteAttribute(); 120 BeginWriteAttribute("alt", " alt=\"", 5240, "\"", 5258, 1); 121 WriteAttributeValue("", 5246, stockStatus, 5246, 12, false); 122 EndWriteAttribute(); 123 WriteLiteral(">\r\n\t\t\t\t\t\t</span>\r\n"); 124 } 125 126 break; 127 case "iconAndText": 128 if (!string.IsNullOrEmpty(stockIcon)) 129 { 130 WriteLiteral("\t\t\t\t\t\t<span class=\"d-none\" data-show-if=\"LiveProductInfo.product.stockStatus != null\">\r\n\t\t\t\t\t\t\t<img"); 131 BeginWriteAttribute("src", " src=\"", 5476, "\"", 5578, 5); 132 WriteAttributeValue("", 5482, "/Admin/Public/GetImage.ashx?image=", 5482, 34, true); 133 WriteAttributeValue("", 5516, stockIcon, 5516, 10, false); 134 WriteAttributeValue("", 5526, "&width=", 5526, 7, true); 135 WriteAttributeValue("", 5533, imageWidth, 5533, 11, false); 136 WriteAttributeValue("", 5544, "&crop=0&format=webp&compression=75", 5544, 34, true); 137 EndWriteAttribute(); 138 BeginWriteAttribute("alt", " alt=\"", 5579, "\"", 5597, 1); 139 WriteAttributeValue("", 5585, stockStatus, 5585, 12, false); 140 EndWriteAttribute(); 141 WriteLiteral(">\r\n\t\t\t\t\t\t</span>\r\n"); 142 } 143 144 WriteLiteral("\t\t\t\t\t<span class=\"d-none js-text-stock-status\" data-show-if=\"!LiveProductInfo.product.neverOutOfstock\"></span>\r\n\t\t\t\t\t<span class=\"d-none\" data-show-if=\"LiveProductInfo.product.neverOutOfstock\">"); 145 Write(stockStatus); 146 WriteLiteral("</span>\r\n"); 147 148 if (hasDeliveryTime) 149 { 150 WriteLiteral(@" <span class=""d-none"" data-show-if=""LiveProductInfo.product.stockDeliveryText != null && LiveProductInfo.product.stockDeliveryText != '' && LiveProductInfo.product.stockDeliveryValue != null && LiveProductInfo.product.stockDeliveryValue != ''""> 151 - "); 152 Write(Translate("Delivery in ")); 153 WriteLiteral(" <span class=\"js-text-stock-delivery\"></span>\r\n\t\t\t\t\t\t</span>\r\n"); 154 } 155 156 break; 157 case "textAndIcon": 158 WriteLiteral("\t\t\t\t\t<span class=\"d-none js-text-stock-status\" data-show-if=\"!LiveProductInfo.product.neverOutOfstock\"></span>\r\n\t\t\t\t\t<span class=\"d-none\" data-show-if=\"LiveProductInfo.product.neverOutOfstock\">"); 159 Write(stockStatus); 160 WriteLiteral("</span>\r\n"); 161 162 if (hasDeliveryTime) 163 { 164 WriteLiteral(@" <span class=""d-none"" data-show-if=""LiveProductInfo.product.stockDeliveryText != null && LiveProductInfo.product.stockDeliveryText != '' && LiveProductInfo.product.stockDeliveryValue != null && LiveProductInfo.product.stockDeliveryValue != ''""> 165 - "); 166 Write(Translate("Delivery in ")); 167 WriteLiteral(" <span class=\"js-text-stock-delivery\"></span>\r\n\t\t\t\t\t\t</span>\r\n"); 168 } 169 170 if (!string.IsNullOrEmpty(stockIcon)) 171 { 172 WriteLiteral("\t\t\t\t\t\t<span class=\"d-none\" data-show-if=\"LiveProductInfo.product.stockStatus != null\">\r\n\t\t\t\t\t\t\t<img"); 173 BeginWriteAttribute("src", " src=\"", 7048, "\"", 7150, 5); 174 WriteAttributeValue("", 7054, "/Admin/Public/GetImage.ashx?image=", 7054, 34, true); 175 WriteAttributeValue("", 7088, stockIcon, 7088, 10, false); 176 WriteAttributeValue("", 7098, "&width=", 7098, 7, true); 177 WriteAttributeValue("", 7105, imageWidth, 7105, 11, false); 178 WriteAttributeValue("", 7116, "&crop=0&format=webp&compression=75", 7116, 34, true); 179 EndWriteAttribute(); 180 BeginWriteAttribute("alt", " alt=\"", 7151, "\"", 7169, 1); 181 WriteAttributeValue("", 7157, stockStatus, 7157, 12, false); 182 EndWriteAttribute(); 183 WriteLiteral(">\r\n\t\t\t\t\t\t</span>\r\n"); 184 } 185 186 break; 187 case "textOnly": 188 WriteLiteral("\t\t\t\t\t<span class=\"d-none js-text-stock-status\" data-show-if=\"!LiveProductInfo.product.neverOutOfstock\"></span>\r\n\t\t\t\t\t<span class=\"d-none\" data-show-if=\"LiveProductInfo.product.neverOutOfstock\">"); 189 Write(stockStatus); 190 WriteLiteral("</span>\r\n"); 191 192 if (hasDeliveryTime) 193 { 194 WriteLiteral(@" <span class=""d-none"" data-show-if=""LiveProductInfo.product.stockDeliveryText != null && LiveProductInfo.product.stockDeliveryText != '' && LiveProductInfo.product.stockDeliveryValue != null && LiveProductInfo.product.stockDeliveryValue != ''""> 195 - "); 196 Write(Translate("Delivery in ")); 197 WriteLiteral(" <span class=\"js-text-stock-delivery\"></span>\r\n\t\t\t\t\t\t</span>\r\n"); 198 } 199 200 break; 201 } 202 WriteLiteral("\t\t</div>\r\n\t</div>\r\n"); 203 } 204 else if (!doDoRenderNeverOutOfStockProduct && (!string.IsNullOrEmpty(stockStatus) && !layout.Equals("iconOnly", StringComparison.InvariantCultureIgnoreCase)) || (!string.IsNullOrEmpty(stockStatus) && layout.Equals("iconOnly", StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrEmpty(stockIcon))) 205 { 206 WriteLiteral("\t<div"); 207 BeginWriteAttribute("class", " class=\"", 8206, "\"", 8286, 4); 208 WriteAttributeValue("", 8214, contentPadding, 8214, 17, false); 209 WriteAttributeValue(" ", 8231, horizontalAlign, 8232, 16, false); 210 WriteAttributeValue(" ", 8248, "item_", 8249, 6, true); 211 WriteAttributeValue("", 8254, Model.Item.SystemName.ToLower(), 8254, 32, false); 212 EndWriteAttribute(); 213 WriteLiteral(">\r\n"); 214 switch (layout) 215 { 216 case "iconOnly": 217 if (!string.IsNullOrEmpty(stockIcon)) 218 { 219 WriteLiteral("\t\t\t\t\t<span>\r\n\t\t\t\t\t\t<img"); 220 BeginWriteAttribute("src", " src=\"", 8409, "\"", 8511, 5); 221 WriteAttributeValue("", 8415, "/Admin/Public/GetImage.ashx?image=", 8415, 34, true); 222 WriteAttributeValue("", 8449, stockIcon, 8449, 10, false); 223 WriteAttributeValue("", 8459, "&width=", 8459, 7, true); 224 WriteAttributeValue("", 8466, imageWidth, 8466, 11, false); 225 WriteAttributeValue("", 8477, "&crop=0&format=webp&compression=75", 8477, 34, true); 226 EndWriteAttribute(); 227 BeginWriteAttribute("alt", " alt=\"", 8512, "\"", 8530, 1); 228 WriteAttributeValue("", 8518, stockStatus, 8518, 12, false); 229 EndWriteAttribute(); 230 WriteLiteral(">\r\n\t\t\t\t\t</span>\r\n"); 231 } 232 233 break; 234 case "iconAndText": 235 if (!string.IsNullOrEmpty(stockIcon)) 236 { 237 WriteLiteral("\t\t\t\t\t<span>\r\n\t\t\t\t\t\t<img"); 238 BeginWriteAttribute("src", " src=\"", 8666, "\"", 8768, 5); 239 WriteAttributeValue("", 8672, "/Admin/Public/GetImage.ashx?image=", 8672, 34, true); 240 WriteAttributeValue("", 8706, stockIcon, 8706, 10, false); 241 WriteAttributeValue("", 8716, "&width=", 8716, 7, true); 242 WriteAttributeValue("", 8723, imageWidth, 8723, 11, false); 243 WriteAttributeValue("", 8734, "&crop=0&format=webp&compression=75", 8734, 34, true); 244 EndWriteAttribute(); 245 BeginWriteAttribute("alt", " alt=\"", 8769, "\"", 8787, 1); 246 WriteAttributeValue("", 8775, stockStatus, 8775, 12, false); 247 EndWriteAttribute(); 248 WriteLiteral(">\r\n\t\t\t\t\t</span>\r\n"); 249 } 250 251 WriteLiteral("\t\t\t\t<span>"); 252 Write(stockStatus); 253 Write(deliveryTime); 254 WriteLiteral("</span>\r\n"); 255 256 break; 257 case "textAndIcon": 258 WriteLiteral("\t\t\t\t<span>"); 259 Write(stockStatus); 260 Write(deliveryTime); 261 WriteLiteral("</span>\r\n"); 262 263 if (!string.IsNullOrEmpty(stockIcon)) 264 { 265 WriteLiteral("\t\t\t\t\t<span>\r\n\t\t\t\t\t\t<img"); 266 BeginWriteAttribute("src", " src=\"", 9015, "\"", 9117, 5); 267 WriteAttributeValue("", 9021, "/Admin/Public/GetImage.ashx?image=", 9021, 34, true); 268 WriteAttributeValue("", 9055, stockIcon, 9055, 10, false); 269 WriteAttributeValue("", 9065, "&width=", 9065, 7, true); 270 WriteAttributeValue("", 9072, imageWidth, 9072, 11, false); 271 WriteAttributeValue("", 9083, "&crop=0&format=webp&compression=75", 9083, 34, true); 272 EndWriteAttribute(); 273 BeginWriteAttribute("alt", " alt=\"", 9118, "\"", 9136, 1); 274 WriteAttributeValue("", 9124, stockStatus, 9124, 12, false); 275 EndWriteAttribute(); 276 WriteLiteral(">\r\n\t\t\t\t\t</span>\r\n"); 277 } 278 279 break; 280 case "textOnly": 281 WriteLiteral("\t\t\t\t<span>"); 282 Write(stockStatus); 283 Write(deliveryTime); 284 WriteLiteral("</span>\r\n"); 285 break; 286 } 287 WriteLiteral("\t</div>\r\n"); 288 } 289 else if (Pageview.IsVisualEditorMode) 290 { 291 WriteLiteral("\t<div class=\"alert alert-dark m-0\">"); 292 Write(Translate("Stock state will be rendered here")); 293 WriteLiteral("</div>\r\n"); 294 } 295 } 296 #pragma warning restore 1998 297 298 static Dynamicweb.Ecommerce.Stocks.StockStatus GetStockDefaultState(string defaultStockGroupId, double? stock) 299 { 300 IEnumerable<Dynamicweb.Ecommerce.Stocks.StockStatus> defaultStockStatuses = Dynamicweb.Ecommerce.Services.StockService.GetStockStatuses(defaultStockGroupId, true); 301 foreach (var status in defaultStockStatuses) 302 { 303 switch (status.Definition ?? "") 304 { 305 case "<=": 306 if (stock <= status.Rate) 307 { 308 return status; 309 } 310 continue; 311 case ">=": 312 if (stock >= status.Rate) 313 { 314 return status; 315 } 316 continue; 317 } 318 } 319 return null; 320 } 321 } 322 } 323 #pragma warning restore 1591 324
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel> 2 @using System 3 @using System.Collections.Generic 4 @using System.Linq 5 @using Dynamicweb.Ecommerce.ProductCatalog 6 @using Dynamicweb.Ecommerce.Products 7 @using Dynamicweb.Ecommerce.Stocks 8 9 @functions 10 { 11 static Dynamicweb.Ecommerce.Stocks.StockStatus GetStockDefaultState(string defaultStockGroupId, double? stock) 12 { 13 IEnumerable<Dynamicweb.Ecommerce.Stocks.StockStatus> defaultStockStatuses = Dynamicweb.Ecommerce.Services.StockService.GetStockStatuses(defaultStockGroupId, true); 14 foreach (var status in defaultStockStatuses) 15 { 16 switch (status.Definition ?? "") 17 { 18 case "<=": 19 if (stock <= status.Rate) 20 { 21 return status; 22 } 23 continue; 24 case ">=": 25 if (stock >= status.Rate) 26 { 27 return status; 28 } 29 continue; 30 } 31 } 32 return null; 33 } 34 } 35 36 @{ 37 ProductViewModel product = null; 38 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails")) 39 { 40 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"]; 41 } 42 else if (Pageview.Page.Item["DummyProduct"] != null && Pageview.IsVisualEditorMode) 43 { 44 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page); 45 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel(); 46 47 if (productList?.Products is object) 48 { 49 product = productList.Products[0]; 50 } 51 } 52 53 bool hasDeliveryTime = Model.Item.GetBoolean("IncludeDeliveryTimeInStockMessage"); 54 string defaultStockGroupId = Model.Item.GetRawValueString("DefaultStockState", string.Empty); 55 bool forceStockStateDefault = Model.Item.GetBoolean("ForceStockStateToDefault"); 56 string neverOutOfStockBehavior = Model.Item.GetRawValueString("NeverOutOfStockBehavior"); 57 58 string layout = Model.Item.GetRawValueString("Layout", "icon-top"); 59 string contentPadding = Model.Item.GetRawValueString("SpaceAround", ""); 60 contentPadding = contentPadding == "none" ? " px-0 py-3" : contentPadding; 61 contentPadding = contentPadding == "small" ? " px-3 py-3" : contentPadding; 62 contentPadding = contentPadding == "large" ? " ps-5 pe-3 py-3" : contentPadding; 63 64 string horizontalAlign = Model.Item.GetRawValueString("HorizontalAlignment", ""); 65 horizontalAlign = horizontalAlign == "center" ? "text-center" : horizontalAlign; 66 horizontalAlign = horizontalAlign == "end" ? "text-end" : horizontalAlign; 67 68 var languageId = Dynamicweb.Ecommerce.Common.Context.LanguageID; 69 70 StockStatus productStockStatus = null; 71 Product prod = Dynamicweb.Ecommerce.Services.Products.GetProductById(product?.Id,product?.VariantId,true); 72 string productStockGroupId = forceStockStateDefault ? defaultStockGroupId : prod.StockGroupId; 73 74 if (forceStockStateDefault) 75 { 76 productStockStatus = GetStockDefaultState(productStockGroupId, product?.StockLevel); 77 } 78 if (neverOutOfStockBehavior == "highestAmount" && product != null && product.NeverOutOfstock) 79 { 80 StockService stockService = new StockService(); 81 productStockStatus = stockService.GetStockStatuses(productStockGroupId, true).LastOrDefault(); 82 } 83 84 string stockStatus = productStockStatus != null ? productStockStatus.GetText(languageId) : product?.StockStatus; 85 string deliveryTimeText = productStockStatus != null ? productStockStatus.GetExpectedDeliveryText(languageId) : product?.StockDeliveryText; 86 string deliveryTime = hasDeliveryTime && !string.IsNullOrEmpty(deliveryTimeText) ? " - " + Translate("Delivery in ") + deliveryTimeText + " " + (productStockStatus != null ? productStockStatus.GetExpectedDeliveryValue(languageId) : product.StockDeliveryValue) : string.Empty; 87 string stockIcon = productStockStatus?.Icon; 88 89 bool doDoRenderNeverOutOfStockProduct = product != null && product.NeverOutOfstock && neverOutOfStockBehavior == "doNotRenderAnything"; 90 91 string imageWidth = Model.Item.GetRawValueString("ImageWidth", string.Empty); 92 93 string liveInfoClass = ""; 94 string productInfoFeed = ""; 95 bool isLazyLoadingForProductInfoEnabled = Dynamicweb.Core.Converter.ToBoolean(Dynamicweb.Context.Current.Items["IsLazyLoadingForProductInfoEnabled"]); 96 if (isLazyLoadingForProductInfoEnabled) 97 { 98 if (Dynamicweb.Context.Current.Items.Contains("ProductInfoFeed")) 99 { 100 productInfoFeed = Dynamicweb.Context.Current.Items["ProductInfoFeed"]?.ToString(); 101 if (!string.IsNullOrEmpty(productInfoFeed)) 102 { 103 productInfoFeed = $"data-product-info-feed=\"{productInfoFeed}\""; 104 } 105 } 106 liveInfoClass = "js-live-info"; 107 } 108 } 109 110 @if (isLazyLoadingForProductInfoEnabled && !forceStockStateDefault) 111 { 112 <div class="js-stock-status @(contentPadding) @horizontalAlign item_@Model.Item.SystemName.ToLower() @liveInfoClass" @productInfoFeed> 113 <div class="spinner-border"> 114 @switch (layout) 115 { 116 case "iconOnly": 117 if (!string.IsNullOrEmpty(stockIcon)) 118 { 119 <span class="d-none" data-show-if="LiveProductInfo.product.stockStatus != null"> 120 <img src="/Admin/Public/GetImage.ashx?image=@stockIcon&width=@imageWidth&crop=0&format=webp&compression=75" alt="@stockStatus"> 121 </span> 122 } 123 124 break; 125 case "iconAndText": 126 if (!string.IsNullOrEmpty(stockIcon)) 127 { 128 <span class="d-none" data-show-if="LiveProductInfo.product.stockStatus != null"> 129 <img src="/Admin/Public/GetImage.ashx?image=@stockIcon&width=@imageWidth&crop=0&format=webp&compression=75" alt="@stockStatus"> 130 </span> 131 } 132 133 <span class="d-none js-text-stock-status" data-show-if="!LiveProductInfo.product.neverOutOfstock"></span> 134 <span class="d-none" data-show-if="LiveProductInfo.product.neverOutOfstock">@stockStatus</span> 135 136 if (hasDeliveryTime) 137 { 138 <span class="d-none" data-show-if="LiveProductInfo.product.stockDeliveryText != null && LiveProductInfo.product.stockDeliveryText != '' && LiveProductInfo.product.stockDeliveryValue != null && LiveProductInfo.product.stockDeliveryValue != ''"> 139 - @Translate("Delivery in ") <span class="js-text-stock-delivery"></span> 140 </span> 141 } 142 143 break; 144 case "textAndIcon": 145 <span class="d-none js-text-stock-status" data-show-if="!LiveProductInfo.product.neverOutOfstock"></span> 146 <span class="d-none" data-show-if="LiveProductInfo.product.neverOutOfstock">@stockStatus</span> 147 148 if (hasDeliveryTime) 149 { 150 <span class="d-none" data-show-if="LiveProductInfo.product.stockDeliveryText != null && LiveProductInfo.product.stockDeliveryText != '' && LiveProductInfo.product.stockDeliveryValue != null && LiveProductInfo.product.stockDeliveryValue != ''"> 151 - @Translate("Delivery in ") <span class="js-text-stock-delivery"></span> 152 </span> 153 } 154 155 if (!string.IsNullOrEmpty(stockIcon)) 156 { 157 <span class="d-none" data-show-if="LiveProductInfo.product.stockStatus != null"> 158 <img src="/Admin/Public/GetImage.ashx?image=@stockIcon&width=@imageWidth&crop=0&format=webp&compression=75" alt="@stockStatus"> 159 </span> 160 } 161 162 break; 163 case "textOnly": 164 <span class="d-none js-text-stock-status" data-show-if="!LiveProductInfo.product.neverOutOfstock"></span> 165 <span class="d-none" data-show-if="LiveProductInfo.product.neverOutOfstock">@stockStatus</span> 166 167 if (hasDeliveryTime) 168 { 169 <span class="d-none" data-show-if="LiveProductInfo.product.stockDeliveryText != null && LiveProductInfo.product.stockDeliveryText != '' && LiveProductInfo.product.stockDeliveryValue != null && LiveProductInfo.product.stockDeliveryValue != ''"> 170 - @Translate("Delivery in ") <span class="js-text-stock-delivery"></span> 171 </span> 172 } 173 174 break; 175 } 176 </div> 177 </div> 178 } 179 else if (!doDoRenderNeverOutOfStockProduct && (!string.IsNullOrEmpty(stockStatus) && !layout.Equals("iconOnly", StringComparison.InvariantCultureIgnoreCase)) || (!string.IsNullOrEmpty(stockStatus) && layout.Equals("iconOnly", StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrEmpty(stockIcon))) 180 { 181 <div class="@(contentPadding) @horizontalAlign item_@Model.Item.SystemName.ToLower()"> 182 @switch (layout) 183 { 184 case "iconOnly": 185 if (!string.IsNullOrEmpty(stockIcon)) 186 { 187 <span> 188 <img src="/Admin/Public/GetImage.ashx?image=@stockIcon&width=@imageWidth&crop=0&format=webp&compression=75" alt="@stockStatus"> 189 </span> 190 } 191 192 break; 193 case "iconAndText": 194 if (!string.IsNullOrEmpty(stockIcon)) 195 { 196 <span> 197 <img src="/Admin/Public/GetImage.ashx?image=@stockIcon&width=@imageWidth&crop=0&format=webp&compression=75" alt="@stockStatus"> 198 </span> 199 } 200 201 <span>@stockStatus@deliveryTime</span> 202 203 break; 204 case "textAndIcon": 205 <span>@stockStatus@deliveryTime</span> 206 207 if (!string.IsNullOrEmpty(stockIcon)) 208 { 209 <span> 210 <img src="/Admin/Public/GetImage.ashx?image=@stockIcon&width=@imageWidth&crop=0&format=webp&compression=75" alt="@stockStatus"> 211 </span> 212 } 213 214 break; 215 case "textOnly": 216 <span>@stockStatus@deliveryTime</span> 217 break; 218 } 219 </div> 220 } 221 else if (Pageview.IsVisualEditorMode) 222 { 223 <div class="alert alert-dark m-0">@Translate("Stock state will be rendered here")</div> 224 }
Delivery within 7 work days
3 years warranty