Mit Bilvalg Showroom

34 biler

Populære filtre

Sortering

Mærke

Error executing template "/Designs/Swift/Paragraph/Swift_ProductListGridView_CustomReadMore.cshtml"
System.FormatException: Input string was not in a correct format.
   at System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
   at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info)
   at System.String.System.IConvertible.ToInt32(IFormatProvider provider)
   at CompiledRazorTemplates.Dynamic.RazorEngine_ad3ab5b00dbc4c83ab4ad76f715f8240.<RenderProductList>b__0_0(TextWriter __razor_helper_writer) in D:\DynamicWeb\Solutions\fleggaard-leasing-dw.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListGridView_CustomReadMore.cshtml:line 118
   at CompiledRazorTemplates.Dynamic.RazorEngine_ad3ab5b00dbc4c83ab4ad76f715f8240.Execute() in D:\DynamicWeb\Solutions\fleggaard-leasing-dw.com\Files\Templates\Designs\Swift\Paragraph\Swift_ProductListGridView_CustomReadMore.cshtml:line 19
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context, TextWriter reader)
   at RazorEngine.Templating.RazorEngineService.RunCompile(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
   at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass16_0.<RunCompile>b__0(TextWriter writer)
   at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
   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.Ecommerce.CustomerExperienceCenter.Favorites 4 5 @{ 6 string theme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("Theme")) ? " theme " + Model.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : ""; 7 string themePadding = theme != string.Empty ? "p-3" : string.Empty; 8 } 9 10 @if (!string.IsNullOrEmpty(theme)) 11 { 12 <div class="h-100@(theme) @themePadding"> 13 @RenderProductList() 14 </div> 15 } 16 else 17 { 18 <div class="pt-3"> 19 @RenderProductList() 20 </div> 21 } 22 23 @helper RenderProductList() 24 { 25 ProductListViewModel productList = new ProductListViewModel(); 26 27 if (Dynamicweb.Context.Current.Items.Contains("ProductList")) 28 { 29 productList = (ProductListViewModel)Dynamicweb.Context.Current.Items["ProductList"]; 30 } 31 32 string anonymousUsersLimitations = Pageview.AreaSettings.GetRawValueString("AnonymousUsers", ""); 33 bool anonymousUser = Pageview.User == null; 34 bool hidePrice = anonymousUsersLimitations.Contains("price") && anonymousUser; 35 36 string detailsPageLink = Dynamicweb.Context.Current.Items["DetailsPageLink"] != null ? Dynamicweb.Context.Current.Items["DetailsPageLink"].ToString() : ""; 37 string productTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ProductTheme")) ? " theme " + Model.Item.GetRawValueString("ProductTheme").Replace(" ", "").Trim().ToLower() : ""; 38 string productThemePadding = productTheme != string.Empty ? "p-3" : string.Empty; 39 40 string url = Dynamicweb.Context.Current.Request.RawUrl; 41 bool hideFavoritesSelector = !string.IsNullOrEmpty(Model.Item.GetString("HideFavoritesSelector")) ? Model.Item.GetBoolean("HideFavoritesSelector") : false; 42 string staticVariantsLayout = Model.Item.GetRawValueString("StaticVariantsLayout", "hide"); 43 44 string groupId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("GroupID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("GroupID") : ""; 45 46 var badgeParms = new Dictionary<string, object>(); 47 badgeParms.Add("saleBadgeType", Model.Item.GetRawValue("SaleBadgeType")); 48 badgeParms.Add("saleBadgeCssClassName", Model.Item.GetRawValue("SaleBadgeDesign")); 49 badgeParms.Add("newBadgeCssClassName", Model.Item.GetRawValue("NewBadgeDesign")); 50 badgeParms.Add("newPublicationDays", Model.Item.GetInt32("NewPublicationDays")); 51 badgeParms.Add("campaignBadgesValues", Model.Item.GetRawValueString("CampaignBadges")); 52 53 bool saleBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("SaleBadgeDesign")) && Model.Item.GetRawValueString("SaleBadgeDesign") != "none" ? true : false; 54 bool newBadgeEnabled = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("NewBadgeDesign")) && Model.Item.GetRawValueString("NewBadgeDesign") != "none" ? true : false; 55 56 string customerNumber = null; 57 if (!anonymousUser) 58 { 59 customerNumber = Pageview.User.CustomerNumber; 60 61 } 62 63 64 var favoriteParameters = new Dictionary<string, object>(); 65 if (!anonymousUser && !hideFavoritesSelector) 66 { 67 int defaultFavoriteListId = 0; 68 69 IEnumerable<FavoriteList> favoreiteLists = Pageview.User.GetFavoriteLists(); 70 if (favoreiteLists.Count() == 1) 71 { 72 foreach (FavoriteList list in favoreiteLists) 73 { 74 defaultFavoriteListId = list.ListId; 75 } 76 } 77 78 favoriteParameters.Add("ListId", defaultFavoriteListId); 79 } 80 81 if (productList.TotalProductsCount > 0) 82 { 83 int pageSizeSetting = 30; 84 int pageSize = productList.PageSize; 85 pageSize += pageSizeSetting; 86 87 int loadedProducts = productList.PageSize > productList.TotalProductsCount ? productList.TotalProductsCount : productList.PageSize; 88 89 <div class="grid grid-2 grid-lg-3"> 90 @foreach (ProductViewModel product in productList.Products) 91 { 92 var defaultGroupId = product.PrimaryOrDefaultGroup.Id; 93 var selectedDetailPage = Dynamicweb.Ecommerce.Services.ProductGroups.GetGroup(defaultGroupId)?.Meta.PrimaryPage ?? string.Empty; 94 95 string link = string.IsNullOrEmpty(selectedDetailPage) ? $"{detailsPageLink}&groupid={defaultGroupId}" : selectedDetailPage; 96 link += "&productid=" + product.Id; 97 link += !string.IsNullOrEmpty(product.VariantId) ? "&variantid=" + product.VariantId : ""; 98 99 string imagePath = product?.DefaultImage?.Value ?? ""; 100 imagePath = Dynamicweb.Context.Current.Server.UrlEncode(imagePath); 101 102 string ratio = Model.Item.GetRawValueString("ImageAspectRatio", ""); 103 ratio = ratio != "0" ? ratio : ""; 104 string ratioCssClass = ratio != "" ? " ratio" : ""; 105 string ratioVariable = ratio != "" ? "--bs-aspect-ratio: " + ratio : ""; 106 107 string imagePathXs = "/Admin/Public/GetImage.ashx?width=" + 480 + "&image=" + imagePath + "&format=webp"; 108 string imagePathS = "/Admin/Public/GetImage.ashx?width=" + 640 + "&image=" + imagePath + "&format=webp"; 109 string imagePathFallBack = "/Admin/Public/GetImage.ashx?width=" + 640 + "&image=" + imagePath + "&format=webp"; 110 111 string imageTheme = !string.IsNullOrWhiteSpace(Model.Item.GetRawValueString("ImageTheme")) ? " theme " + Model.Item.GetRawValueString("ImageTheme").Replace(" ", "").Trim().ToLower() : ""; 112 string imageThemePadding = imageTheme != string.Empty ? "p-3" : string.Empty; 113 string imageOutlineStyle = imageTheme == string.Empty ? "style=\"border: 1px solid transparent\"" : string.Empty; 114 115 string imageId = "ProductImage_" + product.Id + product.VariantId; 116 string priceId = "ProductPrice_" + product.Id + product.VariantId; 117 118 int carSumTaxBaseAmountDkkToShowPrice = Convert.ToInt32(product.ProductFields["CarSumTaxBaseAmountDkk"].Value); 119 120 string showPricesWithVat = Pageview.Area.EcomPricesWithVat.ToLower(); 121 bool neverShowVat = string.IsNullOrEmpty(showPricesWithVat); 122 123 @* Alternative image *@ 124 var supportedImageFormats = new string[] { ".jpg", ".webp", ".png", ".gif" }; 125 string defaultImage = product.DefaultImage != null ? product.DefaultImage.Value : ""; 126 var selectedAssetCategories = Model.Item.GetRawValueString("AlternativeImageAssets"); 127 IEnumerable<MediaViewModel> alternativeImagesList = product.AssetCategories.Where(x => selectedAssetCategories.Contains(x.SystemName)).SelectMany(x => x.Assets); 128 129 if (alternativeImagesList.FirstOrDefault() != null) 130 { 131 alternativeImagesList = alternativeImagesList.OrderByDescending(x => x.Value.Equals(defaultImage)); 132 133 if (alternativeImagesList.First().Value == defaultImage) 134 { 135 alternativeImagesList = alternativeImagesList.Skip(1); 136 } 137 } 138 139 string alternativeImage = alternativeImagesList.FirstOrDefault() != null ? alternativeImagesList.FirstOrDefault().Value : ""; 140 alternativeImage = !string.IsNullOrEmpty(alternativeImage) ? "/Admin/Public/GetImage.ashx?width=" + 640 + "&image=" + alternativeImage + "&format=webp" : ""; 141 142 @* Badges *@ 143 DateTime createdDate = product.Created.Value; 144 bool showBadges = saleBadgeEnabled && product.Discount.Price != 0 ? true : false; 145 showBadges = (newBadgeEnabled && Model.Item.GetInt32("NewPublicationDays") == 0) || (newBadgeEnabled && (createdDate.AddDays(Model.Item.GetInt32("NewPublicationDays")) > DateTime.Now)) ? true : showBadges; 146 showBadges = !string.IsNullOrEmpty(Model.Item.GetRawValueString("CampaignBadges")) ? true : showBadges; 147 148 @* Main features *@ 149 IEnumerable<string> selectedDisplayGroups = Model.Item.GetRawValueString("MainFeatures").Split(',').ToList(); 150 List<CategoryFieldViewModel> mainFeatures = new List<CategoryFieldViewModel>(); 151 152 foreach (var selection in selectedDisplayGroups) 153 { 154 foreach (CategoryFieldViewModel group in product.FieldDisplayGroups.Values) 155 { 156 if (selection == group.Id) 157 { 158 mainFeatures.Add(group); 159 } 160 } 161 } 162 163 <article class="position-relative@(productTheme) product-list-item" itemscope itemtype="https://schema.org/Product"> 164 @if (!anonymousUser && !hideFavoritesSelector && product.VariantInfo.VariantInfo == null) 165 { 166 <div class="position-absolute top-0 end-0 my-3" style="z-index: 2"> 167 @RenderPartial("Components/ToggleFavorite.cshtml", product, favoriteParameters) 168 </div> 169 } 170 171 @if (showBadges) 172 { 173 <div class="position-absolute top-0 left-0 p-1 p-lg-5 ps-0 ps-lg-0" style="z-index: 2"> 174 @RenderPartial("Components/EcommerceBadge.cshtml", product, badgeParms) 175 </div> 176 } 177 178 <a href="@link" class="d-flex flex-column d-block h-100 text-decoration-none"> 179 180 <div class="overflow-hidden@(imageTheme)" @imageOutlineStyle> 181 <div class="ratio" style="@(ratioVariable)"> 182 <div class="d-flex justify-content-center align-items-center"> 183 @if (string.IsNullOrEmpty(alternativeImage)) 184 { 185 <img id="@imageId" 186 srcset=" 187 @imagePathXs 480w, 188 @imagePathS 640w" 189 sizes="(min-width: 992px) 33vw, 50vw" 190 src="@imagePathFallBack" 191 loading="lazy" 192 decoding="async" 193 class="mw-100 mh-100 @imageThemePadding" 194 alt="@product.Name"> 195 } 196 else 197 { 198 <img id="@imageId" 199 src="@imagePathFallBack" 200 loading="lazy" 201 decoding="async" 202 class="mw-100 mh-100 @imageThemePadding" 203 alt="@product.Name" 204 onmouseover="this.src='@alternativeImage'" 205 onmouseout="this.src='@imagePathFallBack'"> 206 } 207 </div> 208 </div> 209 210 211 <div class="position-relative"> 212 @if (product.VariantInfo.VariantInfo != null && staticVariantsLayout == "images") 213 { 214 int variantGroupCount = 0; 215 int showMaxVariantGroups = 2; 216 int showMaxVariants = 3; 217 var productVariantTheme = productTheme != "" ? productTheme : "bg-white"; 218 219 <div class="static-variants w-100 d-none d-lg-block position-absolute left-0 bottom-0 @productTheme" 220 id="StaticVariants_@product.Id" 221 style="pointer-events: none;"> 222 223 @foreach (var variantGroup in product.VariantGroups()) 224 { 225 int variantsCount = 0; 226 227 <div class="d-flex gap-2 mb-2"> 228 @foreach (var variant in variantGroup.Options) 229 { 230 if (variantGroupCount < showMaxVariantGroups) 231 { 232 var optionsCount = variantGroup.Options.Count(); 233 234 if (variantsCount < showMaxVariants) 235 { 236 string optionWidth = !string.IsNullOrEmpty(variant.Color) ? "w-25" : ""; 237 238 <article class="static-variants-option @optionWidth @(productVariantTheme)" title="@product.Name @variant.Name" style="pointer-events: initial;"> 239 @if (!string.IsNullOrEmpty(variant.Color)) 240 { 241 string defaultProductImage = Dynamicweb.Context.Current.Server.UrlEncode(product.DefaultImage.Value); 242 string variantImage = Dynamicweb.Context.Current.Server.UrlEncode(variant.Image.Value); 243 string defaultPrice = !hidePrice ? product.Price.PriceFormatted : "0"; 244 string variantPrice = !hidePrice ? product.Price.PriceFormatted : "0"; 245 246 <figure class="figure w-100 d-block m-0" onmouseover="switchVariantProduct('@product.Id', '@defaultPrice', '@variantImage')" onmouseout="switchVariantProduct('@product.Id', '@variantPrice', '@defaultProductImage')"> 247 <div class="d-flex align-items-center justify-content-center"> 248 <img src="/admin/public/GetImage.ashx?image=@variantImage&width=75&height=75&crop=5&FillCanvas=true&format=webp&Quality=70" height="75" width="75" class="p-1 text-small" loading="lazy" decoding="async" alt="@product.Name, @variant.Name"> 249 </div> 250 </figure> 251 } 252 else 253 { 254 <div class="d-flex align-items-center justify-content-center"> 255 @variant.Name 256 </div> 257 } 258 <div class="visually-hidden"> 259 <h4>@Translate("Variant Name")</h4> 260 <p>@product.Name, @variant.Name</p> 261 @if (!hidePrice) 262 { 263 <h4>@Translate("Variant Price")</h4> 264 <p><span class="text-price">@product.Price.PriceFormatted</span></p> 265 } 266 </div> 267 </article> 268 } 269 270 variantsCount++; 271 272 if (variantsCount == showMaxVariants && optionsCount != showMaxVariants) 273 { 274 int left = optionsCount - showMaxVariants; 275 <div class="variant-option ms-1 d-flex justify-content-center align-items-center"> 276 <span>+@left</span> 277 </div> 278 } 279 } 280 } 281 282 </div> 283 284 variantGroupCount++; 285 } 286 </div> 287 } 288 </div> 289 </div> 290 <div class="@productThemePadding"> 291 <div class="flex-grow-1"> 292 <h3 class="h6 mb-0 text-break"> 293 @product.Name @if (!string.IsNullOrEmpty(product.VariantName)) 294 {<text>(@product.VariantName)</text>} 295 </h3> 296 @if (!Model.Item.GetBoolean("HideProductNumber")) 297 { 298 <p class="fs-7 opacity-85 mb-2">@product.Number</p> 299 } 300 @if (mainFeatures.Count > 0) 301 { 302 <ul class="p-0 lh-sm opacity-75 product-data" style="list-style-type: none;"> 303 @foreach (CategoryFieldViewModel mainFeatureGroup in mainFeatures) 304 { 305 foreach (var field in mainFeatureGroup.Fields) 306 { 307 @RenderField(field.Value) 308 } 309 } 310 </ul> 311 } 312 </div> 313 314 @if (!hidePrice) 315 { 316 string priceMin = ""; 317 string priceMax = ""; 318 319 <div class="align-items-end"> 320 <div> 321 <span itemprop="priceCurrency" content="@product.Price.CurrencyCode" class="d-none"></span> 322 323 @if (showPricesWithVat == "false" && !neverShowVat) 324 { 325 string beforePrice = product.PriceBeforeDiscount.PriceWithoutVatFormatted; 326 327 <span itemprop="price" content="@product.Price.PriceWithoutVat" class="d-none"></span> 328 if (product.Price.Price != product.PriceBeforeDiscount.Price) 329 { 330 <span class="text-decoration-line-through opacity-75 me-3 text-price">@beforePrice</span> 331 } 332 } 333 else 334 { 335 string beforePrice = product.PriceBeforeDiscount.PriceFormatted; 336 337 <span itemprop="price" content="@product.Price.Price" class="d-none"></span> 338 if (product.Price.Price != product.PriceBeforeDiscount.Price) 339 { 340 <span class="text-decoration-line-through opacity-75 me-3 text-price">@beforePrice</span> 341 } 342 } 343 344 @if (showPricesWithVat == "false" && !neverShowVat) 345 { 346 string price = product.Price.PriceWithoutVatFormatted; 347 if (product?.VariantInfo?.VariantInfo != null) 348 { 349 priceMin = product?.VariantInfo?.PriceMin?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithoutVatFormatted : ""; 350 priceMax = product?.VariantInfo?.PriceMax?.PriceWithoutVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithoutVatFormatted : ""; 351 } 352 if (priceMin != priceMax) 353 { 354 price = priceMin + " - " + priceMax; 355 } 356 <span class="text-price">@price</span> 357 } 358 else 359 { 360 string price = product.Price.PriceFormatted; 361 if (product?.VariantInfo?.VariantInfo != null) 362 { 363 priceMin = product?.VariantInfo?.PriceMin?.PriceFormatted != null ? product.VariantInfo.PriceMin.PriceFormatted : ""; 364 priceMax = product?.VariantInfo?.PriceMax?.PriceFormatted != null ? product.VariantInfo.PriceMax.PriceFormatted : ""; 365 } 366 if (priceMin != priceMax) 367 { 368 price = priceMin + " - " + priceMax; 369 } 370 <div class="clearfix g-col-12 flex-column"> 371 <span class="text-wrap">@Translate("TCO price"):</span> 372 <span class="text-price float-sm-end">@price</span> 373 </div> 374 375 string carSumTaxBaseAmountDkk = Decimal.TryParse(Convert.ToString(product.ProductFields["CarSumTaxBaseAmountDkk"].Value), out decimal result) ? result.ToString("C2") : 0.ToString("C2"); 376 string carSumTaxBaseAmountDkkMth = Decimal.TryParse(Convert.ToString(product.ProductFields["CarSumTaxBaseAmountMthDkk"].Value), out decimal result2) ? result2.ToString("C2") : 0.ToString("C2"); 377 378 <div class="clearfix g-col-12 text-black-50"> 379 <span class="text-wrap">@Translate("Tax base"):</span> 380 <span class="text-price float-sm-end"> 381 @carSumTaxBaseAmountDkk 382 </span> 383 </div> 384 385 <div class="clearfix g-col-12 text-black-50"> 386 <span class="text-wrap"> 387 @Translate("Monthly tax"): 388 </span> 389 <span class="text-price float-sm-end"> 390 @carSumTaxBaseAmountDkkMth 391 392 </span> 393 </div> 394 } 395 </div> 396 @if (showPricesWithVat == "false" && !neverShowVat) 397 { 398 string price = product.Price.PriceWithVatFormatted; 399 if (product?.VariantInfo?.VariantInfo != null) 400 { 401 priceMin = product?.VariantInfo?.PriceMin?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMin.PriceWithVatFormatted : ""; 402 priceMax = product?.VariantInfo?.PriceMax?.PriceWithVatFormatted != null ? product.VariantInfo.PriceMax.PriceWithVatFormatted : ""; 403 } 404 if (priceMin != priceMax) 405 { 406 price = priceMin + " - " + priceMax; 407 } 408 <div class="fs-7 opacity-85 text-price">@price @Translate("Incl. VAT")</div> 409 } 410 </div> 411 } 412 @if (hidePrice && carSumTaxBaseAmountDkkToShowPrice>0) 413 { 414 string carSumTaxBaseAmountDkk = Decimal.TryParse(Convert.ToString(product.ProductFields["CarSumTaxBaseAmountDkk"].Value), out decimal result) ? result.ToString("C2") : 0.ToString("C2"); 415 string carSumTaxBaseAmountDkkMth = Decimal.TryParse(Convert.ToString(product.ProductFields["CarSumTaxBaseAmountMthDkk"].Value), out decimal result2) ? result2.ToString("C2") : 0.ToString("C2"); 416 417 <div class="clearfix g-col-12 text-black-50"> 418 <span class="text-wrap">@Translate("Tax base"):</span> 419 <span class="text-price float-sm-end"> 420 @carSumTaxBaseAmountDkk 421 </span> 422 </div> 423 424 <div class="clearfix g-col-12 text-black-50"> 425 <span class="text-wrap"> 426 @Translate("Monthly tax"): 427 </span> 428 <span class="text-price float-sm-end"> 429 @carSumTaxBaseAmountDkkMth 430 431 </span> 432 </div> 433 } 434 @if (product.VariantInfo.VariantInfo != null && staticVariantsLayout == "swatches") 435 { 436 var optionCount = product.VariantInfo.VariantInfo.Count(); 437 var showMaxVariants = 5; 438 439 <div class="d-flex flex-row gap-1 align-items-center"> 440 @foreach (VariantInfoViewModel variant in product.VariantInfo.VariantInfo.Take(showMaxVariants)) 441 { 442 <span class="colorbox colorbox-sm rounded-circle me-1" style="background-color: @variant.OptionColor"></span> 443 } 444 @if (optionCount > showMaxVariants) 445 { 446 int left = optionCount - showMaxVariants; 447 <span class="ms-2">+@left</span> 448 } 449 </div> 450 } 451 </div> 452 </a> 453 </article> 454 } 455 </div> 456 457 <div class="my-3"> 458 <div class="text-center d-flex flex-column gap-3"> 459 <div class="opacity-85">@loadedProducts @Translate("out of") @productList.TotalProductsCount @Translate("products")</div> 460 @if (productList.PageCount != 1) 461 { 462 string sortBySelection = Dynamicweb.Context.Current.Request?.Form["SortBy"] ?? "NameForSort"; 463 sortBySelection = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("SortBy")) ? Dynamicweb.Context.Current.Request.QueryString.Get("SortBy") : sortBySelection; 464 465 <form method="get" action="@url" data-response-target-element="content" class="w-100"> 466 @{ int groupCount = 0; 467 int totalGroups = productList.FacetGroups.Count(); 468 var loggedInUser = Dynamicweb.Security.UserManagement.User.GetCurrentExtranetUser(); 469 470 foreach (FacetGroupViewModel facetGroup in productList.FacetGroups) 471 { 472 473 var facetsLoop = facetGroup.Facets; 474 var sortedFacets = new List<FacetViewModel> 475 (); 476 477 foreach (FacetViewModel facet in facetsLoop) 478 { 479 sortedFacets.Add(facet); 480 } 481 482 483 484 foreach (FacetViewModel facet in sortedFacets) 485 { 486 487 488 if (facet.Options.Count() > 0 && !facet.Name.Contains("TCO") && !facet.Name.Contains("SUMTAX")) 489 { 490 491 492 string sortByFacets = Dynamicweb.Context.Current.Request?.Form[facet.QueryParameter] ?? facet.QueryParameter; 493 string sortBySelectionFacets = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get(facet.QueryParameter)) ? Dynamicweb.Context.Current.Request.QueryString.Get(facet.QueryParameter) : ""; 494 495 if (!string.IsNullOrEmpty(sortBySelectionFacets)) 496 { 497 <input type="hidden" name="@sortByFacets" value="@sortBySelectionFacets" /> 498 } 499 500 } 501 else if ((facet.Name.Contains("TCO") && loggedInUser != null) || (facet.Name.Contains("SUMTAXBASEAMOUNTDKK") && loggedInUser != null) || (facet.Name.Contains("SUMTAXBASEAMOUNTMTHDKK") && loggedInUser != null)) 502 { 503 504 505 506 string sortByTCO = Dynamicweb.Context.Current.Request?.Form[facet.QueryParameter] ?? facet.QueryParameter; 507 string sortBySelectionTCO = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get(facet.QueryParameter)) ? Dynamicweb.Context.Current.Request.QueryString.Get(facet.QueryParameter) : ""; 508 if (!string.IsNullOrEmpty(sortBySelectionTCO)) 509 { 510 <input type="hidden" name="@sortByTCO" value="@sortBySelectionTCO"> 511 } 512 } 513 514 groupCount++; 515 } 516 } } 517 518 @if (productList?.Group?.Id != null) 519 { 520 <input type="hidden" name="GroupId" value="@productList.Group.Id" /> 521 } 522 523 <input type="hidden" name="PageSize" value="@pageSize" /> 524 <input type="hidden" name="SortBy" value="@sortBySelection" /> 525 <input type="hidden" name="RequestType" value="UpdateList" /> 526 527 <button class="btn btn-primary" type="button" onclick="swift.ProductList.Update(event)">@Translate("Load more products")</button> 528 </form> 529 } 530 </div> 531 </div> 532 533 <script> 534 function switchVariantProduct(id, price, imagesrc) { 535 var productImageElement = document.querySelector("#ProductImage_" + id); 536 var productPriceElement = document.querySelector("#ProductPrice_" + id + " .text-price"); 537 538 if (productPriceElement) { 539 productPriceElement.innerText = price; 540 } 541 542 if (productImageElement) { 543 productImageElement.src = imagesrc; 544 545 var imageSrcset = productImageElement.srcset; 546 imageSrcset = imageSrcset.replace(/image=.*?&/g, 'image=' + imagesrc + "&"); 547 548 productImageElement.srcset = imageSrcset; 549 } 550 } 551 </script> 552 } 553 else 554 { 555 if (!Pageview.IsVisualEditorMode) 556 { 557 <div class="alert alert-dark m-0"> 558 @Translate("We did not find anything matching your search result") 559 </div> 560 } 561 else 562 { 563 <div class="alert alert-dark m-0" role="alert"> 564 <span>@Translate("Product list: The list will be shown here, if any")</span> 565 </div> 566 } 567 } 568 } 569 570 @helper RenderField(FieldValueViewModel field) 571 { 572 string fieldValue = field?.Value != null ? field.Value.ToString() : ""; 573 574 if (fieldValue != "") 575 { 576 fieldValue = fieldValue == "False" ? Translate("No") : fieldValue; 577 fieldValue = fieldValue == "True" ? Translate("Yes") : fieldValue; 578 579 if (field.Value.GetType() == typeof(System.Collections.Generic.List<FieldOptionValueViewModel>)) 580 { 581 fieldValue = ""; 582 583 foreach (FieldOptionValueViewModel option in field.Value as System.Collections.Generic.List<FieldOptionValueViewModel>) 584 { 585 fieldValue = option.Name; 586 } 587 } 588 589 bool isColor = false; 590 if (fieldValue.Contains("#") && (Translate(field.Name) == Translate("Color") || Translate(field.Name) == Translate("Colour"))) 591 { 592 isColor = true; 593 } 594 595 if (!string.IsNullOrEmpty(fieldValue)) 596 { 597 if (!isColor) 598 { 599 <li>@(field.Name): @fieldValue</li> 600 } 601 else 602 { 603 <li class="position-relative"> 604 <span class="colorbox-sm" style="background-color: @fieldValue"></span> 605 </li> 606 } 607 } 608 } 609 } 610
Ved at klikke ”Acceptér Alle” gives samtykke til at anvende cookies samt indsamling af persondata, som bidrager til forbedring af sitets funktionalitet, statistiske udtræk samt marketingrelaterede aktiviteter.