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_f1d8342ff7214cf19402e7761785518d.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
If you’re looking to turn your ride into a true racing machine, then this deep dish, carbon wheelset for tubular tires is as good as it gets!
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_6f19884329294f05ad51970e07846a64 : 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