Produktet blev tilføjet favoritliste Produktet blev fjernet fra din favoritliste
Otto schachner logo
Error executing template "Designs/OttoSchachner/eCom/ProductCatalog/ProductView.cshtml"
System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')
   at System.Collections.Generic.List`1.get_Item(Int32 index)
   at CompiledRazorTemplates.Dynamic.RazorEngine_6bfc52a8ff3e40a4b349ae4fdab36455.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.Ecommerce.ProductCatalog.ProductViewModel> 2 @using System.Diagnostics.SymbolStore 3 @using Dynamicweb.Content 4 @using Dynamicweb.Content.Data 5 @using Dynamicweb.Ecommerce 6 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites 7 @using Dynamicweb.Ecommerce.Prices 8 @using Dynamicweb.Frontend 9 @using Dynamicweb.Frontend.Devices 10 @using Dynamicweb.Frontend.Navigation 11 @using Dynamicweb.Ecommerce.ProductCatalog 12 @using Dynamicweb.Ecommerce.Products 13 @using Dynamicweb.Ecommerce.Shops 14 @using Dynamicweb.Ecommerce.Variants 15 @using Dynamicweb.Rendering 16 @using OttoSchachner.CustomCode.Helpers 17 @using Dynamicweb.Ecommerce.DynamicwebLiveIntegration.Products 18 19 @{ 20 var isCsv = string.Equals(Dynamicweb.Context.Current.Request.QueryString["download"], "csv", StringComparison.OrdinalIgnoreCase); 21 if (isCsv) 22 { 23 var fileVirtual = OttoSchachner.CustomCode.Helpers.ProductCsvExport.CreateTempCsvFile( 24 Model.Id, 25 Model.VariantId, 26 Model.LanguageId, 27 Model, 28 Pageview.User 29 ); 30 31 Dynamicweb.Context.Current.Response.Redirect(fileVirtual); 32 return; 33 } 34 35 var isZip = string.Equals(Dynamicweb.Context.Current.Request.QueryString["download"], "imageszip", StringComparison.OrdinalIgnoreCase); 36 if (isZip) 37 { 38 var zipVirtual = OttoSchachner.CustomCode.Helpers.ProductImagesZipExport.CreateTempImagesZipFile( 39 Model.Id, 40 Model.VariantId, 41 Model.LanguageId, 42 Model 43 ); 44 45 Dynamicweb.Context.Current.Response.Redirect(zipVirtual); 46 return; 47 } 48 49 ProductService productService = new ProductService(); 50 ProductQuantityPrices matrixProvider = new ProductQuantityPrices(); 51 var productPriceMatrix = matrixProvider.GetProductQuantityPrices(productService.GetProductById(Model.Id, Model.VariantId, Model.LanguageId)); 52 var uniquePricesMatrix = productPriceMatrix 53 .GroupBy(p => new { p.Quantity, Unit = Model.ProductFields["VjmSalesUnit"].Value, Amount = Dynamicweb.Core.Converter.ToDouble(p.Amount) }) 54 .Select(g => g.First()) 55 .ToList(); 56 } 57 58 @{ 59 string RenderPriceMatrix(List<ProductPrice> uniquePrices, bool isAssortmentGroup, bool alwaysNetPrice) 60 { 61 <div class="pview__matrix mb-4 @(isAssortmentGroup || alwaysNetPrice ? "d-block" : "")"> 62 @if (uniquePrices.Count != 0) 63 { 64 <div class="d-flex flex-row justify-content-between mb-2"> 65 <div class="fw-bold">@Translate("price-matrix-amount", "Antal")</div> 66 <div class="fw-bold">@Translate("price-matrix-price", "Pris")</div> 67 </div> 68 69 70 bool notLast = true; 71 int index = 0; 72 73 74 foreach (var price in uniquePrices) 75 { 76 <div class="d-flex flex-row justify-content-between"> 77 <div>@price.Quantity @price.UnitId</div> 78 <div>@Dynamicweb.Core.Converter.ToDouble(price.Amount).ToString("F2")</div> 79 </div> 80 81 if (index < uniquePrices.Count - 1) 82 { 83 <hr></hr> 84 } 85 86 index++; 87 } 88 } 89 else 90 { 91 <div class="fw-bold"> 92 @Translate("price-matrix-no-prices", "Ingen mængdepriser fundet") 93 </div> 94 } 95 </div> 96 97 return ""; 98 } 99 100 string RenderSections() 101 { 102 <div class="mb-4"> 103 <!-- Specifikationer - skjult for nu --> 104 105 @* <div class="pview__section"> *@ 106 @* <a href="javascript:void(0)" data-id="specifikationer" class="pview__section__name-container d-flex align-items-center justify-content-between"> *@ 107 @* *@ 108 @* <div class="d-flex flex-row"> *@ 109 @* <i class="pview__section__name-container__icon fa-solid fa-gears"></i> *@ 110 @* *@ 111 @* <div class="pview__section__name-container__name"> *@ 112 @* @Translate("product-specifications", "Specifikationer") *@ 113 @* </div> *@ 114 @* </div> *@ 115 @* <i class="bi-chevron-down"></i> *@ 116 @* <i class="bi-chevron-up d-none"></i> *@ 117 @* </a> *@ 118 @* *@ 119 @* <div data-id="specifikationer" class="pview__section__content"> *@ 120 @* Indhold *@ 121 @* </div> *@ 122 @* *@ 123 @* </div> *@ 124 125 @{ 126 var download = Dynamicweb.Core.Converter.ToString(Model.ProductFields.Where(x => x.Key == "VjmDocumentLibraryHtml").FirstOrDefault().Value.Value); 127 bool hasDocDownloads = !string.IsNullOrEmpty(download); 128 129 var current = Dynamicweb.Context.Current.Request.RawUrl ?? ""; 130 var csvUrl = current + (current.Contains("?") ? "&" : "?") + "download=csv"; 131 var zipUrl = (Dynamicweb.Context.Current.Request.RawUrl ?? "/") + 132 ((Dynamicweb.Context.Current.Request.RawUrl ?? "/").Contains("?") ? "&" : "?") + 133 "download=imageszip"; 134 } 135 136 <div class="pview__section"> 137 <a href="javascript:void(0)" data-id="Downloads" 138 class="pview__section__name-container d-flex align-items-center justify-content-between"> 139 <div class="d-flex flex-row"> 140 <i class="pview__section__name-container__icon fa-solid fa-file-pdf"></i> 141 <div class="pview__section__name-container__name"> 142 @(Translate("product-downloads", "Downloads")) 143 </div> 144 </div> 145 <i class="bi-chevron-down"></i> 146 <i class="bi-chevron-up d-none"></i> 147 </a> 148 149 <div data-id="Downloads" class="pview__section__content"> 150 <div class="d-flex flex-column"> 151 <a class="os-button os-button--red mb-2" href="@csvUrl"> 152 @Translate("download-csv", "Download CSV") 153 </a> 154 155 <a class="os-button os-button--red mb-2" href="@zipUrl"> 156 @Translate("download-images-zip", "Download billeder ZIP") 157 </a> 158 159 @if (hasDocDownloads) 160 { 161 @download 162 } 163 </div> 164 </div> 165 </div> 166 </div> 167 168 return ""; 169 } 170 171 bool signedIn = PageView.Current().User != null; 172 bool purchasable = false; 173 bool alwaysNetPrice = false; 174 175 if (signedIn) 176 { 177 var alwaysNetPriceField = Pageview.User.CustomFieldValues.FirstOrDefault(x => x.CustomField.SystemName == "AccessUser_AlwaysNettopPrices"); 178 if (alwaysNetPriceField != null && alwaysNetPriceField.Value != null) 179 { 180 alwaysNetPrice = Dynamicweb.Core.Converter.ToBoolean(alwaysNetPriceField.Value); 181 } 182 183 if (Model.VariantCombinations().Count > 1 && string.IsNullOrEmpty(Model.VariantId)) 184 { 185 purchasable = false; 186 } 187 else 188 { 189 purchasable = true; 190 } 191 } 192 193 List<BreadcrumbItem> items = new List<BreadcrumbItem>(); 194 bool isMobile = PageView.Current().Device == DeviceType.Mobile; 195 196 var primaryGroup = Model.PrimaryOrDefaultGroup; 197 var categoryName = primaryGroup?.Name ?? ""; 198 var categoryId = primaryGroup?.Id ?? ""; 199 200 var groupService = new GroupService(); 201 var shop = new ShopService().GetShop("SHOP1"); 202 var groups = groupService.FindPath(shop, groupService.GetGroup(primaryGroup.Id)); 203 var shopPageId = GetPageIdByNavigationTag("Shop"); 204 var product = productService.GetProductById(Model.Id, Model.VariantId, Model.LanguageId); 205 var productImageService = new ProductImageService(); 206 var images = productImageService.GetImagesFromPatterns(product, shop).ToList(); 207 bool variantSelected = !string.IsNullOrEmpty(Model.VariantId); 208 var pageService = new PageService(); 209 210 if (variantSelected) 211 { 212 images.Clear(); 213 images.Add(Model.DefaultImage.Value); 214 } 215 216 foreach (var group in groups) 217 { 218 items.Add(new BreadcrumbItem 219 { 220 Title = group.Name, 221 Url = "/Default.aspx?ID=" + shopPageId + "&groupid=" + group.Id 222 }); 223 } 224 225 var parameters = new Dictionary<string, object>(); 226 parameters.Add("items", items); 227 228 var _navigationSettings = new Dynamicweb.Frontend.Navigation.NavigationSettings() 229 { 230 Parameters = parameters 231 }; 232 233 var _navigationTemplate = "../Partials/Breadcrumb.cshtml"; 234 235 var alternativeImageObject = Model.ProductFields.Where(x => x.Key == "VjmpAlternativeManufacturerBrandLogo").FirstOrDefault(); 236 var alternativeImage = Dynamicweb.Core.Converter.ToString(alternativeImageObject.Value.Value); 237 238 bool isAssortmentGroup = Model.GroupPaths?.Any(groupList => 239 groupList.Any(group => group.Name == "Logovare")) == true; 240 } 241 242 <div class="pview os-container "> 243 244 <div class="pview__top position-relative d-flex flex-row justify-content-between align-items-center"> 245 246 <div class="pview__top__breadcrumb"> 247 @Navigation.RenderNavigation(_navigationTemplate, _navigationSettings) 248 </div> 249 250 <img class="pview__top__brand" src="@alternativeImage"/> 251 </div> 252 253 <div class="d-flex flew-row flex-wrap"> 254 255 256 <div class="pview__row row z-0"> 257 258 <div class="col-12 col-lg-6"> 259 <div class="product-view-gallery-wrapper position-relative"> 260 <div class="swiper product-view-gallery"> 261 <div class="swiper-wrapper"> 262 263 @foreach (var image in images) 264 { 265 var imageSrc = ""; 266 if (!string.IsNullOrEmpty(image)) 267 { 268 Dynamicweb.VestjyskMarketing.Models.ResizeImageSettings imageSettings = new Dynamicweb.VestjyskMarketing.Models.ResizeImageSettings 269 { 270 Width = 1500, 271 Height = 1500, 272 Crop = "5", 273 Quality = 90, 274 Image = image 275 }; 276 277 imageSrc = Dynamicweb.VestjyskMarketing.Helpers.ImageHelper.ResizeImage(imageSettings); 278 } 279 else 280 { 281 imageSrc = "/Files/Images/missing_image.jpg"; 282 } 283 284 string altText = OttoSchachner.Api.AISeo.GetProductImageAlt(product.Id, Model.VariantId, Model.LanguageId, image).FirstOrDefault()?.Alt ?? string.Empty; 285 if (string.IsNullOrEmpty(altText)) 286 { 287 altText = Translate("product-image-alt", "Produkt billede ") + " " + images.IndexOf(image); 288 } 289 290 <div class="swiper-slide"> 291 <img alt="@altText" class="pview__image-container__image" src="@imageSrc"> 292 </div> 293 } 294 295 @if (images.Count() == 0) 296 { 297 <div class="swiper-slide"> 298 <img alt="Produkt billede 0" class="pview__image-container__image" 299 src="/Files/Images/missing_image.jpg"> 300 </div> 301 } 302 303 </div> 304 </div> 305 306 @{ 307 if (signedIn && purchasable) 308 { 309 string favoriteLink = "/Default.aspx?ID=" + pageService.GetPageByNavigationTag(PageView.Current().AreaID, "FavoriteService").ID + "&ProductID=" + Model.Id + "&ProductVariantId=" + Model.VariantId + "&UserID=" + PageView.Current().User.ID + "&ReloadPage=false"; 310 bool isInFavoriteList = false; 311 var favoriteLists = Pageview.User.GetFavoriteLists(); 312 int favoriteListContainingProductId = 0; 313 string command = "add"; 314 new FavoriteListService().ClearCache(); 315 316 foreach (var favoriteList in favoriteLists) 317 { 318 isInFavoriteList = Pageview.User.IsProductInFavoriteList(favoriteList.ListId, product.Id, Model.VariantId); 319 320 if (isInFavoriteList) 321 { 322 favoriteListContainingProductId = favoriteList.ListId; 323 command = "remove"; 324 break; 325 } 326 } 327 328 <a data-command="@command" data-in-this-list="@favoriteListContainingProductId" 329 data-url="@favoriteLink" href="javascript:void(0)" 330 title="@Translate("add-or-remove-favorites")" class="product-list__favorite z-2"> 331 332 @if (isInFavoriteList) 333 { 334 <i class="fa-sharp fa-solid fa-heart"></i> 335 } 336 else 337 { 338 <i class="fa-regular fa-heart"></i> 339 } 340 341 </a> 342 } 343 } 344 <div 345 class="product-view-gallery__navigation position-absolute top-50 translate-middle-y z-1 justify-content-between d-flex "> 346 <i class="os-chevron os-chevron--prev bi-chevron-left product-view-prev"></i> 347 <i class="os-chevron bi-chevron-right product-view-next"></i> 348 </div> 349 </div> 350 351 <div class="pview__thumbnails product-view-thumbs row g-3 mt-2 "> 352 @if (images.Count > 1) 353 { 354 var imagesArray = images.ToArray(); 355 356 for (int i = 0; 357 i < images.Count(); 358 i++) 359 { 360 Dynamicweb.VestjyskMarketing.Models.ResizeImageSettings imageSettings = new Dynamicweb.VestjyskMarketing.Models.ResizeImageSettings 361 { 362 Width = 750, 363 Height = 750, 364 Crop = "5", 365 Quality = 90, 366 Image = imagesArray[i] 367 }; 368 369 var imageSrc = Dynamicweb.VestjyskMarketing.Helpers.ImageHelper.ResizeImage(imageSettings); 370 371 int number = i + 1; 372 373 string altText = OttoSchachner.Api.AISeo.GetProductImageAlt(product.Id, Model.VariantId, Model.LanguageId, imagesArray[i]).FirstOrDefault()?.Alt ?? string.Empty; 374 if (string.IsNullOrEmpty(altText)) 375 { 376 altText = Translate("product-image-alt", "Produkt billede ") + " " + i; 377 } 378 379 <a title="@Translate("go-to-image", "Gå til billede ") @number" data-slide="@i" 380 class="pview__thumbnails__item col-2 "> 381 <img alt="@altText" loading="lazy" src="@imageSrc"/> 382 </a> 383 } 384 } 385 386 </div> 387 388 @if (signedIn && isMobile == false) 389 { 390 @RenderSections() 391 } 392 393 </div> 394 <div class="col-12 col-lg-6"> 395 <h1 class="pview__name"> 396 @Model.Name 397 </h1> 398 <div class="pview__productid "> 399 @Translate("product-number", "Varenr: ") @Model.Number 400 </div> 401 402 403 @if (purchasable && !isAssortmentGroup) 404 { 405 <div class="pview__price d-flex flex-row align-items-center"> 406 <div class="pview__price__text me-3"> 407 <span class="pview__price__text"> 408 @Translate("recommended-price", "Vejl. pris") 409 </span> 410 </div> 411 <span class="pview__price__amount">@product.DefaultPrice.ToString("F2") KR. <span 412 class="pview__price__amount__netto @(alwaysNetPrice ? "" : "d-none")">(@Translate("net-price", "netto") @Model.Price.PriceWithoutVatFormatted )</span></span> 413 414 </div> 415 416 <div class="pview__price-toggler d-flex flex-row mb-3"> 417 418 419 <div 420 class="pview__price-toggler__container @(alwaysNetPrice ? "d-none" : "d-flex") flex-row align-items-center"> 421 <input class="me-3" type="checkbox" id="pview__netprice" name="horns" 422 @(alwaysNetPrice ? "checked" : "")/> 423 <label for="pview__netprice"> 424 @Translate("show-net-price", "Vis nettopris") 425 </label> 426 </div> 427 428 429 </div> 430 } 431 else if (signedIn == false) 432 { 433 <div class="pview__signin-message "> 434 @Translate("sign-in-to-see-prices", "LOG IND FOR AT SE PRISER OG KØBE PRODUKTET") 435 </div> 436 } 437 438 @if (purchasable) 439 { 440 @RenderPriceMatrix(uniquePricesMatrix, isAssortmentGroup, alwaysNetPrice) 441 } 442 443 <div class="pview__description"> 444 @Model.ShortDescription 445 @Model.LongDescription 446 </div> 447 448 @{ 449 string pictogramHtml = Model.ProductFields["VjmPictogramHtml"]?.Value.ToString(); 450 if (!string.IsNullOrEmpty(pictogramHtml)) 451 { 452 <div class="pictogram__section d-flex"> 453 <div class="d-flex "> 454 @pictogramHtml 455 </div> 456 </div> 457 } 458 } 459 460 @if (Model.VariantCombinations().Count > 1 && string.IsNullOrEmpty(Model.VariantId) && signedIn) 461 { 462 <div class="pview__variant-selector__message mb-3 fw-bold"> 463 @Translate("select-variant-message", "Du skal vælge variant før du kan tilføje til kurv") 464 </div> 465 } 466 @{ 467 string variantGroupName = ""; 468 bool colorGroup = Model.VariantInfo.VariantInfoGroupName == "Farver"; 469 470 @if (Model.VariantGroups().Count > 0) 471 { 472 if (Model.VariantGroups().Count == 1) 473 { 474 variantGroupName = Model.VariantGroups().First().Name.Replace(" ", ""); 475 variantGroupName = Translate("VariantGroup.Name." + variantGroupName, variantGroupName); 476 477 <div class="pview__cart__variant mb-3"> 478 <span class="fw-bold">@variantGroupName@(colorGroup ? ": " : "")</span> 479 @if (colorGroup) 480 { 481 <span>@Model.VariantName</span> 482 } 483 </div> 484 } 485 } 486 } 487 488 @if (signedIn && isMobile) 489 { 490 @RenderSections() 491 } 492 493 @{ 494 var step = Model.PurchaseQuantityStep; 495 if (step == null || step == 0) 496 { 497 step = 1; 498 } 499 500 if (isAssortmentGroup && uniquePricesMatrix.Count > 0) 501 { 502 step = uniquePricesMatrix?.FirstOrDefault()?.Quantity; 503 } 504 505 string stockLevel = Convert.ToString(product != null ? product.ProductFieldValues["VjmStockLevel"]?.Value : Model.ProductFields["VjmStockLevel"]?.Value); 506 string stockLevelText = ""; 507 508 if (!string.IsNullOrEmpty(stockLevel)) 509 { 510 stockLevel = stockLevel.ToLower(); 511 stockLevelText = StockLevelText(stockLevel); 512 } 513 514 515 <div class="pview__cart"> 516 <div class="pview__variant-selector row g-2 mb-2 mb-lg-4 d-flex flex-row flex-wrap"> 517 518 @if (Model.VariantGroups().Count == 1) 519 { 520 @foreach (var variantGroup in Model.VariantGroups()) 521 { 522 foreach (var option in variantGroup.Options) 523 { 524 string variantUrl = "/Default.aspx?ID=" + Pageview.ID + "&groupid=" + primaryGroup.Id + "&productid=" + Model.Id + "&variantid=" + option.Id; 525 var variantProduct = productService.GetProductById(Model.Id, option.Id, Model.LanguageId); 526 527 @if (Model.VariantInfo.VariantInfoGroupName == "Farver") 528 { 529 var variantImagePath = productImageService.GetImagePath(variantProduct); 530 531 Dynamicweb.VestjyskMarketing.Models.ResizeImageSettings imageSettings = new Dynamicweb.VestjyskMarketing.Models.ResizeImageSettings 532 { 533 Width = 1500, 534 Height = 1500, 535 Crop = "5", 536 Quality = 90, 537 Image = variantImagePath 538 }; 539 540 string imageSrc = Dynamicweb.VestjyskMarketing.Helpers.ImageHelper.ResizeImage(imageSettings); 541 542 <div class="w-auto"> 543 <div class="pview__variant-selector__item"> 544 <a href="@variantUrl" 545 title="@Translate("go-to", "Gå til") @variantGroupName.ToLower() @option.Name.ToLower()"> 546 <img class="w-100" alt="Variant @option.Name" src="@imageSrc"/> 547 </a> 548 </div> 549 </div> 550 } 551 else 552 { 553 <div class="w-auto"> 554 <div 555 class="pview__variant-selector__item number-selector @(Model.VariantId == option.Id ? "active" : "")"> 556 <a href="@variantUrl" 557 title="@Translate("go-to", "Gå til") @variantGroupName.ToLower() @option.Name.ToLower()" 558 class="d-flex h-100 w-100 align-items-center justify-content-center text-decoration-none"> 559 @option.Name 560 </a> 561 </div> 562 </div> 563 } 564 } 565 } 566 } 567 //multi variant håndtering 568 else 569 { 570 <div hidden="" id="variant-combinations"> 571 @string.Join(",", Model.VariantCombinations()) 572 </div> 573 @foreach (var variantGroup in Model.VariantGroups()) 574 { 575 string variantGroupNameMulti = Translate("VariantGroup.Name." + variantGroup.Name, variantGroup.Name); 576 <div class="pview__cart__variant fw-bold"> 577 @variantGroupNameMulti 578 </div> 579 <div class="d-flex mb-1 flex-wrap"> 580 @{ 581 foreach (var option in variantGroup.Options) 582 { 583 string variantUrl = "/Default.aspx?ID=" + Pageview.ID + "&groupid=" + primaryGroup.Id + "&productid=" + Model.Id + "&variantid=" + option.Id; 584 bool active = Model.VariantId.Contains(option.Id); 585 586 <div class="me-2 mb-2"> 587 <a data-group="@variantGroup.Name" data-id="@option.Id" 588 data-url="@variantUrl" href="javascript:void(0)" 589 title="@Translate("select", "vælg") @option.Name" 590 class="os-button os-button--no-hover @(active ? "" : "active os-button--transparent") d-flex h-100 w-100 align-items-center justify-content-center text-decoration-none"> 591 @option.Name 592 </a> 593 </div> 594 } 595 } 596 </div> 597 } 598 } 599 </div> 600 601 @if (purchasable) 602 { 603 <form method="post" class="h-100" id="pview-add-to-cart-form"> 604 <div class="pview__cart__container d-flex align-items-stretch mb-3"> 605 <div class="col-4"> 606 <input name="Quantity" type="number" min="@step" step="@step" value="@step" 607 class="pview__cart__container__quantity col-4"/> 608 </div> 609 <div class="col-8"> 610 611 <input type="hidden" name="ProductId" value='@Model.Id'/> 612 <input type="hidden" name="VariantId" value="@Model.VariantId"/> 613 <button class="pview__cart__container__button" type="submit" name="CartCmd" 614 value="add">Tilføj til kurv 615 </button> 616 617 </div> 618 </div> 619 </form> 620 <div class="d-flex flex-row align-items-center"> 621 <div class="col-4 d-flex flex-row justify-content-between align-items-center"> 622 <div class="pview__cart__min ">Min. antal: @step</div> 623 <div class="pview__cart__status-color pview__cart__status-color--@stockLevel"> 624 </div> 625 </div> 626 <div class="pview__cart__message d-flex align-items-center"> 627 @stockLevelText 628 </div> 629 </div> 630 } 631 </div>} 632 633 @if (signedIn == false) 634 { 635 @RenderSections() 636 } 637 </div> 638 </div> 639 </div> 640 </div> 641 642 @functions{ 643 644 string StockLevelText(string stockLevel) 645 { 646 string result = ""; 647 648 if (!string.IsNullOrEmpty(stockLevel)) 649 { 650 stockLevel = stockLevel.ToLower(); 651 652 switch (stockLevel) 653 { 654 case "green": 655 result = Translate("in-stock", "På lager"); 656 break; 657 case "yellow": 658 result = Translate("low-stock", "På vej hjem"); 659 break; 660 case "red": 661 result = Translate("out-of-stock", "Ikke på lager"); 662 break; 663 default: 664 result = Translate("out-of-stock", "Ikke på lager"); 665 break; 666 } 667 } 668 669 return result; 670 } 671 672 } 673 674 @if (Model.VariantCombinations().Count > 0 && !isAssortmentGroup) 675 { 676 var quickOrderVariants = product.GetVariantCombinations().Where(x => x.GetProduct(Model.LanguageId) != null && x.GetProduct(Model.LanguageId).Active).ToList(); 677 quickOrderVariants = quickOrderVariants.OrderBy(x => x.GetProduct(Model.LanguageId).Number).ToList(); 678 int count = 0; 679 <div class="pview__qorder"> 680 <div class="os-container"> 681 <div class="d-flex flex-column flex-lg-row justify-content-between flex-wrap mb-3 mb-lg-5"> 682 <div class="pview__qorder__header col-12 col-lg-auto mb-3 mb-lg-0"> 683 @Translate("quick-order", "Hurtig bestilling") 684 </div> 685 686 <div class="pview__qorder__input-container d-flex flex-row align-items-center col-12 col-lg-5"> 687 <i class="bi-search me-2"></i> 688 <input class="pview__qorder__input-container__input col-5" 689 placeholder='@Translate("quick-order-search", "Søg efter varenr., DB nr., materiale, størrelse m.m.")'/> 690 </div> 691 </div> 692 <form id="pview-qorder-form" method="post" action=""> 693 694 695 <input type="hidden" name="cartcmd" value="addmulti"/> 696 <input type="hidden" name="redirect" value="false"/> 697 698 <div class="product-table"> 699 <div 700 class="row header @(signedIn ? "signed-in" : "") @(Model.VariantGroups().Count > 1 ? "multi" : "")"> 701 <div>@Translate("order-variant-number", "Varenr.")</div> 702 703 @{ 704 List<string> variantGroupNames = new List<string>(); 705 } 706 707 @foreach (var variantGroup in Model.VariantGroups()) 708 { 709 string _variantGroupName = Translate("VariantGroup.Name." + variantGroup.Name, variantGroup.Name); 710 variantGroupNames.Add(_variantGroupName); 711 <div>@_variantGroupName</div> 712 } 713 714 715 <div>@Translate("db-number", "DB-nummer")</div> 716 <div>@Translate("ean-upc", "EAN/UPC")</div> 717 <div>@Translate("special-order-item", "Skaffevare")</div> 718 <div>@Translate("order-quantity", "Ordrekvantum")</div> 719 <div>@Translate("packaging", "Forpakning")</div> 720 @if (signedIn) 721 { 722 <div>@Translate("stock-status", "Lagerstatus")</div> 723 } 724 </div> 725 726 @{ 727 var matrixItems = new List<(Dynamicweb.Ecommerce.Products.Product Product, VariantCombination VariantComb, bool IsVariant)>(); 728 729 //hvis ingen varianter - hvis hovedproduktet i tabellen 730 if (quickOrderVariants.Count == 0) 731 { 732 matrixItems.Add((product, null, false)); 733 } 734 735 // Tilføj alle variants bagefter 736 foreach (var vc in quickOrderVariants) 737 { 738 matrixItems.Add((vc.GetProduct(Model.LanguageId), vc, true)); 739 } 740 } 741 742 <div class="row-wrapper"> 743 @foreach (var item in matrixItems) 744 { 745 count++; 746 747 748 var variant = item.Product; 749 var variantComb = item.VariantComb; 750 bool isVariant = item.IsVariant; 751 // DB-nummer (VjmDBNumber) 752 string dbNumber = 753 variant?.ProductFieldValues? 754 .GetProductFieldValue("VjmDBNumber")?.Value?.ToString() 755 ?? Translate("not-available", "N/A"); 756 757 // EAN 758 string EAN = !string.IsNullOrEmpty(variant?.EAN) 759 ? variant.EAN 760 : Translate("not-available", "N/A"); 761 762 string spStatus = variant?.ProductFieldValues.GetProductFieldValue("SpStatus")?.Value?.ToString().ToLower(); 763 764 if (spStatus == "skaffevare" || spStatus == "pris på forespørgsel") 765 { 766 spStatus = Translate("Yes", "Ja"); 767 } 768 else 769 { 770 spStatus = Translate("No", "Nej"); 771 } 772 773 string variantStockLevel = Convert.ToString(variant != null ? variant.ProductFieldValues["VjmStockLevel"]?.Value : "red"); 774 string variantStockLevelText = ""; 775 776 777 if (!string.IsNullOrEmpty(variantStockLevel)) 778 { 779 variantStockLevel = variantStockLevel.ToLower(); 780 variantStockLevelText = StockLevelText(variantStockLevel); 781 } 782 783 // Packaging (VjmUnitsConcat) 784 string packaging = 785 variant?.ProductFieldValues? 786 .GetProductFieldValue("VjmUnitsConcat")?.Value?.ToString() 787 ?? ""; 788 789 // Unit (VjmSalesUnit) 790 string unit = 791 variant?.ProductFieldValues? 792 .GetProductFieldValue("VjmSalesUnit")?.Value?.ToString() 793 ?? ""; 794 795 // Minimum order quantity 796 string minQty = variant?.PurchaseQuantityStep.ToString() ?? ""; 797 798 if (minQty == "0") 799 { 800 minQty = "1"; 801 unit = ""; 802 } 803 804 // Price 805 string bruttoPrice = $"{variant.DefaultPrice:0.00} KR"; 806 PriceContext priceContext = new PriceContext(Dynamicweb.Ecommerce.Common.Context.Currency, Dynamicweb.Ecommerce.Common.Context.Country, shop, Pageview.User, false, null); 807 string netPrice = $"{variant?.GetPrice(priceContext).PriceWithoutVATFormattedNoSymbol:00} KR"; 808 809 <div 810 class="row data @(count % 2 == 0 ? "visible-index-even" : "") @(signedIn ? "signed-in" : "") @(Model.VariantGroups().Count > 1 ? "multi" : "")" 811 data-id="@variant.Id" 812 data-name="@variant.Name" 813 data-variant="@(isVariant ? variantComb.VariantId : "")" 814 data-price="@variant.GetPrice(priceContext).PriceWithoutVAT.ToString("F2", System.Globalization.CultureInfo.InvariantCulture)"> 815 <input type="hidden" name="ProductLoopCounter@(count)" id="ProductLoopCounter@(count)" 816 value="@count"/> 817 <input type="hidden" name="ProductId@(count)" id="ProductId@(count)" 818 value="@variant.Id"/> 819 @if (isVariant) 820 { 821 <input type="hidden" name="VariantId@(count)" value="@variantComb.VariantId"/> 822 } 823 824 <!-- Varenr. --> 825 <div class="d-flex justify-content-between d-lg-block"> 826 <span class="d-block d-lg-none">@Translate("order-variant-number", "Varenr.")</span> 827 <span class="searchable">@variant.Number</span> 828 </div> 829 <hr/> 830 <!-- Variantnavne --> 831 @if (isVariant) 832 { 833 int index = 0; 834 835 foreach (var optionId in variantComb.GetVariantOptionIds()) 836 { 837 <div class="d-flex justify-content-between d-lg-block"> 838 <span class="d-block d-lg-none">@variantGroupNames[index]</span> 839 <span class="searchable"> 840 @Model.VariantGroups().Find(group => group.Options.Find(option => option.Id == optionId) != null).Options.Single(option2 => option2.Id == optionId).Name 841 </span> 842 </div> 843 <hr/> 844 index++; 845 } 846 } 847 848 <!-- DB nummer --> 849 <div class="d-flex justify-content-between d-lg-block"> 850 <span class="d-block d-lg-none">@Translate("db-number", "DB-nummer")</span> 851 <span class="searchable">@dbNumber</span> 852 </div> 853 854 <hr/> 855 <!-- EAN --> 856 <div class="d-flex justify-content-between d-lg-block"> 857 <span class="d-block d-lg-none">@Translate("ean-upc", "EAN/UPC")</span> 858 <span class="searchable">@EAN</span> 859 </div> 860 <hr/> 861 862 <!-- Skaffevare --> 863 <div class="d-flex justify-content-between d-lg-block"> 864 <span 865 class="d-block d-lg-none">@Translate("special-order-item", "Skaffevare")</span> 866 <span class="searchable">@spStatus</span> 867 </div> 868 869 <hr/> 870 <!-- Ordrekvantum --> 871 <div class="d-flex justify-content-between d-lg-block"> 872 <span class="d-block d-lg-none">@Translate("order-quantity", "Ordrekvantum")</span> 873 <span>@minQty @unit</span> 874 </div> 875 <hr/> 876 877 <!-- Forpakning --> 878 <div class="d-flex justify-content-between d-lg-block"> 879 <span class="d-block d-lg-none">@Translate("packaging", "Forpakning")</span> 880 <span>@packaging</span> 881 </div> 882 883 @if (signedIn) 884 { 885 <hr/> 886 <!-- Lagerstatus --> 887 <div class="d-flex justify-content-between d-lg-block align-items-center"> 888 <span class="d-block d-lg-none">@Translate("stock-status", "Lagerstatus")</span> 889 <div class="d-flex flex-row align-items-center p-0"> 890 <div 891 class="pview__cart__status-color pview__cart__status-color--@variantStockLevel"></div> 892 @variantStockLevelText 893 </div> 894 </div> 895 896 <hr/> 897 898 <!-- Pris --> 899 <div 900 class="d-flex justify-content-between d-lg-block flex-row flex-lg-column align-items-center"> 901 <span class="d-block d-lg-none">@Translate("price", "Pris")</span> 902 <div class="d-flex flex-column"> 903 <span class="fw-bold">@bruttoPrice</span> 904 <span 905 class="quick-order-net @(alwaysNetPrice ? "" : "d-none")">(@netPrice)</span> 906 <small>@Translate("quick-order-min", "Bestilles i"): @minQty @unit</small> 907 </div> 908 909 </div> 910 <hr/> 911 912 <!-- Antal vælger --> 913 <div class="d-flex justify-content-between d-lg-block align-items-center"> 914 <span class="d-block d-lg-none">@Translate("quantity", "Antal")</span> 915 <div class="pview__qorder__actions d-flex flex-row"> 916 <a class="pview__qorder__actions__decrement" href="javascript:void(0)">-</a> 917 <input class="pview__qorder__actions__input" name="Quantity@(count)" 918 type="number" step="@minQty" min="0" value="0"> 919 <a class="pview__qorder__actions__incremenet" 920 href="javascript:void(0)">+</a> 921 </div> 922 </div> 923 } 924 </div> 925 } 926 927 </div> 928 </div> 929 930 931 <div class="pview__qorder__no-results justify-content-center mt-3" style="display: none"> 932 @Translate("quick-order-no-results", "Ingen resultater fundet") 933 </div> 934 935 @if (signedIn) 936 { 937 <div class="d-flex justify-content-end"> 938 <button type="submit" class="pview__qorder__add-button os-button os-button--red mt-4"> 939 @Translate("add-all-to-cart", "Læg alle i kurv") 940 </button> 941 </div> 942 } 943 </form> 944 945 </div> 946 </div> 947 } 948 949 @{ 950 var productListParameters = new Dictionary<string, object>(); 951 productListParameters.Add("itemsToShow", 4); 952 productListParameters.Add("maxItems", 99); 953 954 List<dynamic> productsRelated = new List<dynamic>(); 955 foreach (var relatedGroup in Model.RelatedGroups) 956 { 957 if (relatedGroup.Id == "TILBEHØR") 958 { 959 foreach (var relatedProduct in relatedGroup.Products) 960 { 961 productsRelated.Add(ProductInfoViewModelExtensions.GetProduct(relatedProduct)); 962 } 963 } 964 } 965 966 bool slider = productsRelated.Count > 4; 967 productListParameters.Add("slider", slider); 968 productListParameters.Add("products", productsRelated); 969 } 970 971 @if (productsRelated.Count > 0) 972 { 973 <div class="os-container pview__related"> 974 <div class="pview__related__header mb-4"> 975 @Translate("product-add-ons", "Tilbehør") 976 </div> 977 <div class="@(slider ? "" : "row g-3") "> 978 @RenderPartial("/Designs/OttoSchachner/Partials/ProductList.cshtml", new ParagraphViewModel(), productListParameters) 979 </div> 980 </div> 981 } 982 983 @if (signedIn == false) 984 { 985 <div class="os-container pview__signup"> 986 @{ 987 var signupParagraphPageId = GetPageIdByNavigationTag("NotSignedInProductViewParagraph"); 988 @(new Content(Pageview).RenderExternalGrid(signupParagraphPageId, "")) 989 } 990 </div> 991 } 992 993 @if (purchasable && signedIn) 994 { 995 <script> 996 window.dataLayer = window.dataLayer || []; 997 (function () { 998 function pushAddToCart(items, currency) { 999 if (items.length > 0) { 1000 dataLayer.push({ ecommerce: null }); 1001 dataLayer.push({ 1002 event: "add_to_cart", 1003 ecommerce: { 1004 currency: currency, 1005 items: items 1006 } 1007 }); 1008 } 1009 } 1010 1011 const quickOrderForm = document.getElementById('pview-qorder-form'); 1012 if (quickOrderForm) { 1013 quickOrderForm.addEventListener('submit', function () { 1014 const items = []; 1015 const rows = quickOrderForm.querySelectorAll('.row.data'); 1016 rows.forEach(function (row) { 1017 const quantityInput = row.querySelector('.pview__qorder__actions__input'); 1018 const quantity = quantityInput ? parseInt(quantityInput.value || '0', 10) : 0; 1019 1020 if (quantity > 0) { 1021 items.push({ 1022 item_id: row.dataset.id, 1023 item_name: row.dataset.name, 1024 affiliation: "Online Store", 1025 variant: row.dataset.variant, 1026 price: parseFloat(row.dataset.price), 1027 quantity: quantity 1028 }); 1029 } 1030 }); 1031 1032 pushAddToCart(items, "@Model.Price.CurrencyCode"); 1033 }); 1034 } 1035 1036 const form = document.getElementById('pview-add-to-cart-form'); 1037 if(form){ 1038 form.addEventListener('submit', function () { 1039 const quantityInput = form.querySelector('input[name="Quantity"]'); 1040 const quantity = quantityInput ? parseInt(quantityInput.value || '1', 10) : 1; 1041 1042 const items = [ 1043 { 1044 item_id: "@Model.Id", 1045 item_name: "@Model.Name", 1046 affiliation: "Online Store", 1047 variant: "@Model.VariantId", 1048 price: @Model.Price?.PriceWithoutVat.ToString("F2", System.Globalization.CultureInfo.InvariantCulture), 1049 quantity: quantity 1050 } 1051 ]; 1052 1053 pushAddToCart(items, "@Model.Price.CurrencyCode"); 1054 }); 1055 } 1056 })(); 1057 1058 dataLayer.push({ ecommerce: null }); 1059 dataLayer.push({ 1060 event: 'view_item', 1061 ecommerce: { 1062 item_name: "@Model.Name", 1063 item_id: "@Model.Id", 1064 price: @Model.Price?.PriceWithoutVat.ToString("F2", System.Globalization.CultureInfo.InvariantCulture), 1065 item_brand: "@Model.Manufacturer?.Name", 1066 item_category: "@categoryName", 1067 item_list_name: "@categoryName", 1068 item_list_id: "@categoryId", 1069 quantity: 1 1070 } 1071 }); 1072 </script> 1073 } 1074