Error compiling template "Designs/Swift-v2/Paragraph/Elka_CustomProductDetails.cshtml"
Line 57: The name 'ProductOrderabilityService' does not exist in the current context
Line 145: The annotation for nullable reference types should only be used in code within a '#nullable' annotations context. Auto-generated code requires an explicit '#nullable' directive in source.
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.Security.UserManagement;
12 using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites;
13 using ProductViewModel = Website.ViewModels.Ecommerce.ProductViewModel;
14 using Website.Services.Product;
15 internal class RazorEngine_2b01addda9b548fdb18260e680ca4e01 : Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
16 {
17 #pragma warning disable 1998
18 public async override global::System.Threading.Tasks.Task ExecuteAsync()
19 {
20 WriteLiteral("\r\n");
21 WriteLiteral("\r\n");
22
23 ProductViewModel product = null;
24 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
25 {
26 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
27 }
28 else if (!string.IsNullOrEmpty(Pageview.Page.Item["DummyProduct"]?.ToString()) && Pageview.IsVisualEditorMode)
29 {
30 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page);
31 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel();
32
33 if (productList?.Products is object)
34 {
35 product = (ProductViewModel)productList.Products[0];
36 }
37
38 if (string.IsNullOrEmpty(product.Number) && Pageview.IsVisualEditorMode)
39 {
40 product.Number = "394041";
41 }
42 }
43 else if (Pageview.IsVisualEditorMode)
44 {
45 product = new ProductViewModel();
46 product.Number = "394041";
47 }
48 WriteLiteral("\r\n");
49 if (product is object)
50 {
51 string productId = product.Id;
52 string productName = product.Name;
53 string productNumber = product.ArtNumber;
54 string productVariantName = product.VariantName ?? string.Empty;
55 string productVariantId = !string.IsNullOrEmpty(product.VariantId) ? product.VariantId : product.DefaultVariantId;
56
57 bool canBeOrdered = ProductOrderabilityService.Current.CanBeOrdered(product);
58 bool productShowPrice = product.ShowPrice && canBeOrdered;
59
60 string productPriceCurrencyCode = canBeOrdered ? product.Price.CurrencyCode : string.Empty;
61 string productPrice = canBeOrdered ? product.Price.ToStringInvariant() : string.Empty;
62 string productDiscount = product.Discount.ToStringInvariant();
63 string productSeriesHex = product.SeriesHex;
64 string brandLogo = product.BrandLogo;
65
66
67 string iconPath = "/Files/Images/Icons/";
68
69 string outletLabelColor = string.IsNullOrEmpty(product.OutletLabelColor) ? "primary" : product.OutletLabelColor;
70 string labelCustom1Color = string.IsNullOrEmpty(product.LabelCustom1Color) ? "primary" : product.LabelCustom1Color;
71 string labelCustom2Color = string.IsNullOrEmpty(product.LabelCustom2Color) ? "primary" : product.LabelCustom2Color;
72 bool isUserAuthenticated = UserContext.Current.IsLoggedOn;
73
74 WriteLiteral(" <div class=\"d-flex flex-row align-items-start mb-2 gap-1\">\r\n");
75 if (isUserAuthenticated)
76 {
77 if (product.Outlet)
78 {
79 WriteLiteral(" <span class=\"badge\" data-dw-colorscheme=\"");
80 Write(outletLabelColor);
81 WriteLiteral("\">");
82 Write(Translate("Outlet", "Outlet"));
83 WriteLiteral("</span>\r\n");
84 }
85 }
86 if (!string.IsNullOrEmpty(product.LabelCustom1))
87 {
88 WriteLiteral(" <span class=\"badge\" data-dw-colorscheme=\"");
89 Write(labelCustom1Color);
90 WriteLiteral("\">");
91 Write(product.LabelCustom1);
92 WriteLiteral("</span>\r\n");
93 }
94 if (!string.IsNullOrEmpty(product.LabelCustom2))
95 {
96 WriteLiteral(" <span class=\"badge\" data-dw-colorscheme=\"");
97 Write(labelCustom2Color);
98 WriteLiteral("\">");
99 Write(product.LabelCustom2);
100 WriteLiteral("</span>\r\n");
101 }
102 WriteLiteral(" </div>\r\n");
103
104 if (!string.IsNullOrEmpty(productNumber))
105 {
106 WriteLiteral(" <div class=\"mb-1 text-muted text-uppercase fw-bold small\">\r\n ");
107 Write(Translate("Number"));
108 WriteLiteral(" <span itemprop=\"sku\">");
109 Write(productNumber);
110 WriteLiteral("</span>\r\n </div>\r\n");
111 }
112
113 if (!string.IsNullOrEmpty(productName))
114 {
115 WriteLiteral(" <h1 class=\"mb-2 fs-1\" itemprop=\"name\">");
116 Write(productName);
117 WriteLiteral("</h1>\r\n");
118 }
119
120 if (!string.IsNullOrEmpty(product.ShortDescription))
121 {
122 WriteLiteral(" <div class=\"mt-3\">\r\n ");
123 Write(product.ShortDescription);
124 WriteLiteral("\r\n </div>\r\n");
125 }
126
127 if (productShowPrice && isUserAuthenticated)
128 {
129 WriteLiteral(" <div class=\"h2 mt-4 mb-0\">\r\n ");
130 Write(product.RenderedHtml.Price);
131 WriteLiteral("\r\n </div>\r\n");
132 }
133
134 if (!string.IsNullOrEmpty(product.SizeText))
135 {
136 WriteLiteral(" <span class=\"h6 mt-4 mb-0 lh-1\">\r\n <b>");
137 Write(Translate("Sizes", "Sizes"));
138 WriteLiteral(":</b> ");
139 Write(product.SizeText);
140 WriteLiteral("\r\n </span>\r\n");
141 }
142
143 if (product.ColorOptions != null)
144 {
145 ProductService? productService = ProductService.Instance;
146 string baseUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl($"Default.aspx?ID={GetPageIdByNavigationTag("Shop")}&GroupID={product.PrimaryOrDefaultGroup.Id}&ProductID={product.Id}") + "?";
147 string variantUrl = string.Empty;
148 if (!string.IsNullOrEmpty(product.VariantId))
149 {
150 variantUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl($"Default.aspx?ID={GetPageIdByNavigationTag("Shop")}&GroupID={product.PrimaryOrDefaultGroup.Id}&ProductID={product.Id}&VariantID={product.VariantId}");
151 }
152
153 string[] variantId = productVariantId.Split('.');
154 string variantColorId = variantId.Length > 0 ? variantId[0] : string.Empty;
155 string variantSizeId = variantId.Length > 1 ? variantId[1] : string.Empty;
156
157 string selectedColorName = product.ColorOptions.FirstOrDefault(v => v.Id.Equals(variantColorId))?.Name ?? string.Empty;
158
159 WriteLiteral(" <span class=\"h6 mt-4 mb-2 lh-1\">\r\n <b>");
160 Write(Translate("Colors", "Colors"));
161 WriteLiteral(":</b> ");
162 Write(selectedColorName);
163 WriteLiteral("\r\n </span>\r\n <form class=\"d-flex gap-2 js-variant-selector\" data-combinations=\"");
164 Write(string.Join(",", product.VariantCombinations()));
165 WriteLiteral("\" data-base-url=\"");
166 Write(baseUrl);
167 WriteLiteral("\" data-friendly-url=\"");
168 Write(variantUrl);
169 WriteLiteral("\" data-dw-colorscheme=\"none\">\r\n <div class=\"d-flex gap-2 start flex-wrap js-variant-group\" data-group-id=\"1\">\r\n");
170 foreach (VariantOptionViewModel color in product.ColorOptions)
171 {
172 string active = variantId != null && variantId.Contains(color.Id) ? "active" : string.Empty;
173
174 WriteLiteral(" <button data-dw-colorscheme=\"white\" type=\"button\"");
175 BeginWriteAttribute("class", " class=\"", 6142, "\"", 6267, 10);
176 WriteAttributeValue("", 6150, "border-0", 6150, 8, true);
177 WriteAttributeValue(" ", 6158, "overflow-hidden", 6159, 16, true);
178 WriteAttributeValue(" ", 6174, "colorbox", 6175, 9, true);
179 WriteAttributeValue(" ", 6183, "colorbox-auto", 6184, 14, true);
180 WriteAttributeValue(" ", 6197, "rounded-0", 6198, 10, true);
181 WriteAttributeValue(" ", 6207, "p-0", 6208, 4, true);
182 WriteAttributeValue(" ", 6211, "d-inline-block", 6212, 15, true);
183 WriteAttributeValue(" ", 6226, "variant-option", 6227, 15, true);
184 WriteAttributeValue(" ", 6241, "js-variant-option", 6242, 18, true);
185 WriteAttributeValue(" ", 6259, active, 6260, 7, false);
186 EndWriteAttribute();
187 WriteLiteral(" style=\"width:46px\" onclick=\"swift.VariantSelector.OptionClick(event)\" data-variant-id=\"");
188 Write(color.Id);
189 WriteLiteral("\"");
190 BeginWriteAttribute("id", " id=\"", 6368, "\"", 6427, 5);
191 WriteAttributeValue("", 6373, productId, 6373, 12, false);
192 WriteAttributeValue("", 6385, "_", 6385, 1, true);
193 WriteAttributeValue("", 6386, color.Id, 6386, 11, false);
194 WriteAttributeValue("", 6397, "_", 6397, 1, true);
195 WriteAttributeValue("", 6398, Pageview.CurrentParagraph.ID, 6398, 29, false);
196 EndWriteAttribute();
197 WriteLiteral(">\r\n <img");
198 BeginWriteAttribute("alt", " alt=\"", 6459, "\"", 6476, 1);
199 WriteAttributeValue("", 6465, color.Name, 6465, 11, false);
200 EndWriteAttribute();
201 WriteLiteral(" class=\"elka-variant-color-preview\" style=\"width: 46px; height: 46px;\"");
202 BeginWriteAttribute("src", " src=\"", 6547, "\"", 6663, 3);
203 WriteAttributeValue("", 6553, "/Admin/Public/GetImage.ashx?image=", 6553, 34, true);
204 WriteAttributeValue("", 6587, productService.GetVariantOptionColorImage(color.Id), 6587, 54, false);
205 WriteAttributeValue("", 6641, "&width=128&format=webp", 6641, 22, true);
206 EndWriteAttribute();
207 WriteLiteral(">\r\n </button>\r\n");
208 }
209 WriteLiteral(@" </div>
210 <div class=""d-flex gap-2 start flex-wrap js-variant-group d-none"" data-group-id=""2"">
211 <button type=""button"" class=""variant-option js-variant-option active"" style=""width:46px"" onclick=""swift.VariantSelector.OptionClick(event)"" data-variant-id=""");
212 Write(variantSizeId);
213 WriteLiteral("\"");
214 BeginWriteAttribute("id", " id=\"", 7025, "\"", 7089, 5);
215 WriteAttributeValue("", 7030, productId, 7030, 12, false);
216 WriteAttributeValue("", 7042, "_", 7042, 1, true);
217 WriteAttributeValue("", 7043, variantSizeId, 7043, 16, false);
218 WriteAttributeValue("", 7059, "_", 7059, 1, true);
219 WriteAttributeValue("", 7060, Pageview.CurrentParagraph.ID, 7060, 29, false);
220 EndWriteAttribute();
221 WriteLiteral(">\r\n </button>\r\n </div>\r\n </form>\r\n <script type=\"module\">\r\n swift.VariantSelector.init();\r\n </script>\r\n");
222 }
223
224 if (isUserAuthenticated)
225 {
226 string variantId = product.VariantId;
227 string productPriceCurrency = product.Price.CurrencyCode;
228
229 int defaultFavoriteListId = 0;
230 IEnumerable<FavoriteList> favoriteLists = new FavoriteList[] { };
231
232 if (Pageview?.User?.ID != null)
233 {
234 favoriteLists = Pageview.User.GetFavoriteLists();
235
236 if (favoriteLists.Count() == 1)
237 {
238 foreach (FavoriteList list in favoriteLists)
239 {
240 defaultFavoriteListId = list.ListId;
241 }
242 }
243 }
244
245 defaultFavoriteListId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("FavoriteListId")) ? Convert.ToInt32(Dynamicweb.Context.Current.Request.QueryString.Get("FavoriteListId")) : defaultFavoriteListId;
246 string favoriteToggleType = defaultFavoriteListId == 0 && favoriteLists.Count() > 1 ? "multiple-lists" : "single-list";
247 favoriteToggleType = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("FavoriteListId")) ? "remove-from-list" : favoriteToggleType;
248
249 bool isInFavoriteList = Pageview?.User?.ID != null ? Pageview.User.IsProductInAnyFavoriteList(productId, variantId) : false;
250 string pageId = GetPageIdByNavigationTag("FavoriteServicePage") != 0 ? GetPageIdByNavigationTag("FavoriteServicePage").ToString() : "";
251 pageId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("FavoriteListId")) ? Pageview.Page.ID.ToString() : pageId;
252
253 string url = "/Default.aspx?ID=" + pageId + "&ProductID=" + productId + "&VariantId=" + variantId + "&ProductVariantId=" + variantId + "&ShowButtonText=True";
254 url += favoriteToggleType == "single-list" || favoriteToggleType == "remove-from-list" ? "&FavoriteListId=" + defaultFavoriteListId : "";
255 url += favoriteToggleType == "remove-from-list" ? "&FavoriteCmd=removeproductfromfavoritelist" : "";
256
257 string filledFavoriteIcon = isInFavoriteList ? "" : "d-none";
258 string outlineFavoriteIcon = isInFavoriteList ? "d-none" : "";
259
260 string favoriteButtonId = $"FavoriteBtn_{productId}{variantId.Replace(".", "")}";
261
262 WriteLiteral(" <div class=\"mt-4\">\r\n");
263 if (canBeOrdered)
264 {
265 WriteLiteral(" <button class=\"btn btn-lg btn-secondary js-e-product-matrix-modal-open-button\" type=\"button\" data-bs-toggle=\"modal\" data-bs-target=\".js-e-product-matrix-modal\">\r\n ");
266 Write(Translate("eCom Product - Launch Product Matrix - Button", "Bestil vare"));
267 WriteLiteral("\r\n </button>\r\n");
268 }
269 WriteLiteral(" <button type=\"button\" class=\"pe-0 py-0 btn custom_favorites-button\"");
270 BeginWriteAttribute("id", " id=\"", 10047, "\"", 10069, 1);
271 WriteAttributeValue("", 10052, favoriteButtonId, 10052, 17, false);
272 EndWriteAttribute();
273 BeginWriteAttribute("onclick", " onclick=\"", 10070, "\"", 10140, 7);
274 WriteAttributeValue("", 10080, "swift.Favorites.Toggle(event,", 10080, 29, true);
275 WriteAttributeValue(" ", 10109, "\'", 10110, 2, true);
276 WriteAttributeValue("", 10111, url, 10111, 4, false);
277 WriteAttributeValue("", 10115, "\',", 10115, 2, true);
278 WriteAttributeValue(" ", 10117, "\'", 10118, 2, true);
279 WriteAttributeValue("", 10119, favoriteToggleType, 10119, 19, false);
280 WriteAttributeValue("", 10138, "\')", 10138, 2, true);
281 EndWriteAttribute();
282 WriteLiteral(" style=\"z-index: 1;\" data-product-id=\"");
283 Write(productId);
284 WriteLiteral("\" data-variant-id=\"");
285 Write(variantId);
286 WriteLiteral("\" data-product-name=\"");
287 Write(productName);
288 WriteLiteral("\" data-product-price=\"");
289 Write(productPrice);
290 WriteLiteral("\" data-product-currency=\"");
291 Write(productPriceCurrency);
292 WriteLiteral("\">\r\n <span class=\"favorite-icon\">\r\n <span");
293 BeginWriteAttribute("class", " class=\"", 10407, "\"", 10454, 3);
294 WriteAttributeValue("", 10415, "text-nowrap", 10415, 11, true);
295 WriteAttributeValue(" ", 10426, "in-list", 10427, 8, true);
296 WriteAttributeValue(" ", 10434, filledFavoriteIcon, 10435, 19, false);
297 EndWriteAttribute();
298 WriteLiteral(" title=\"In list\">\r\n <span class=\"icon-2\" aria-hidden=\"true\">");
299 Write(ReadFile(iconPath + "heart-filled.svg"));
300 WriteLiteral("</span>\r\n <span class=\"small ms-2\">");
301 Write(Translate("Remove from favorites"));
302 WriteLiteral("</span>\r\n </span>\r\n <span");
303 BeginWriteAttribute("class", " class=\"", 10734, "\"", 10786, 3);
304 WriteAttributeValue("", 10742, "text-nowrap", 10742, 11, true);
305 WriteAttributeValue(" ", 10753, "not-in-list", 10754, 12, true);
306 WriteAttributeValue(" ", 10765, outlineFavoriteIcon, 10766, 20, false);
307 EndWriteAttribute();
308 WriteLiteral(" title=\"Not in list\">\r\n <span class=\"icon-2\" aria-hidden=\"true\">");
309 Write(ReadFile(iconPath + "heart.svg"));
310 WriteLiteral("</span>\r\n <span class=\"small ms-2\">");
311 Write(Translate("Add to favorites"));
312 WriteLiteral("</span>\r\n </span>\r\n </span>\r\n </button>\r\n </div>\r\n");
313 Write(product.RenderedHtml.Matrix);
314
315 }
316
317 WriteLiteral(" <div class=\"row justify-content-between\">\r\n <div class=\"col-12 col-md-12 col-lg-6 mt-4\">\r\n <div class=\"dropdown js-elka-product\" data-product-id=\"");
318 Write(productId);
319 WriteLiteral("\" data-variant-id=\"");
320 Write(productVariantId);
321 WriteLiteral("\">\r\n <button aria-expanded=\"false\" class=\"btn btn-link dropdown-toggle border text-decoration-none\" data-bs-toggle=\"dropdown\" type=\"button\">\r\n <span class=\"icon-2\" aria-hidden=\"true\">");
322 Write(ReadFile(iconPath + "download.svg"));
323 WriteLiteral("</span>\r\n ");
324 Write(Translate( "Elka - Product Details - PDF Download - Text", "Download datablad" ));
325 WriteLiteral("\r\n </button>\r\n <div class=\"dropdown-menu p-0\">\r\n <a class=\"dropdown-item js-elka-download-product-pdf py-1 px-2 d-block\" href=\"#\">\r\n ");
326 Write(Translate( "Elka - Product Details - PDF Download without logo - Text", "Uden eget logo" ));
327 WriteLiteral("\r\n </a>\r\n <a class=\"dropdown-item p-0\" href=\"#\">\r\n <label class=\"m-0 py-1 px-2 pointer-cursor d-block\" for=\"elkaPdfUploadInput\">\r\n ");
328 Write(Translate( "Elka - Product Details - PDF Download logo - Text", "Med eget logo" ));
329 WriteLiteral("\r\n </label>\r\n <input class=\"d-none js-elka-upload-pdf-logo\" id=\"elkaPdfUploadInput\" type=\"file\">\r\n </a>\r\n </div>\r\n </div>\r\n </div>\r\n </div>\r\n");
330
331 //CUSTOM
332 if (!Pageview.IsVisualEditorMode && !string.IsNullOrEmpty(product.Id))
333 {
334 var itemBrand = product.ProductCategories.GetValueOrDefault("ProductGeneral")?.Fields.GetValueOrDefault("ProductSeries")?.Value?.ToString() ?? "";
335
336 WriteLiteral(" <script>\r\n gtag(\"event\", \"view_item\", {\r\n currency: \"");
337 Write(product.Price.CurrencyCode);
338 WriteLiteral("\",\r\n value: ");
339 Write(product.Price.ToStringInvariant());
340 WriteLiteral(",\r\n items: [{\r\n item_id: \"");
341 Write(product.Id);
342 WriteLiteral("\",\r\n item_name: \"");
343 Write(Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(product.Name));
344 WriteLiteral("\",\r\n item_number: \"");
345 Write(product.Number);
346 WriteLiteral("\",\r\n item_variant: \"");
347 Write(Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(product.VariantName ?? ""));
348 WriteLiteral("\",\r\n item_variant_id: \"");
349 Write(product.VariantId);
350 WriteLiteral("\",\r\n item_brand: \"");
351 Write(Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(itemBrand));
352 WriteLiteral("\",\r\n item_category: \"");
353 Write(Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(product.PrimaryOrDefaultGroup?.Name ?? ""));
354 WriteLiteral("\",\r\n currency: \"");
355 Write(product.Price.CurrencyCode);
356 WriteLiteral("\",\r\n price: ");
357 Write(product.Price.ToStringInvariant());
358 WriteLiteral(",\r\n discount: ");
359 Write(product.Discount.ToStringInvariant());
360 WriteLiteral("\r\n }]\r\n });\r\n </script>\r\n");
361 }
362 //--CUSTOM
363 }
364 }
365 #pragma warning restore 1998
366 }
367 }
368 #pragma warning restore 1591
369
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.ParagraphViewModel>
2 @using Dynamicweb.Ecommerce.ProductCatalog
3 @using Dynamicweb.Security.UserManagement
4 @using Dynamicweb.Ecommerce.CustomerExperienceCenter.Favorites
5 @using ProductViewModel = Website.ViewModels.Ecommerce.ProductViewModel
6 @using Website.Services.Product
7
8 @* CUSTOMIZED STANDARD SWIFT-V2 TEMPLATE *@
9
10 @{
11 ProductViewModel product = null;
12 if (Dynamicweb.Context.Current.Items.Contains("ProductDetails"))
13 {
14 product = (ProductViewModel)Dynamicweb.Context.Current.Items["ProductDetails"];
15 }
16 else if (!string.IsNullOrEmpty(Pageview.Page.Item["DummyProduct"]?.ToString()) && Pageview.IsVisualEditorMode)
17 {
18 var pageViewModel = Dynamicweb.Frontend.ContentViewModelFactory.CreatePageInfoViewModel(Pageview.Page);
19 ProductListViewModel productList = pageViewModel.Item.GetValue("DummyProduct") != null ? pageViewModel.Item.GetValue("DummyProduct") as ProductListViewModel : new ProductListViewModel();
20
21 if (productList?.Products is object)
22 {
23 product = (ProductViewModel)productList.Products[0];
24 }
25
26 if (string.IsNullOrEmpty(product.Number) && Pageview.IsVisualEditorMode)
27 {
28 product.Number = "394041";
29 }
30 }
31 else if (Pageview.IsVisualEditorMode)
32 {
33 product = new ProductViewModel();
34 product.Number = "394041";
35 }
36 }
37
38 @if (product is object)
39 {
40 string productId = product.Id;
41 string productName = product.Name;
42 string productNumber = product.ArtNumber;
43 string productVariantName = product.VariantName ?? string.Empty;
44 string productVariantId = !string.IsNullOrEmpty(product.VariantId) ? product.VariantId : product.DefaultVariantId;
45 @*//CUSTOM*@
46 bool canBeOrdered = ProductOrderabilityService.Current.CanBeOrdered(product);
47 bool productShowPrice = product.ShowPrice && canBeOrdered;
48 @*//--CUSTOM*@
49 string productPriceCurrencyCode = canBeOrdered ? product.Price.CurrencyCode : string.Empty;
50 string productPrice = canBeOrdered ? product.Price.ToStringInvariant() : string.Empty;
51 string productDiscount = product.Discount.ToStringInvariant();
52 string productSeriesHex = product.SeriesHex;
53 string brandLogo = product.BrandLogo;
54
55
56 string iconPath = "/Files/Images/Icons/";
57
58 string outletLabelColor = string.IsNullOrEmpty(product.OutletLabelColor) ? "primary" : product.OutletLabelColor;
59 string labelCustom1Color = string.IsNullOrEmpty(product.LabelCustom1Color) ? "primary" : product.LabelCustom1Color;
60 string labelCustom2Color = string.IsNullOrEmpty(product.LabelCustom2Color) ? "primary" : product.LabelCustom2Color;
61 bool isUserAuthenticated = UserContext.Current.IsLoggedOn;
62
63 <div class="d-flex flex-row align-items-start mb-2 gap-1">
64 @if (isUserAuthenticated)
65 {
66 if (product.Outlet)
67 {
68 <span class="badge" data-dw-colorscheme="@outletLabelColor">@Translate("Outlet", "Outlet")</span>
69 }
70 }
71 @if (!string.IsNullOrEmpty(product.LabelCustom1))
72 {
73 <span class="badge" data-dw-colorscheme="@labelCustom1Color">@product.LabelCustom1</span>
74 }
75 @if (!string.IsNullOrEmpty(product.LabelCustom2))
76 {
77 <span class="badge" data-dw-colorscheme="@labelCustom2Color">@product.LabelCustom2</span>
78 }
79 </div>
80
81 if (!string.IsNullOrEmpty(productNumber))
82 {
83 <div class="mb-1 text-muted text-uppercase fw-bold small">
84 @Translate("Number") <span itemprop="sku">@productNumber</span>
85 </div>
86 }
87
88 if (!string.IsNullOrEmpty(productName))
89 {
90 <h1 class="mb-2 fs-1" itemprop="name">@productName</h1>
91 }
92
93 if (!string.IsNullOrEmpty(product.ShortDescription))
94 {
95 <div class="mt-3">
96 @product.ShortDescription
97 </div>
98 }
99
100 @if (productShowPrice && isUserAuthenticated)
101 {
102 <div class="h2 mt-4 mb-0">
103 @product.RenderedHtml.Price
104 </div>
105 }
106
107 if (!string.IsNullOrEmpty(product.SizeText))
108 {
109 <span class="h6 mt-4 mb-0 lh-1">
110 <b>@Translate("Sizes", "Sizes"):</b> @product.SizeText
111 </span>
112 }
113
114 @if (product.ColorOptions != null)
115 {
116 ProductService? productService = ProductService.Instance;
117 string baseUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl($"Default.aspx?ID={GetPageIdByNavigationTag("Shop")}&GroupID={product.PrimaryOrDefaultGroup.Id}&ProductID={product.Id}") + "?";
118 string variantUrl = string.Empty;
119 if (!string.IsNullOrEmpty(product.VariantId))
120 {
121 variantUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl($"Default.aspx?ID={GetPageIdByNavigationTag("Shop")}&GroupID={product.PrimaryOrDefaultGroup.Id}&ProductID={product.Id}&VariantID={product.VariantId}");
122 }
123
124 string[] variantId = productVariantId.Split('.');
125 string variantColorId = variantId.Length > 0 ? variantId[0] : string.Empty;
126 string variantSizeId = variantId.Length > 1 ? variantId[1] : string.Empty;
127
128 string selectedColorName = product.ColorOptions.FirstOrDefault(v => v.Id.Equals(variantColorId))?.Name ?? string.Empty;
129
130 <span class="h6 mt-4 mb-2 lh-1">
131 <b>@Translate("Colors", "Colors"):</b> @selectedColorName
132 </span>
133 <form class="d-flex gap-2 js-variant-selector" data-combinations="@string.Join(",", product.VariantCombinations())" data-base-url="@baseUrl" data-friendly-url="@variantUrl" data-dw-colorscheme="none">
134 <div class="d-flex gap-2 start flex-wrap js-variant-group" data-group-id="1">
135 @foreach (VariantOptionViewModel color in product.ColorOptions)
136 {
137 string active = variantId != null && variantId.Contains(color.Id) ? "active" : string.Empty;
138
139 <button data-dw-colorscheme="white" type="button" class="border-0 overflow-hidden colorbox colorbox-auto rounded-0 p-0 d-inline-block variant-option js-variant-option @active" style="width:46px" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="@(color.Id)" id="@(productId)_@(color.Id)_@Pageview.CurrentParagraph.ID">
140 <img alt="@color.Name" class="elka-variant-color-preview" style="width: 46px; height: 46px;" src="/Admin/Public/GetImage.ashx?image=@(productService.GetVariantOptionColorImage(color.Id))&width=128&format=webp">
141 </button>
142 }
143 </div>
144 <div class="d-flex gap-2 start flex-wrap js-variant-group d-none" data-group-id="2">
145 <button type="button" class="variant-option js-variant-option active" style="width:46px" onclick="swift.VariantSelector.OptionClick(event)" data-variant-id="@(variantSizeId)" id="@(productId)_@(variantSizeId)_@Pageview.CurrentParagraph.ID">
146 </button>
147 </div>
148 </form>
149 <script type="module">
150 swift.VariantSelector.init();
151 </script>
152 }
153
154 if (isUserAuthenticated)
155 {
156 string variantId = product.VariantId;
157 string productPriceCurrency = product.Price.CurrencyCode;
158
159 int defaultFavoriteListId = 0;
160 IEnumerable<FavoriteList> favoriteLists = new FavoriteList[] { };
161
162 if (Pageview?.User?.ID != null)
163 {
164 favoriteLists = Pageview.User.GetFavoriteLists();
165
166 if (favoriteLists.Count() == 1)
167 {
168 foreach (FavoriteList list in favoriteLists)
169 {
170 defaultFavoriteListId = list.ListId;
171 }
172 }
173 }
174
175 defaultFavoriteListId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("FavoriteListId")) ? Convert.ToInt32(Dynamicweb.Context.Current.Request.QueryString.Get("FavoriteListId")) : defaultFavoriteListId;
176 string favoriteToggleType = defaultFavoriteListId == 0 && favoriteLists.Count() > 1 ? "multiple-lists" : "single-list";
177 favoriteToggleType = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("FavoriteListId")) ? "remove-from-list" : favoriteToggleType;
178
179 bool isInFavoriteList = Pageview?.User?.ID != null ? Pageview.User.IsProductInAnyFavoriteList(productId, variantId) : false;
180 string pageId = GetPageIdByNavigationTag("FavoriteServicePage") != 0 ? GetPageIdByNavigationTag("FavoriteServicePage").ToString() : "";
181 pageId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("FavoriteListId")) ? Pageview.Page.ID.ToString() : pageId;
182
183 string url = "/Default.aspx?ID=" + pageId + "&ProductID=" + productId + "&VariantId=" + variantId + "&ProductVariantId=" + variantId + "&ShowButtonText=True";
184 url += favoriteToggleType == "single-list" || favoriteToggleType == "remove-from-list" ? "&FavoriteListId=" + defaultFavoriteListId : "";
185 url += favoriteToggleType == "remove-from-list" ? "&FavoriteCmd=removeproductfromfavoritelist" : "";
186
187 string filledFavoriteIcon = isInFavoriteList ? "" : "d-none";
188 string outlineFavoriteIcon = isInFavoriteList ? "d-none" : "";
189
190 string favoriteButtonId = $"FavoriteBtn_{productId}{variantId.Replace(".", "")}";
191
192 <div class="mt-4">
193 @*//CUSTOM*@
194 @if (canBeOrdered)
195 {
196 <button class="btn btn-lg btn-secondary js-e-product-matrix-modal-open-button" type="button" data-bs-toggle="modal" data-bs-target=".js-e-product-matrix-modal">
197 @Translate("eCom Product - Launch Product Matrix - Button", "Bestil vare")
198 </button>
199 }
200 @*//--CUSTOM*@
201 <button type="button" class="pe-0 py-0 btn custom_favorites-button" id="@favoriteButtonId" onclick="swift.Favorites.Toggle(event, '@url', '@favoriteToggleType')" style="z-index: 1;" data-product-id="@productId" data-variant-id="@variantId" data-product-name="@productName" data-product-price="@productPrice" data-product-currency="@productPriceCurrency">
202 <span class="favorite-icon">
203 <span class="text-nowrap in-list @filledFavoriteIcon" title="In list">
204 <span class="icon-2" aria-hidden="true">@ReadFile(iconPath + "heart-filled.svg")</span>
205 <span class="small ms-2">@Translate("Remove from favorites")</span>
206 </span>
207 <span class="text-nowrap not-in-list @outlineFavoriteIcon" title="Not in list">
208 <span class="icon-2" aria-hidden="true">@ReadFile(iconPath + "heart.svg")</span>
209 <span class="small ms-2">@Translate("Add to favorites")</span>
210 </span>
211 </span>
212 </button>
213 </div>
214 @product.RenderedHtml.Matrix
215 }
216
217 <div class="row justify-content-between">
218 <div class="col-12 col-md-12 col-lg-6 mt-4">
219 <div class="dropdown js-elka-product" data-product-id="@productId" data-variant-id="@productVariantId">
220 <button aria-expanded="false" class="btn btn-link dropdown-toggle border text-decoration-none" data-bs-toggle="dropdown" type="button">
221 <span class="icon-2" aria-hidden="true">@ReadFile(iconPath + "download.svg")</span>
222 @Translate( "Elka - Product Details - PDF Download - Text", "Download datablad" )
223 </button>
224 <div class="dropdown-menu p-0">
225 <a class="dropdown-item js-elka-download-product-pdf py-1 px-2 d-block" href="#">
226 @Translate( "Elka - Product Details - PDF Download without logo - Text", "Uden eget logo" )
227 </a>
228 <a class="dropdown-item p-0" href="#">
229 <label class="m-0 py-1 px-2 pointer-cursor d-block" for="elkaPdfUploadInput">
230 @Translate( "Elka - Product Details - PDF Download logo - Text", "Med eget logo" )
231 </label>
232 <input class="d-none js-elka-upload-pdf-logo" id="elkaPdfUploadInput" type="file">
233 </a>
234 </div>
235 </div>
236 </div>
237 </div>
238
239 //CUSTOM
240 if (!Pageview.IsVisualEditorMode && !string.IsNullOrEmpty(product.Id))
241 {
242 var itemBrand = product.ProductCategories.GetValueOrDefault("ProductGeneral")?.Fields.GetValueOrDefault("ProductSeries")?.Value?.ToString() ?? "";
243
244 <script>
245 gtag("event", "view_item", {
246 currency: "@(product.Price.CurrencyCode)",
247 value: @product.Price.ToStringInvariant(),
248 items: [{
249 item_id: "@(product.Id)",
250 item_name: "@Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(product.Name)",
251 item_number: "@(product.Number)",
252 item_variant: "@Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(product.VariantName ?? "")",
253 item_variant_id: "@(product.VariantId)",
254 item_brand: "@Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(itemBrand)",
255 item_category: "@Dynamicweb.Core.Encoders.HtmlEncoder.JavaScriptStringEncode(product.PrimaryOrDefaultGroup?.Name ?? "")",
256 currency: "@(product.Price.CurrencyCode)",
257 price: @product.Price.ToStringInvariant(),
258 discount: @product.Discount.ToStringInvariant()
259 }]
260 });
261 </script>
262 }
263 //--CUSTOM
264 }