Exception in template (eCom/Product/Custom_hattingagro-product.cshtml): System.NullReferenceException: Object reference not set to an instance of an object.
   at CompiledRazorTemplates.Dynamic.cebbfeebbecbf.GetProductBreadcrumb(Product prod, Group grp)
   at CompiledRazorTemplates.Dynamic.cebbfeebbecbf.Execute()
   at RazorEngine.Templating.TemplateBase.RazorEngine.Templating.ITemplate.Run(ExecuteContext context)
   at RazorEngine.Razor.Parse[T](String razorTemplate, T model, String cacheName)
   at Dynamicweb.Rendering.Template.Output()
@inherits Dynamicweb.Rendering.RazorTemplateBase<Dynamicweb.Rendering.RazorTemplateModel<Dynamicweb.Rendering.Template>> @using Application.CustomModules.Helpers @using NPoco; @using System.Text.RegularExpressions; @using Dynamicweb.eCommerce.Products; @using System.Web.WebPages; @functions { #region Objects public class SplashTypes { //Todo Add more if needed by HA public bool Offer { get; set; } public bool Discount { get; set; } public bool HasSpecialShipping { get; set; } } public class DiscountObj { public double Quantity { get; set; } public double UnitPrice { get; set; } public double UnitDiscount { get; set; } public double TotalDiscount { get; set; } public string VariantId { get; set; } public DateTime? ValidFrom { get; set; } public DateTime? ValidTo { get; set; } } #endregion Objects #region General public string CheckForPopupHelper(Product ecomProduct) { var popupStartDate = string.IsNullOrEmpty(ecomProduct.GetProductFieldValue("PopupStartDate").ToString()) ? new DateTime() : ecomProduct.GetProductFieldValue("PopupStartDate").ToString().AsDateTime(); var popupExpiryDate = string.IsNullOrEmpty(ecomProduct.GetProductFieldValue("PopupExpiryDate").ToString()) ? new DateTime() : ecomProduct.GetProductFieldValue("PopupExpiryDate").ToString().AsDateTime(); var foreverValidDate = new DateTime(2950, 01, 01, 00, 00, 00); //var popupStartDate = string.IsNullOrEmpty(ecomProduct.GetPropertyValue("PopupStartDate").ToString()) ? "hello" : ConvertToDateTime(ecomProduct.GetProductFieldValue("PopupStartDate").ToString()); //var popupExpiryDate = Convert.ToDateTime(ecomProduct.GetProductFieldValue("PopupExpiryDate")); var popupAvailable = !string.IsNullOrEmpty(ecomProduct.GetProductFieldValue("Popup").ToString()); var popupText = "empty"; if (popupAvailable && popupStartDate <= DateTime.Now && popupExpiryDate >= DateTime.Now || popupAvailable && popupStartDate >= foreverValidDate) { popupText = ecomProduct.GetProductFieldValue("Popup").ToString(); } return popupText; } public static bool IsB2B() { bool isB2B = Dynamicweb.Modules.UserManagement.User.GetCurrentUserID() > 0; return isB2B; } public static string StripHTML(string input) { return Regex.Replace(input, "<.*?>", String.Empty); } public string FormatPriceForGoogle(string price) { string amount = ""; //String.Format("{0:0.00}", 123.4); // "123.40" string priceformate = price; int AreaId = Dynamicweb.Frontend.PageView.Current().AreaID; string AreaName = Dynamicweb.Content.Area.GetAreaById(AreaId).Name; if (AreaName == "DE") { priceformate = price.Replace(".", "").Replace(",", "."); } amount = String.Format("{0:0.00}", priceformate);//.Replace(".", "").Replace(",", "."); return amount; } string GetProductCategory(string prodID) { var prod = Dynamicweb.eCommerce.Products.Product.GetProductByID(prodID); string breadCrumb = ""; string groupID = prod.PrimaryGroupID; if (string.IsNullOrEmpty(groupID)) { foreach (Dynamicweb.eCommerce.Products.Group gr in prod.Groups) { if (gr.HasChildGroups == false) { groupID = gr.ID; break; } } } List<Dynamicweb.eCommerce.Products.Group> grps = new List<Dynamicweb.eCommerce.Products.Group>(); do { var gr = Dynamicweb.eCommerce.Products.Group.GetGroupByID(groupID); grps.Add(gr); if (gr.ParentGroups.Count == 0) { break; } if (gr.ParentGroups[0] == null) { break; } groupID = gr.ParentGroups[0].ID; } while (groupID != "shop"); grps.Reverse(); int i = 0; List<string> category = new List<string>(); foreach (Dynamicweb.eCommerce.Products.Group gr in grps) { if (i > 0) { category.Add(gr.Name); } else { category.Add(gr.Name); } i++; } breadCrumb = string.Join(" &gt; ", category.ToArray()); return breadCrumb; } string GetProductBreadcrumb(Dynamicweb.eCommerce.Products.Product prod, Dynamicweb.eCommerce.Products.Group grp) { string breadCrumb = ""; if (prod != null || grp != null) { breadCrumb = "<ol class='breadcrumb'>"; string groupID = ""; if (prod != null) { breadCrumb += "<li class=\"tilbage\"><a onclick=\"window.history.back();\">Tilbage</a></li>"; groupID = prod.PrimaryGroupID; if (string.IsNullOrEmpty(groupID)) { foreach (Dynamicweb.eCommerce.Products.Group gr in prod.Groups) { if (gr.HasChildGroups == false) { groupID = gr.ID; break; } } } } else if (grp != null) { breadCrumb += "<li><a href=\"/\">Home</a></li>"; groupID = grp.ID; } List<Dynamicweb.eCommerce.Products.Group> grps = new List<Dynamicweb.eCommerce.Products.Group>(); do { var gr = string.IsNullOrEmpty(groupID) ? grp : Dynamicweb.eCommerce.Products.Group.GetGroupByID(groupID); if (gr.ParentGroups.Count == 0) { break; } grps.Add(gr); groupID = gr.ParentGroups[0].ID; } while (!string.IsNullOrEmpty(groupID) && groupID != "shop"); grps.Reverse(); int i = 0; foreach (Dynamicweb.eCommerce.Products.Group gr in grps) { breadCrumb += "<li><a href='" + getGroupCanonicalMethod(gr.ID) + "'>" + gr.Name + "</a></li>"; i++; } if (prod != null) { breadCrumb += "<li>" + prod.Name + "</li>"; } breadCrumb += "</ol>"; } return breadCrumb; } string getGroupCanonicalMethod(string groupID) { string DWurl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?ID=8584&GroupID=" + groupID); return DWurl; } string getGroupCanonicalMethod(string prodId, string groupID) { string DWurl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?ID=8584&GroupID=" + groupID + "&ProductID=" + prodId); return DWurl; } public string GetAddressRecIDByID(string ID) { if (string.IsNullOrEmpty(ID)) return ""; var adr = Dynamicweb.Modules.UserManagement.UserAddress.GetUserAddressById(int.Parse(ID)); if (adr != null) return adr.UID; adr = Dynamicweb.Modules.UserManagement.UserAddress.GetUserDefaultAddress(int.Parse(ID)); if (adr != null) return adr.UID; return ""; } #endregion General #region Productinfo public IEnumerable<string> FetchFiles(string fileString) { var filesList = new List<string>(); filesList = fileString.Split(';').ToList(); return filesList; } public SplashTypes Splashes(Dynamicweb.eCommerce.Products.Product product) { var splashTypes = new SplashTypes(); var variantId = GetString("Ecom:Product.VariantID"); var priceList = new List<Dynamicweb.eCommerce.Prices.Price>(product.Prices).Where(p => p.VariantID == variantId).ToList(); if ((bool)product.GetProductFieldValue("HasSpecialShipping")) { splashTypes.HasSpecialShipping = true; } //if ((bool)prod.ProductFieldValues.GetProductFieldValue("HasSpecialShipping").Value) try { if (priceList.Count > 1 && priceList.Where(p => p.Quantity == 0 && ( (!p.ValidTo.HasValue && !p.ValidFrom.HasValue) || (p.ValidTo.HasValue && p.ValidFrom.HasValue && p.ValidFrom.Value <= DateTime.Today && DateTime.Today <= p.ValidTo.Value) )).GroupBy(p => p.VariantID).Any(p => p.Count() > 1)) { splashTypes.Offer = true; } else if (priceList.FindAll( x => x.Quantity == 0 && (product.VariantID == x.VariantID || product.DefaultVariantComboID == x.VariantID) && ( (!x.ValidTo.HasValue && !x.ValidFrom.HasValue) || (x.ValidTo.HasValue && x.ValidFrom.HasValue && x.ValidFrom.Value <= DateTime.Today && DateTime.Today <= x.ValidTo.Value) )).Count() > 1) { splashTypes.Offer = true; } if (priceList.FindAll(x => x.Quantity > 1 && x.ValidFrom < DateTime.Now && x.ValidTo > DateTime.Now).Count > 0) { splashTypes.Discount = true; } } catch { return splashTypes; } return splashTypes; } public SplashTypes SplashesList(Dynamicweb.eCommerce.Products.Product product) { var splashTypes = new SplashTypes(); var variantId = GetString("Ecom:Product.VariantID"); var priceList = new List<Dynamicweb.eCommerce.Prices.Price>(product.Prices).ToList(); if ((bool)product.GetProductFieldValue("HasSpecialShipping")) { splashTypes.HasSpecialShipping = true; } //if ((bool)prod.ProductFieldValues.GetProductFieldValue("HasSpecialShipping").Value) try { if (priceList.Count > 1 && priceList.Where(p => p.Quantity == 0 && ( (!p.ValidTo.HasValue && !p.ValidFrom.HasValue) || (p.ValidTo.HasValue && p.ValidFrom.HasValue && p.ValidFrom.Value <= DateTime.Today && DateTime.Today <= p.ValidTo.Value) )).GroupBy(p => p.VariantID).Any(p => p.Count() > 1)) { splashTypes.Offer = true; } else if (priceList.FindAll( x => x.Quantity == 0 && (product.VariantID == x.VariantID || product.DefaultVariantComboID == x.VariantID) && ( (!x.ValidTo.HasValue && !x.ValidFrom.HasValue) || (x.ValidTo.HasValue && x.ValidFrom.HasValue && x.ValidFrom.Value <= DateTime.Today && DateTime.Today <= x.ValidTo.Value) )).Count() > 1) { splashTypes.Offer = true; } if (priceList.FindAll(x => x.Quantity >= 1 && x.ValidFrom < DateTime.Now && x.ValidTo > DateTime.Now).Count > 0) { splashTypes.Discount = true; } } catch { return splashTypes; } return splashTypes; } public Dictionary<string, string> ParseProductFeatures(string productFeaturesRaw) { Dictionary<string, string> productFeatures = new Dictionary<string, string>(); string[] delimiter = { "<br/>" }; foreach (string x in productFeaturesRaw.Split(delimiter, StringSplitOptions.None)) { string[] values = x.Split(':'); if (!productFeatures.ContainsKey(values[0])) { productFeatures.Add(values[0], values[1]); } } return productFeatures; } public string GetImagePath(string imageGUID) { return "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + imageGUID + "&size=450x400&format=png"; } public string GetImageThumbPath(string imageGUID) { return "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + imageGUID + "&size=80x80&format=png"; } public string GetImageSmallThumbPath(string imageGUID) { return "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + imageGUID + "&size=50x50&format=png"; } #endregion Productinfo #region Prices List<DiscountObj> GetDiscounts(List<Dynamicweb.eCommerce.Prices.Price> prices) { var discounts = new List<DiscountObj>(); var variantId = GetString("Ecom:Product.VariantID"); //General prices are specified by a quantity of 0. double originalPrice = prices.FirstOrDefault(e => e.Quantity == 0 && e.VariantID == variantId).Amount; if (prices.Any()) { var priceList = prices.FindAll(x => x.Quantity > 1 && x.ValidFrom < DateTime.Now && x.ValidTo > DateTime.Now).Where(x => x.VariantID == variantId); var priceListGrouped = priceList.GroupBy(e => e.Quantity).Select(g => g.OrderBy(x => x.Amount).FirstOrDefault()); foreach (var price in priceListGrouped) { var DiscountObj = new DiscountObj { Quantity = price.Quantity, UnitPrice = price.Amount, UnitDiscount = CalculateUnitDiscount(price.Amount, originalPrice), TotalDiscount = CalculateTotalDiscount(price.Amount, originalPrice, price.Quantity), VariantId = price.VariantID, ValidFrom = price.ValidFrom, ValidTo = price.ValidTo }; discounts.Add(DiscountObj); } } return discounts; } double CalculateUnitDiscount(double unitPrice, double originalPrice) { double unitDiscount = 0; unitDiscount = originalPrice - unitPrice; return unitDiscount; } double CalculateTotalDiscount(double unitPrice, double originalPrice, double quantity) { double totalDiscount = 0; totalDiscount = (originalPrice - unitPrice) * quantity; return totalDiscount; } bool HasAmountDiscount(Dynamicweb.eCommerce.Prices.PriceCollection prices) { bool hasAmountDiscount = false; var variantId = GetString("Ecom:Product.VariantID"); var priceList = prices.Where(x => x.VariantID == variantId).ToList(); if (priceList.FindAll(x => x.Quantity > 1 && x.ValidFrom < DateTime.Now && x.ValidTo > DateTime.Now).Count > 0) { hasAmountDiscount = true; } return hasAmountDiscount; } double GetPrice(Dynamicweb.eCommerce.Products.Product product) { double price = 0; if (IsB2B()) { price = RoundCorrect(Dynamicweb.eCommerce.Products.Product.GetProductsAndVariantsByProduct(product).getProductById(product.ID, product.DefaultVariantComboID).Price.PriceWithoutVAT); } else { price = RoundCorrect(Dynamicweb.eCommerce.Products.Product.GetProductsAndVariantsByProduct(product).getProductById(product.ID, product.DefaultVariantComboID).Price.PriceWithoutVAT); } return price; } public static string getVariantBeforePrice(string prodNumber) { var prod = Dynamicweb.eCommerce.Products.Product.GetProductByNumber(prodNumber); if (prod != null) { var pList = prod.Prices.Where(x => (x.VariantID == prod.VariantID || x.VariantID == prod.DefaultVariantComboID) && x.Quantity == 0 && (x.ValidFrom.Value <= DateTime.Today && DateTime.Today <= x.ValidTo.Value)); if (pList.Count() > 0) { return pList.Max(x => x.Amount).ToString("F2"); } } return string.Empty; // return prod.Prices.Where(x => x.VariantID == prod.VariantID && x.Quantity == 0 && (x.ValidFrom.Value <= DateTime.Today && DateTime.Today <= x.ValidTo.Value)).Max(x => x.Amount).ToString("F2"); } bool IsPriceHidden(string productId) { bool hidden = false; var hidePriceItem = Dynamicweb.Content.Items.Item.GetItemById("HidePrice", "1"); List<string> hideThese = hidePriceItem["HidePrice"].ToString().Split(',').ToList(); if (hideThese.Contains(productId)) { hidden = true; } return hidden; } bool HasDiscount(Dynamicweb.eCommerce.Products.Product prod) { List<Dynamicweb.eCommerce.Prices.Price> priceList = new List<Dynamicweb.eCommerce.Prices.Price>(prod.Prices); try { // if (priceList != null && priceList.Count > 1 && priceList.FindAll(x => x.Quantity == 0 && (prod.VariantID == x.VariantID || prod.DefaultVariantComboID == x.VariantID) && ( (!x.ValidTo.HasValue && !x.ValidFrom.HasValue) || (x.ValidTo.HasValue && x.ValidFrom.HasValue && x.ValidFrom.Value <= DateTime.Today && DateTime.Today <= x.ValidTo.Value) ) ).Count > 1) { return true; } } catch { return false; } return false; } public double RoundCorrect(double d) { if (d * 10 - Math.Floor(d) * 10 == 5) { return Math.Floor(d); } else { return Math.Round(d); } } string makeDiscountMarkup(object currencyCode, object productPrice, string prodName) { string html = ""; html += "<figure>"; html += "<img src='/admin/public/getimage.ashx?Image=/Files/Billeder/ny hjemmeside/discount.jpg&amp;width=72&amp;Height=72&amp;crop=5&amp;Resolution=72&amp;Compression=80&amp;AlternativeImage=/Files/Billeder/Ecom/NoPicture_medium_300x300.gif' border=\"0\" alt=\"" + prodName + "\" title=\"" + prodName + "\" />"; html += "</figure>"; html += "<div class=\"info\">"; html += "<span class=\"product-name\">" + prodName + "</span>"; html += "<div class=\"cmd row\">"; html += "<div class=\"col-xs-8\">"; html += "</div>"; html += "<div class=\"col-xs-4\">"; html += "<span class=\"order-line-price\">"; html += currencyCode + " " + productPrice; html += "</span>"; html += "</div>"; html += "</div>"; html += "</div>"; return html; } #endregion Prices #region Urls string PrimaryPageID() { return "8584"; } string GetGroupCanonical(string groupID) { string DWurl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?ID=" + PrimaryPageID() + "&GroupID=" + groupID); return DWurl; } string[] notPrimaryGroups = new string[] { "julen", "tilbud" }; string GetProductCanonical(string prodId) { Dynamicweb.eCommerce.Products.Product prod = Dynamicweb.eCommerce.Products.Product.GetProductByID(prodId); string groupID = prod.PrimaryGroupID; if (string.IsNullOrEmpty(groupID)) { foreach (Dynamicweb.eCommerce.Products.Group gr in prod.Groups) { if (gr.ParentGroups == null || gr.ParentGroups.Count == 0) { continue; } if (notPrimaryGroups.Any(g => gr.Name.ToLower().Contains(g.ToLower()))) { continue; } if (gr.HasChildGroups == false && gr.ParentGroups[0].NavigationClickable) { groupID = gr.ID; break; } } } string DWurl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl("Default.aspx?ID=" + PrimaryPageID() + "&GroupID=" + groupID + "&ProductID=" + prodId); return DWurl; } #endregion Urls //#region Variants //public string GetVariantMeasurement(string variantGroupID) //{ // string measurement = string.Empty; // string commandText = @"select VariantGroupOptionPropertyValue from dbo.EcomVariantGroupOptionPropertyValue where VariantGroupOptionPropertyValuePropertyID = {0}"; // var commandBuilder = new Dynamicweb.CommandBuilder(); // commandBuilder.Add(commandText, variantGroupID); // var dbResult = Dynamicweb.Database.ExecuteScalar(commandBuilder); // if(dbResult != null) // { // measurement = dbResult.ToString(); // } // return measurement; //} //#endregion Variants } @helper ShowPriceDetail(Dynamicweb.eCommerce.Products.Product product) { string productprice = GetString("Ecom:Product.Price.PriceWithoutVAT"); var isPriceHidden = product.GetProductFieldValue("hideprice"); var notBuyable = product.GetProductFieldValue("NotBuyable"); if (GetPrice(product) != 0 && !(bool)isPriceHidden) { if (HasDiscount(product)) { // && p.Amount < prod.Price.PriceWithoutVAT List<Dynamicweb.eCommerce.Prices.Price> priceList = new List<Dynamicweb.eCommerce.Prices.Price>(product.Prices); List<Dynamicweb.eCommerce.Prices.Price> discounts = null; string orgPrice = ""; if (string.IsNullOrEmpty(product.VariantID)) { discounts = priceList.FindAll(p => p.Quantity == 0 && p.VariantID == product.DefaultVariantComboID && p.Amount > product.Price.PriceWithoutVAT && p.ValidFrom < DateTime.Now && p.ValidTo > DateTime.Now); } else { discounts = priceList.FindAll(p => p.Quantity == 0 && p.VariantID == product.VariantID && p.Amount > product.Price.PriceWithoutVAT && p.ValidFrom < DateTime.Now && p.ValidTo > DateTime.Now); } if (discounts != null && discounts.Count > 0) { orgPrice = string.Format("{0:0.00}", RoundCorrect(discounts.Max(p => p.Amount))); <div class="priser-item priser-item-underlined">@product.Price.Currency.Code @orgPrice</div> if ((bool)notBuyable) { <div class="priser-item priser-item-actual-price">Kontakt Kundeservice for køb på tlf. 70159909</div> } } } if (string.IsNullOrEmpty(product.VariantID)) { <div class="priser-item priser-item-actual-price"> @product.Price.Currency.Code @productprice </div> if ((bool)notBuyable) { <div class="priser-item priser-item-actual-price">Kontakt Kundeservice for køb på tlf. 70159909</div> } } else { <span style="display:none;" class="price-spar">@product.Price.Currency.Code <span itemprop="price" content="productprice">@productprice</span></span> <div class="priser-item priser-item-actual-price">@product.Price.Currency.Code @productprice</div> if ((bool)notBuyable) { <div class="priser-item priser-item-actual-price">Kontakt Kundeservice for køb på tlf. 70159909</div> } } } else { <div class="priser-item priser-item-actual-price">Kontakt Kundeservice for priser på tlf. 70159909 </div> } } @helper ShowPriceList(Dynamicweb.eCommerce.Products.Product product) { var isPriceHidden = product.GetProductFieldValue("hideprice"); var notBuyable = product.GetProductFieldValue("NotBuyable"); if (GetPrice(product) != 0 && !(bool)isPriceHidden) { double Productprice = 0; var prod2 = Dynamicweb.eCommerce.Products.Product.GetProductByID(product.ID); Productprice = RoundCorrect(Dynamicweb.eCommerce.Products.Product.GetProductsAndVariantsByProduct(prod2).getProductById(product.ID, prod2.DefaultVariantComboID).Price.PriceWithoutVAT); if (HasDiscount(product)) { // && p.Amount < prod.Price.PriceWithoutVAT List<Dynamicweb.eCommerce.Prices.Price> discounts = null; List<Dynamicweb.eCommerce.Prices.Price> priceList = new List<Dynamicweb.eCommerce.Prices.Price>(product.Prices); string orgPrice = ""; discounts = priceList.FindAll(p => p.Quantity == 0 && p.VariantID == prod2.DefaultVariantComboID && p.Amount > prod2.Price.PriceWithoutVAT && p.ValidFrom < DateTime.Now && p.ValidTo > DateTime.Now); if (discounts != null && discounts.Count > 0) { orgPrice = string.Format("{0:0.00}", RoundCorrect(discounts.Max(p => p.Amount))); } if (discounts != null && discounts.Count > 0) { <div class="item-body-discount"> <span class="discount">@product.Price.Currency.Code @orgPrice</span> </div> } } <span class="currency">DKK</span> <span class="amount">@string.Format("{0:0.00}", Productprice) </span> if ((bool)notBuyable) { <div class="priser-item contact">Kontakt Kundeservice for køb på tlf. 70159909</div> } } else { <span class="amount contact">Kontakt Kundeservice for priser på tlf. 70159909</span> } } @helper ShowPriceListforgoogle(Product prod) { var hidePriceItem = Dynamicweb.Content.Items.Item.GetItemById("HidePrice", "1"); List<string> hideUs = hidePriceItem["HidePrice"].ToString().Split(',').ToList(); if (!hideUs.Contains(prod.ID)) { List<Dynamicweb.eCommerce.Prices.Price> discounts = null; List<Dynamicweb.eCommerce.Prices.Price> priceList = new List<Dynamicweb.eCommerce.Prices.Price>(prod.Prices); double ProductpriceWithVAT = 0; double ProductpriceWithoutVAT = 0; string orgPriceWithoutVAT = ""; string orgPriceWithVAT = ""; ProductpriceWithVAT = prod.Price.PriceWithVAT; ProductpriceWithoutVAT = prod.Price.PriceWithoutVAT; if (HasDiscount(prod)) { discounts = priceList.FindAll(p => p.Quantity == 0 && p.Amount > prod.Price.PriceWithoutVAT && p.ValidFrom < DateTime.Now && p.ValidTo > DateTime.Now && p.VariantID == prod.DefaultVariantComboID); if (discounts != null && discounts.Count > 0) { orgPriceWithoutVAT = string.Format("{0:0.00}", discounts.Max(p => p.Amount)); orgPriceWithVAT = string.Format("{0:0.00}", discounts.Max(p => p.Amount) * 1.25); <g:price>@FormatPriceForGoogle(string.Format("{0:0.00}", orgPriceWithVAT)) @prod.Price.Currency.Code </g:price> <g:priceWithoutVAT>@FormatPriceForGoogle(string.Format("{0:0.00}", orgPriceWithoutVAT)) @prod.Price.Currency.Code </g:priceWithoutVAT> <g:sale_price>@FormatPriceForGoogle(string.Format("{0:0.00}", ProductpriceWithVAT)) @prod.Price.Currency.Code </g:sale_price> <g:sale_priceWithoutVAT>@FormatPriceForGoogle(string.Format("{0:0.00}", ProductpriceWithoutVAT)) @prod.Price.Currency.Code </g:sale_priceWithoutVAT> } } else { <g:price>@FormatPriceForGoogle(string.Format("{0:0.00}", ProductpriceWithVAT)) @prod.Price.Currency.Code </g:price> <g:priceWithoutVAT>@FormatPriceForGoogle(string.Format("{0:0.00}", ProductpriceWithoutVAT)) @prod.Price.Currency.Code </g:priceWithoutVAT> } } } @helper RenderRaptorModule(List<LoopItem> raptorProducts, string raptorMethod, int numOfProducts = 10) { var prodsWithoutSaedVarer = new List<LoopItem>(); var owlSlider = false; if (numOfProducts > 4) { owlSlider = true; } var symbolDescriptionPageIdObj = Dynamicweb.Frontend.PageView.Current().Area.Item["SymbolDescriptionPageId"]; string symbolPageUrl = null; if (symbolDescriptionPageIdObj != null) { var symbolDescriptionPageId = Convert.ToInt32(symbolDescriptionPageIdObj); symbolPageUrl = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(symbolDescriptionPageId); } foreach (var prod in raptorProducts) { var prodGroup = prod.GetString("Ecom:Product.PrimaryOrFirstGroupID"); // Check for Saed group. if (prodGroup != "23427" && prod.GetString("Ecom:Product.Name") != "Ekspeditionsgebyr") { prodsWithoutSaedVarer.Add(prod); } } foreach (var raptorProduct in prodsWithoutSaedVarer.Take(numOfProducts)) { var isVariant = raptorProduct.GetString("Ecom:Product.DefaultVariantComboID") != ""; var variantGroupName = string.Empty; int variantLoopCounter = 0; var variantOptionId = string.Empty; var productLink = GetProductCanonical(raptorProduct.GetString("Ecom:Product.ID")) + "?RaptorRecommendation=" + raptorMethod; foreach (LoopItem i2 in raptorProduct.GetLoop("VariantGroups")) { if (i2.GetString("Ecom:VariantGroup.ID") == "SV") { variantGroupName = "SV"; } foreach (LoopItem i3 in i2.GetLoop("VariantAvailableOptions")) { variantLoopCounter = i3.GetInteger("VariantAvailableOptions.LoopCounter"); variantOptionId = i3.GetString("Ecom:VariantOption.ID"); } } string productImage = string.Empty; var imageGuid = raptorProduct.GetString("Ecom:Product:Field.ImageGuid"); if (!string.IsNullOrEmpty(imageGuid)) { productImage = "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + imageGuid + "&size=220x245&format=png"; } var ecomProduct = Dynamicweb.eCommerce.Products.Product.GetProductByID(raptorProduct.GetString("Ecom:Product.ID")); var splashTypes = Splashes(ecomProduct); var popupText = CheckForPopupHelper(ecomProduct); var notBuyable = ecomProduct.GetProductFieldValue("NotBuyable"); if (owlSlider) { <div class="item"> <div class="col-xs-12 col-md-12 product pop-prodslider-item @(isVariant ? "variant-product" : "")"> <div class="product-wrapper"> <div class="top"> <div class="product-item-header"> <a href="@productLink"> @if (splashTypes.Offer) { <div class="circle-offer circle-offer-tilbud"> <span>Tilbud</span> </div> } @if (splashTypes.Discount) { <div class="circle-offer circle-offer-rabat"> <span>Mængde</span> <span>Rabat</span> </div> } <img class="prod-Image" src="@productImage" alt="" /> </a> </div> <div class="product-item-body"> @if (!isVariant && variantLoopCounter <= 0) { <a href="@productLink" class="btn-se-product">Se produkt</a> } <div class="item-body-title">@raptorProduct.GetString("Ecom:Product.Name")</div> @*<div class="item-body-color"> @foreach (LoopItem i2 in raptorProduct.GetLoop("VariantGroups")) { if (i2.GetString("Ecom:VariantGroup.Label") == "Farvekode Værdi") { <ul id="choosingcolors" class="cc-wrapper-product-list"> @foreach (LoopItem i3 in i2.GetLoop("VariantAvailableOptions")) { <li class="color-option"> <input type="radio" name="colors" class="var-color-option-chooser"> <label for="colors" class="productlist-colors" style="background-color:@i3.GetString("Ecom:VariantOption.Name")"></label> </li> } </ul> } } </div>*@ </div> </div> <div class="bottom_align"> <div class="item-body-price"> @ShowPriceList(ecomProduct) </div> <div class="item-body-varenr">Varenr: @raptorProduct.GetString("Ecom:Product.Number")</div> <div class="product-item-actions"> @if (raptorProduct.GetString("Ecom:Product.DefaultVariantComboID") == "" && variantLoopCounter <= 0) { if ((bool)notBuyable) { <a href="@productLink" class="btn-se-product text-center no-padding" style="padding-right: 0px;">Se produkt</a> } else { @*<a href="@productLink" class="btn-se-product">Se produkt</a>*@ <input type="number" name="amount" class="product-amount js-product-amount" value="1" /> <a href="#" data-class="overlay-add-to-basket" data-src="Files/Templates/Designs/Hatting_KS_2013/ajax-addtocart.html" onclick="addToCartlist(@raptorProduct.GetString("Ecom:Product.ID"), 1, '@raptorMethod', '@popupText', this), dataLayer.push({'ecomm_prodid':'@ecomProduct.ID','ecomm_pagetype':'raptormodule','ecomm_totalvalue':'@ecomProduct.Price.PriceWithVAT'});" class="btn btn-success btn-basket"> <span class="btn-basket-icon"></span> </a> } } else { <a href="@productLink" class="btn btn-success btn">Vælg variant</a> } </div> @{ var hasSpecialShipping = raptorProduct.GetString("Ecom:Product:Field.HasSpecialShipping") == "True"; var hasDirectDelivery = raptorProduct.GetBoolean("Ecom:Product:Field.DirectDelivery"); var onStock = raptorProduct.GetDouble("Ecom:Product.Stock") > 0; } @if (hasSpecialShipping || hasDirectDelivery || onStock) { <a class="product-item-footer" href="@symbolPageUrl"> <div class="item-footer-text text-left"> @if (hasSpecialShipping) { <img src="/Files/Templates/Designs/Hatting_KS_2013/img/money.png" alt="Specialfragt" /> } </div> <div class="item-footer-text text-right"> @if (hasDirectDelivery) { <img src="/Files/Templates/Designs/Hatting_KS_2013/img/truck.png" alt="Fragtmandslevering" /> } else if (onStock) { <span class="check-icon">&#10004;</span>@:På lager } </div> </a> } else { <div class="product-item-footer"></div> } </div> </div> </div> </div> } else { <div class="col-xs-6 col-md-3 product"> <div class="product-wrapper"> <div class="product-item-header"> <a href="@productLink"> @if (splashTypes.Offer) { <div class="circle-offer circle-offer-tilbud"> <span>Tilbud</span> </div> } @if (splashTypes.Discount) { <div class="circle-offer circle-offer-rabat"> <span>Mængde</span> <span>Rabat</span> </div> } <img class="prod-Image" src="@productImage" alt="" /> </a> </div> <div class="product-item-body"> <div class="item-body-title">@raptorProduct.GetString("Ecom:Product.Name")</div> @*<div class="item-body-color"> @foreach (LoopItem i2 in raptorProduct.GetLoop("VariantGroups")) { if (i2.GetString("Ecom:VariantGroup.Label") == "Farvekode Værdi") { <ul id="choosingcolors" class="cc-wrapper-product-list"> @foreach (LoopItem i3 in i2.GetLoop("VariantAvailableOptions")) { <li class="color-option"> <input type="radio" name="colors" class="var-color-option-chooser"> <label for="colors" class="productlist-colors" style="background-color:@i3.GetString("Ecom:VariantOption.Name")"></label> </li> } </ul> } } </div>*@ <div class="item-body-price"> @ShowPriceList(ecomProduct) </div> <div class="item-body-varenr">Varenr: @raptorProduct.GetString("Ecom:Product.Number")</div> </div> <div class="product-item-actions"> @if (raptorProduct.GetString("Ecom:Product.DefaultVariantComboID") == "" && variantLoopCounter <= 0) { if ((bool)notBuyable) { <a href="@productLink" class="btn-se-product text-center no-padding" style="padding-right: 0px;">Se produkt</a> } else { @*<a href="@productLink" class="btn-se-product">Se produkt</a>*@ <input type="number" name="amount" class="product-amount js-product-amount" value="1" /> <a href="#" data-class="overlay-add-to-basket" data-src="Files/Templates/Designs/Hatting_KS_2013/ajax-addtocart.html" onclick="addToCartlist(@raptorProduct.GetString("Ecom:Product.ID"), 1, '@raptorMethod', '@popupText', this), dataLayer.push({'ecomm_prodid':'@ecomProduct.ID','ecomm_pagetype':'raptormodule','ecomm_totalvalue':'@ecomProduct.Price.PriceWithVAT'});" class="btn btn-success btn-basket"> <span class="btn-basket-icon"></span> </a> } } else { <a href="@productLink" class="btn btn-success btn">Vælg variant</a> } </div> @{ var hasSpecialShipping = raptorProduct.GetString("Ecom:Product:Field.HasSpecialShipping") == "True"; var hasDirectDelivery = raptorProduct.GetBoolean("Ecom:Product:Field.DirectDelivery"); var onStock = raptorProduct.GetDouble("Ecom:Product.Stock") > 0; } @if (hasSpecialShipping || hasDirectDelivery || onStock) { <a class="product-item-footer" href="@symbolPageUrl"> <div class="item-footer-text text-left"> @if (hasSpecialShipping) { <img src="/Files/Templates/Designs/Hatting_KS_2013/img/money.png" alt="Specialfragt" /> } </div> <div class="item-footer-text text-right"> @if (hasDirectDelivery) { <img src="/Files/Templates/Designs/Hatting_KS_2013/img/truck.png" alt="Fragtmandslevering" /> } else if (onStock) { <span class="check-icon">&#10004;</span>@:På lager } </div> </a> } else { <div class="product-item-footer"></div> } </div> </div> } } } @using System.Web @using Application.CustomModules; @{ //NOTE!! All code below should be refactored into a ProductService / ProductViewModel if Hatting, at any time decides to upgrade or update the design on the webshop.. // There is some pretty good documentation regarding custom razor viewmodels in Dynamicweb - along with webapi/controllers etc // - mto@novicell.dk // Customer number var user = Pageview.User; bool isUserLoggedIn = user != null; var customerNumber = isUserLoggedIn ? user.CustomerNumber : ""; if (!TemplateHelper.RenderProduct(GetString("Ecom:Product:Field.AllowedCustomers"), customerNumber)) { HttpContext.Current.Response.Redirect("/"); } //Product information var product = Dynamicweb.eCommerce.Products.Product.GetProductByID(GetString("Ecom:Product.ID"), GetString("Ecom:Product.VariantID")); Dynamicweb.eCommerce.Products.Product variantProduct = null; var productMetaDescription = product.Meta.Description; var productMetaTitle = product.Meta.Title; int variantCount = GetInteger("Ecom:Product.VariantCount"); string variantComboId = GetString("Ecom:Product.DefaultVariantComboID"); var variantId = GetString("Ecom:Product.VariantID"); string curVarID = variantId; if (string.IsNullOrEmpty(curVarID)) { curVarID = product.VariantID; variantProduct = Dynamicweb.eCommerce.Products.Product.GetProductByID(GetString("Ecom:Product.ID"), curVarID); } curVarID = curVarID.Replace("#", "%23"); var productDeliveryTime = !string.IsNullOrEmpty(product.GetProductFieldValue("ExpectedDelivery").ToString()) ? product.GetProductFieldValue("ExpectedDelivery") : "1 dags levering"; string healtAuthorityLogo = !string.IsNullOrEmpty(product.GetProductFieldValue("Sundhedsstyrelsen").ToString()) ? product.GetProductFieldValue("Sundhedsstyrelsen").ToString() : string.Empty; string HealthAuthorotiesPictogram = !string.IsNullOrEmpty(product.GetProductFieldValue("SundhedsstyrelsensPictogram").ToString()) ? product.GetProductFieldValue("SundhedsstyrelsensPictogram").ToString() : string.Empty; string HealthAuthoritiesLink = !string.IsNullOrEmpty(product.GetProductFieldValue("LinkTilSundhedsstyrelsen").ToString()) ? product.GetProductFieldValue("LinkTilSundhedsstyrelsen").ToString() : string.Empty; string HealthPictogram = "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + HealthAuthorotiesPictogram + "&size1920x300&format=png"; string ProductAlternativeText = !string.IsNullOrEmpty(product.GetProductFieldValue("BilledeTekstSEO").ToString()) ? product.GetProductFieldValue("BilledeTekstSEO").ToString() : string.Empty; string ProductsAlternativeText = !string.IsNullOrEmpty(product.GetProductFieldValue("OevrigeBillederTekstSEO").ToString()) ? product.GetProductFieldValue("OevrigeBillederTekstSEO").ToString() : string.Empty; //var productImage = GetString("Ecom:Product.ID") + ".jpg"; var splashTypes = Splashes(product); var imageGuid = GetString("Ecom:Product:Field.ImageGuid"); string productImage = string.Empty; string productThumb = string.Empty; if (!string.IsNullOrEmpty(imageGuid)) { productImage = GetImagePath(imageGuid); productThumb = GetImageThumbPath(imageGuid); } var notBuyable = product.GetProductFieldValue("NotBuyable"); var youTubeLink = product.GetProductFieldValue("YoutubeLink").ToString(); //Details var details = GetLoop("Details"); //Product features Dictionary<string, string> productFeaturesDictionary = new Dictionary<string, string>(); var productFeaturesRaw = GetString("Ecom:Product:Field.ProductFeatures"); if (!string.IsNullOrEmpty(productFeaturesRaw)) { productFeaturesDictionary = ParseProductFeatures(productFeaturesRaw); } //Product files IEnumerable<string> brochureFilesList = !string.IsNullOrEmpty(GetString("Ecom:Product:Field.Brochure")) ? FetchFiles(GetString("Ecom:Product:Field.Brochure")) : Enumerable.Empty<string>(); IEnumerable<string> brugsanvisningerFilesList = !string.IsNullOrEmpty(GetString("Ecom:Product:Field.Brugsanvisninger")) ? FetchFiles(GetString("Ecom:Product:Field.Brugsanvisninger")) : Enumerable.Empty<string>(); IEnumerable<string> produktbladeFilesList = !string.IsNullOrEmpty(GetString("Ecom:Product:Field.Produktblade")) ? FetchFiles(GetString("Ecom:Product:Field.Produktblade")) : Enumerable.Empty<string>(); IEnumerable<string> sikkerhedsdatabladeFilesList = !string.IsNullOrEmpty(GetString("Ecom:Product:Field.Sikkerhedsdatablade")) ? FetchFiles(GetString("Ecom:Product:Field.Sikkerhedsdatablade")) : Enumerable.Empty<string>(); IEnumerable<string> skemaFilesList = !string.IsNullOrEmpty(GetString("Ecom:Product:Field.Skema")) ? FetchFiles(GetString("Ecom:Product:Field.Skema")) : Enumerable.Empty<string>(); //Variants var variants = GetLoop("VariantGroups"); //Spare parts var spareParts = GetLoop("ProductRelatedGroups").Where(e => e.GetString("Ecom:Product:RelatedGroup.Name") == "Reservedele og tilbehør"); //Raptor related products var similarItems = GetLoop("RaptorRecommendation:GetSimilarItems"); var relatedItems = GetLoop("RaptorRecommendation:GetRelatedItems_25-02-2019"); //Prices var hasAmountDiscount = HasAmountDiscount(product.Prices); var priceList = product.Prices.ToList(); //Static page id which is shared across qa and live. var freightLink = ""; //if(HttpContext.Current.Request.) var specialFreightLink = ""; if (HttpContext.Current.Request.Url.Host.Contains(".stagingsite.dk") || HttpContext.Current.Request.Url.Host.Contains(".ditnyewebsite.dk") || HttpContext.Current.Request.Url.Host.Contains(".local")) { specialFreightLink = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(7968); freightLink = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(7968); } else { freightLink = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(7968); specialFreightLink = Dynamicweb.Frontend.SearchEngineFriendlyURLs.GetFriendlyUrl(8753); <meta name="robots" content="index, follow"> } //Canonical url var canonicalUrl = GetProductCanonical(product.ID); //PopupCheck var popupText = CheckForPopupHelper(product); var userProduct = Dynamicweb.Modules.UserManagement.User.GetCurrentUser(); var disableRaptorSpecificUserProduct = false; if (userProduct != null) { var userRaptorFieldValue = userProduct.CustomFieldValues.Find(f => f.CustomField.SystemName == "AccessUser_DisableRaptor").Value.ToString(); if (userRaptorFieldValue == "False" || userRaptorFieldValue == null || userRaptorFieldValue.IsEmpty()) { disableRaptorSpecificUserProduct = false; } else { disableRaptorSpecificUserProduct = true; } } } @helper Truncate(string input, int length) { if (input.Length <= length) { @input } else { @input.Substring(0, length) } } @SnippetStart("metatags") <link rel="canonical" href="@canonicalUrl" /> @SnippetEnd("metatags") <div id="mobile-menu" class="visible-xs clearfix"> <div id="mobilenav" class="container mobile-submenu dwnavigation" settings="startlevel:3;endlevel:3;template:mobileecomnav.xslt;parentid:323;"> </div> </div> <!-- /MOBILE SIDE-MENU --> <div id="category-primary-content" class="category-primary-content"> <div class="product-list-container"> <div class="container single-product-breadcrumb"> @GetProductBreadcrumb(product, null) </div> </div> <div class="container spmain-container"> <div class="row"> <div class="col-sm-12 no-mobile"> <div class="single-product-wrapper"> <!-- --------------------- left box ------------------------ --> <div class="content-product left-side col-sm-6"> <meta name="description" content="@productMetaDescription" /> <meta title="@productMetaTitle" /> <div class="content-product-header"> <div class="content-product-header-item"> <h1 class="content-product-header-item links" style="font-weight: bolder">@GetString("Ecom:Product.Name") </h1> @*Customer wants similar look to item links, just bold*@ </div> <div class="content-product-header-item"> <p class="varenummer">Varenummer: @GetString("Ecom:Product.Number")</p> </div> <div class="content-product-header-item"> <p class="description"></p> </div> <div class="content-product-header-item links"> <a class="content-product-header-item-link" href="#description-specifications">Beskrivelse og specifikationer</a> @if (brochureFilesList.Any() || produktbladeFilesList.Any() || sikkerhedsdatabladeFilesList.Any() || skemaFilesList.Any() || brugsanvisningerFilesList.Any()) { <a class="content-product-header-item-link" href="#description-specifications">Download datablade</a> } </div> </div> <div class="content-product-sliderbox"> <div class="clearfixX"> @* If the product has one or more variants *@ @if (variantCount >= 1) { var currentUrl = HttpContext.Current.Request.Url; @* If the product url contains "variantid" *@ if (currentUrl.Query.Contains("VariantId")) { <ul class="image-gallery-variants gallery list-unstyled cS" style="height:auto;"> <li class="ls-item" data-teaser="" data-thumbicon="" data-thumb="@productThumb"> <div class="single-slide-area-item-box"> @if (splashTypes.HasSpecialShipping) { <span> <img src="/Files/Templates/Designs/Hatting_KS_2013/img/speciel_fragt.png" /> </span> } @if (splashTypes.Offer) { <span> <img src="/Files/Templates/Designs/Hatting_KS_2013/img/splash_tilbud.png" alt="tilbud" /> </span> } @if (splashTypes.Discount) { <span> <img src="/Files/Templates/Designs/Hatting_KS_2013/img/splash_maengderabat.png" alt="mænge rabat" /> </span> } </div> @if (!string.IsNullOrEmpty(productImage)) { <img src="@productImage" @(string.IsNullOrEmpty(ProductAlternativeText) ? "" : "alt=\"" + ProductAlternativeText + "\"") /> } </li> @foreach (var otherImgString in product.GetOtherImages()) { string otherImgThumb = "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + otherImgString + "&size=80x80&format=png"; string otherImgLarge = "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + otherImgString + "&size=540x400&format=png"; <li class="ls-item" data-teaser="" data-thumbicon="" data-thumb="@otherImgThumb"> <img src="@otherImgLarge" @(string.IsNullOrEmpty(ProductsAlternativeText) ? "" : "alt=\"" + ProductsAlternativeText + "\"") /> </li> } @if (!string.IsNullOrEmpty(youTubeLink)) { <li class="ls-item" data-teaser="" data-thumbicon="" data-thumb="/Files/Templates/Designs/Hatting_KS_2013/img/play.png"> <iframe class="youtube" width="100%" height="215" src="@youTubeLink" frameborder="0" allowfullscreen></iframe> </li> } </ul> } else { <ul class="image-gallery-variants gallery list-unstyled cS" style="height:auto;"> <li class="ls-item" data-teaser="" data-thumbicon="" data-thumb="@productThumb"> <div class="single-slide-area-item-box"> @if (splashTypes.HasSpecialShipping) { <span> <img src="/Files/Templates/Designs/Hatting_KS_2013/img/speciel_fragt.png" /> </span> } @if (splashTypes.Offer) { <span> <img src="/Files/Templates/Designs/Hatting_KS_2013/img/splash_tilbud.png" alt="tilbud" /> </span> } @if (splashTypes.Discount) { <span> <img src="/Files/Templates/Designs/Hatting_KS_2013/img/splash_maengderabat.png" alt="mænge rabat" /> </span> } </div> @if (!string.IsNullOrEmpty(productImage)) { <img src="@productImage" @(string.IsNullOrEmpty(ProductAlternativeText) ? "" : "alt=\"" + ProductAlternativeText + "\"") /> } </li> @foreach (var otherImgString in product.GetOtherImages()) { string otherImgThumb = "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + otherImgString + "&size=80x80&format=png"; string otherImgLarge = "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + otherImgString + "&size=540x400&format=png"; <li class="ls-item" data-teaser="" data-thumbicon="" data-thumb="@otherImgThumb"> <img src="@otherImgLarge" @(string.IsNullOrEmpty(ProductsAlternativeText) ? "" : "alt=\"" + ProductsAlternativeText + "\"") /> </li> } @if (!string.IsNullOrEmpty(youTubeLink)) { <li class="ls-item" data-teaser="" data-thumbicon="" data-thumb="/Files/Templates/Designs/Hatting_KS_2013/img/play.png"> <iframe class="youtube" width="100%" height="215" src="@youTubeLink" frameborder="0" allowfullscreen></iframe> </li> } </ul> } } else { <ul id="image-gallery" class="image-gallery gallery list-unstyled cS" style="height:auto;"> <!--data-thumb is for the images in the thumbnails the img holder is for the slide with a predifined size of 540px(width) x 400px(height), if there not image a default empty will appear instead --> <li class="ls-item" data-teaser="" data-thumbicon="" data-thumb="@productThumb"> <div class="single-slide-area-item-box"> @if (splashTypes.HasSpecialShipping) { <span> <img src="/Files/Templates/Designs/Hatting_KS_2013/img/speciel_fragt.png" /> </span> } @if (splashTypes.Offer) { <span> <img src="/Files/Templates/Designs/Hatting_KS_2013/img/splash_tilbud.png" alt="tilbud" /> </span> } @if (splashTypes.Discount) { <span> <img src="/Files/Templates/Designs/Hatting_KS_2013/img/splash_maengderabat.png" alt="mænge rabat" /> </span> } </div> @if (!string.IsNullOrEmpty(productImage)) { <img src="@productImage" @(string.IsNullOrEmpty(ProductAlternativeText) ? "" : "alt=\"" + ProductAlternativeText + "\"") /> } </li> @foreach (var otherImgString in product.GetOtherImages()) { if (!string.IsNullOrEmpty(otherImgString)) { string otherImgThumb = "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + otherImgString + "&size=80x80&format=png"; string otherImgLarge = "https://perfionapi.hattingagro.dk/Perfion/Image.aspx?id=" + otherImgString + "&size=540x400&format=png"; <li class="ls-item" data-teaser="" data-thumbicon="" data-thumb="@otherImgThumb"> <img src="@otherImgLarge" @(string.IsNullOrEmpty(ProductsAlternativeText) ? "" : "alt=\"" + ProductsAlternativeText + "\"") /> </li> } } @if (!string.IsNullOrEmpty(youTubeLink)) { <li class="ls-item" data-teaser="" data-thumbicon="" data-thumb="/Files/Templates/Designs/Hatting_KS_2013/img/play.png"> <iframe class="youtube" width="100%" height="215" src="@youTubeLink" frameborder="0" allowfullscreen></iframe> </li> } </ul> } </div> <!--side left slider single page--> </div> </div> <!-- --------------------- right box ------------------------ --> <div class="content-product right-side col-sm-6"> <div class="box-basket basket-options part1"> <div class="box-basket-body"> <div class="priser-box"> <input id="singleProductId" type="hidden" value="@product.ID" /> @ShowPriceDetail(product) </div> <div style="display:none;" id="productid">@GetString("Ecom:Product.ID")</div> <select id="VariantChooser@(GetValue("Ecom:Product.ID"))" name="VariantID" class="VariantID" style="position:fixed;left:-3333px;"> @foreach (LoopItem i in GetLoop("VariantCombinations")) { var VarientPrice = ""; if (Dynamicweb.Modules.UserManagement.User.GetCurrentUserID() > 0) { VarientPrice = string.Format("{0:0.00}", i.GetDouble("Ecom:Product.Price.PriceWithoutVAT")); } else { VarientPrice = string.Format("{0:0.00}", i.GetDouble("Ecom:Product.Price.PriceWithVAT")); } var Checked = ""; if (GetString("Ecom:Product.SelectedVariantComboID") == i.GetString("Ecom:VariantCombination.VariantID")) { Checked = "checked='checked'"; } <option @Checked data-images="@i.GetString("Ecom:Product:Field.ImageGuid")" data-pnumber="@i.GetValue("Ecom:Product.Number")" data-pname='@i.GetValue("Ecom:Product.Name")' before-price="@getVariantBeforePrice(i.GetString("Ecom:Product.Number"))" data-pdesc='@i.GetValue("Ecom:Product.LongDescription")' data-price="@(VarientPrice)" value="@i.GetValue("Ecom:VariantCombination.VariantID")">@i.GetValue("Ecom:VariantCombination.VariantID")</option> } </select> @* -------------------------- changes here*@ @* end ---------------------- changes here*@ @foreach (var variant in variants) { if (variant.GetString("Ecom:VariantGroup.Label") == "Farvekode Værdi") { <form class="choosingcolor"> <div class="txt__colors">@Translate("Vaelgfarve", "Vælg farve")</div> <ul id="choosingcolors" class="cc-wrapper variant-option"> <div class="radioColorblock"> @foreach (var color in variant.GetLoop("VariantAvailableOptions")) { var selected = ""; var addClass = ""; if (GetString("Ecom:Product.SelectedVariantComboID").Contains(color.GetString("Ecom:VariantOption.ID")) && !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["VariantId"])) { selected = "data-selected='true' checked"; addClass = "class='isActive'"; } // size.color @*<div class="radio radioColorblock__item"> <label> <input type="radio" id="@color.GetString("Ecom:VariantOption.ID")" name="colors" data-colorid="@color.GetString("Ecom:VariantOption.ID")" class="var-color-option-chooser" value="@color.GetString("Ecom:VariantOption.Name")"> @color.GetString("Ecom:VariantOption.Name") </label> </div>*@ @*<span>@color.GetString("Ecom:VariantOption.Name")</span>*@ <li class="color-option"> <input type="radio" id="@color.GetString("Ecom:VariantOption.ID")" name="colors" data-colorid="@color.GetString("Ecom:VariantOption.ID")" class="var-color-option-chooser" value="@color.GetString("Ecom:VariantOption.ID")" @selected> <label for="colors" @addClass style="background-color:@color.GetString("Ecom:VariantOption.Name")"></label> </li> } </div> @*@foreach (var color in variant.GetLoop("VariantAvailableOptions")) { <li class="color-option"> <input type="radio" id="@color.GetString("Ecom:VariantOption.ID")" name="colors" data-colorid="@color.GetString("Ecom:VariantOption.ID")" class="var-color-option-chooser" value="blue"> <label for="colors" class="blue" style="background-color:@color.GetString("Ecom:VariantOption.Name")"></label> </li> }*@ @*<li class="color-option"> <input type="radio" name="colors" class="var-color-option-chooser" value="blue"> <label for="colors" class="blue"></label> </li> <li class="color-option"> <input type="radio" name="colors" class="var-color-option-chooser" value="red"> <label for="colors" class="red"></label> </li> <li class="color-option"> <input type="radio" name="colors" class="var-color-option-chooser" value="black"> <label for="colors" class="black"></label> </li>*@ </ul> </form> } } @foreach (var variant in variants) { if (variant.GetString("Ecom:VariantGroup.Label") != "Farvekode Værdi") { //todo: fix styling issues on variants with 32-34 e.g. (happens on socks) <form class="form-row"> <div class="txt__size">Vælg @variant.GetString("Ecom:VariantGroup.Label")</div> <ul id="variant-size" class="option-wrapper variant-option"> @foreach (var size in variant.GetLoop("VariantAvailableOptions")) { var variantProperties = size.GetLoop("VariantGroupProperties"); var variantMeasurement = string.Empty; if (variantProperties.Any()) { foreach (var measurement in variantProperties) { variantMeasurement = measurement.GetString("Ecom:VariantGroupProperty.Value"); } } var selected = ""; var addClass = ""; if (GetString("Ecom:Product.SelectedVariantComboID").Contains(size.GetString("Ecom:VariantOption.ID")) && !string.IsNullOrEmpty(HttpContext.Current.Request.QueryString["VariantId"])) { selected = "checked='checked' data-selected='true'"; addClass = "isActive"; } <li class="option option-square"> <input type="radio" onclick="disableBasketBtn();" @selected id="@size.GetString("Ecom:VariantOption.ID")" data-sizeid="@size.GetString("Ecom:VariantOption.ID")" name="SV" class="var-option-chooser" value="@size.GetString("Ecom:VariantOption.Name")"> <label for="SV" class="is-disabled @addClass">@size.GetString("Ecom:VariantOption.Name") @variantMeasurement</label> @*<span class="tool__option">@size.GetString("Ecom:VariantOption.Name") @variantMeasurement </span>*@ </li> } </ul> </form> } } </div> </div> <div class="box-basket basket-options part2"> <!--yellow area--> @*<div class="du-far-ogsa"> <div class="dfo-item"> <p>Du får også</p> </div> <div class="dfo-item"> <div class="radio radio-simple"> <label> Rensekit til boltpistol blits <span>( gratis )</span> </label> <a href="#" class="dfo-link pull-right">Se product</a> </div> <div class="radio"> <label> <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1" checked> Rensekit til boltpistol blits <span>( gratis )</span> </label> <a href="#" class="dfo-link pull-right">Se product</a> </div> <div class="radio"> <label> <input type="radio" name="optionsRadios" id="optionsRadios1" value="option1"> T-shirt rib granddad <span>( gratis )</span> </label> <a href="#" class="dfo-link pull-right">Se product</a> </div> </div> </div>*@ <!-- END yellow area--> <div class="box-basket-body"> <div class="add2basket-area"> <div class="box"> <div class="box-item box-item-input"> <input class="form-control boxinput" type="text" name="french-hens" id="boxinput" value="1" placeholder="1"> </div> <div class="box-item box-item-btn"> <button class="inc button">+</button> <button class="dec button">-</button> </div> </div> <div class="box"> @if ((bool)notBuyable) { <button type="submit" id="laegIkurv" class="input-form-btn btn btn-danger">Kan ikke købes online</button> } else { if (GetInteger("Ecom:Product:Field.MinimumOrderQuantity.Value.Clean") > 0) { <button type="submit" id="laegIkurv" class="input-form-btn btn btn-success" onclick="addToCartminimumquantity(@GetString("Ecom:Product.ID")), dataLayer.push({'ecomm_prodid':'@product.ID','ecomm_pagetype':'product','ecomm_totalvalue':'@product.Price.PriceWithVAT'});"> <span class="big-basket-icon"></span> Læg i kurv </button> } else { <button type="submit" id="laegIkurv" class="input-form-btn btn btn-success" onclick="addToCartN(false, 0, '@popupText'), dataLayer.push({'ecomm_prodid':'@product.ID','ecomm_pagetype':'product','ecomm_totalvalue':'@product.Price.PriceWithVAT'});"> <span class="big-basket-icon"></span> Læg i kurv </button> } } </div> </div> <div class="shipping-info"> @* Removal of default shipping text if product has speciel shipping*@ @if (splashTypes.HasSpecialShipping) { <div class="shipping-info-item fragt"> <div class="shipping-info-fragt-container"> <span class="shipping-bus-icon"></span> <span class="first"><a style="text-decoration: underline" href="@specialFreightLink "> Se fragtpriser</a></span> </div> </div> } else { <div class="shipping-info-item fragt"> <div class="shipping-info-fragt-container"> <span class="shipping-bus-icon"></span> <span class="first">Fragt fra kr. 170,-</span> <span class="second"><a href="@freightLink ">Se fragtpriser</a></span> </div> </div> } <div class="shipping-info-item levering"> <span class="shipping-timer-icon"></span> <span class="first">@productDeliveryTime</span> </div> @if (Dynamicweb.Modules.UserManagement.User.GetCurrentUserID() > 0) { <div class="shipping-info-item favorite"> @if (GetBoolean("Ecom:Product.IsProductInFavoriteList")) { <span class="star-icon"></span> <span class="first"><a href="@GetString("Ecom:Product.RemoveFromFavorites")">Fjern som favorit</a></span> } else { <span class="star-icon"></span> <span class="first"><a href="@GetString("Ecom:Product.AddToFavorites")">Tilføj som favorit</a></span> } </div> } </div> </div> <div class="box-basket-footer"> <div class="table-wrapper table-responsive"> @if (hasAmountDiscount && !(bool)product.GetProductFieldValue("hideprice")) { var discounts = GetDiscounts(product.Prices.ToList()); <p>Køb flere og spar</p> <table class="table" id="discount-table"> <thead> <tr> <th>Antal</th> <th>Pris pr. stk.</th> <th>Rabat pr. stk.</th> <th>Samlet rabat</th> <th></th> </tr> </thead> <tbody> @foreach (var discount in discounts) { string displayStyle = string.Empty; if (discount.VariantId != curVarID && !string.IsNullOrEmpty(discount.VariantId)) { displayStyle = "display:none;"; } <tr style='@displayStyle'> <td>@discount.Quantity</td> <td>DKK. @string.Format("{0:0.00}", discount.UnitPrice)</td> <td>DKK. @string.Format("{0:0.00}", discount.UnitDiscount)</td> <td>DKK. @string.Format("{0:0.00}", discount.TotalDiscount)</td> <td> <button class="btn btn-success btn-add-basket" href="#" onclick="addToCartN(discountPressed = true, discountQuantity = @discount.Quantity, '@popupText'), dataLayer.push({'ecomm_prodid':'@product.ID','ecomm_pagetype':'productlist','ecomm_totalvalue':'@product.Price.PriceWithVAT'});"> <span class="btn-basket-icon"></span> </button> </td> </tr> } </tbody> </table> } </div> @{ string datasheet = @GetString("Ecom:Product:Field.EcoOnlineDataSheet"); string signalWord = GetString("Ecom:Product:Field.EcoOnlineSignalWord"); string pictograms = GetString("Ecom:Product:Field.EcoOnlinePictograms"); } @{ if (!string.IsNullOrWhiteSpace(signalWord)) { <h4>@signalWord</h4> } } <ul> @{foreach (string statement in GetString("Ecom:Product:Field.EcoOnlineHazardStatement").Split(';')) { if (!string.IsNullOrWhiteSpace(statement)) { <li> @statement.Replace(";", "").Trim() </li> } } } @{ if (!string.IsNullOrWhiteSpace(datasheet)) { <a href="@datasheet&action=save">Download sikkerhedsdatablad</a> } } </ul> @{ if (!string.IsNullOrWhiteSpace(pictograms)) { if (pictograms.Contains(';')) { foreach (string link in pictograms.Split(';')) { <img style="height:75px;width:75px" src="@link.Replace(";", "").Trim()"> } } else { <img style="height:100px;width:100px" src="@pictograms"> } } } </div> </div> @if (spareParts.Any()) { <div class="box-basket reservedele"> <div class="table-wrapper-reservedele table-responsive"> <p>Reservedele og tilbehør</p> <table class="table"> <thead> <tr> <th></th> <th></th> <th></th> <th></th> </tr> </thead> <tbody> @foreach (var sp in spareParts) { foreach (var sparePartProduct in sp.GetLoop("Products")) { var sparePartEcomProduct = Dynamicweb.eCommerce.Products.Product.GetProductByID(sparePartProduct.GetString("Ecom:Product.ID")); var sparePartImageGuid = sparePartProduct.GetString("Ecom:Product:Field.ImageGuid"); var sparePartImage = GetImageSmallThumbPath(sparePartImageGuid); var sparePartNotBuyable = sparePartEcomProduct.GetProductFieldValue("NotBuyable"); <tr> <td class="table-small-img"> <img class="table-small-img" src="@sparePartImage" alt="" /> </td> <td class="table-small-info"> <span>@sparePartProduct.GetString("Ecom:Product.Name") - @sparePartProduct.GetString("Ecom:Product.Number")</span> </td> <td class="table-small-price">@product.Price.Currency.Code @string.Format("{0:0.00}", GetPrice(sparePartEcomProduct))</td> <td> <div class="table-action-btns"> <form id="form-@sparePartProduct.GetString("Ecom:Product.ID")" method="post" class="" style="display:flex"> <input id="@sparePartProduct.GetString("Ecom:Product.ID")" class="form-control" type="text" value="1" placeholder="1" /> @{ string valueid = "#" + sparePartProduct.GetString("Ecom:Product.ID");} @if ((bool)sparePartNotBuyable) { <button type="submit" id="laegIkurv" class="btn btn-success btn-add-basket">X</button> } else { <button class="btn btn-success btn-add-basket" onclick="addReservedeleTilbehoor('@sparePartProduct.GetString("Ecom:Product.ID")&VariantID=@sparePartProduct.GetString("Ecom:Product.VariantID")', $('@valueid').val(), event )"> <span class="btn-basket-icon"></span> </button> } </form> </div> </td> </tr> } } </tbody> </table> @*<a href="#"> <div class="span-showme-more"></div> </a>*@ </div> </div> } @if (!string.IsNullOrEmpty(healtAuthorityLogo)) { <div class="box-basket"> <div class="box-basket-footer"> <a href="@HealthAuthoritiesLink" target="_blank"> <img src="@HealthPictogram" /> </a> </div> </div> } </div> </div> </div> </div> </div> <hr class="prodList md-hidden" /> <div class="divider-page"></div> <div class="row"> <div class="container product-list-container-bottom" id="description-specifications"> <div class="col-sm-6 col-xs-12 description-left"> <h2>Beskrivelse og specifikationer</h2> <span id="LongDescription">@GetString("Ecom:Product.LongDescription")</span> </div> <div class="col-sm-6 col-xs-12 description-right"> <div class="description-right-item"> @*<div class="desc-item"> <span>varenummer</span> <span>@GetString("Ecom:Product.ID")</span> </div>*@ @if (productFeaturesDictionary.Any()) { foreach (var productFeature in productFeaturesDictionary) { <div class="desc-item"> @if (productFeature.Key == "Antal stk. pr. colli") { <span>Pakkestørrelse</span> <span>@productFeature.Value @GetString("Ecom:Product:Field.ColliUnit")</span> } else { <span>@productFeature.Key</span> <span>@productFeature.Value</span> } </div> } } </div> <div class="description-right-item"> @if (brochureFilesList.Any() || produktbladeFilesList.Any() || sikkerhedsdatabladeFilesList.Any() || skemaFilesList.Any() || brugsanvisningerFilesList.Any()) { <div class="title">Download datablade</div> <div class="link-list"> <ul> @foreach (var file in brochureFilesList) { <li> <a href="https://perfionapi.hattingagro.dk/Perfion/File.aspx?id=@file&action=save">Download brochure</a> </li> } @foreach (string file in produktbladeFilesList) { <li> <a href="https://perfionapi.hattingagro.dk/Perfion/File.aspx?id=@file&action=save">Download produktblade</a> </li> } @foreach (string file in skemaFilesList) { <li> <a href="https://perfionapi.hattingagro.dk/Perfion/File.aspx?id=@file&action=save">Download skema</a> </li> } @foreach (string file in brugsanvisningerFilesList) { <li> <a href="https://perfionapi.hattingagro.dk/Perfion/File.aspx?id=@file&action=save">Download brugsanvisning</a> </li> } </ul> </div> } </div> </div> </div> </div> <div class="bottom-container"> <div class="container"> @if (disableRaptorSpecificUserProduct == false && similarItems.Any()) { <div class="row"> <div class="slider-title"> <h2>Lignende varer</h2> </div> <div class="bc-slider-controllers-left"> <button type="button" id="sp-snextFirst" class="bc-btnleft"> <span class="icbtn"></span> </button> </div> <div class="bc-slider-controllers-right"> <button type="button" id="sp-sprevFirst" class="bc-btnright"> <span class="icbtn"></span> </button> </div> <div class="owl-carousel-singleProduct owl-theme first-owl"> @RenderRaptorModule(similarItems, "GetSimilarItems") </div> </div> } @if (disableRaptorSpecificUserProduct == false && relatedItems.Any()) { <div class="row"> <div class="slider-title"> <h2>Andre har også købt</h2> </div> <div class="bc-slider-controllers-left"> <button type="button" id="sp-snextSecond" class="bc-btnleft"> <span class="icbtn"></span> </button> </div> <div class="bc-slider-controllers-right"> <button type="button" id="sp-sprevSecond" class="bc-btnright"> <span class="icbtn"></span> </button> </div> <div class="owl-carousel-singleProduct owl-theme second-owl"> @RenderRaptorModule(relatedItems, "GetRelatedItems_25-02-2019") </div> </div> } </div> </div> <script> $(document).ready(function () { $(".button").on("click", function () { var $button = $(this); var oldValue = $("#boxinput").val(); if ($button.text() === "+") { var newVal = parseFloat(oldValue) + 1; } else { // Don't allow decrementing below zero if (oldValue > 0) { var newVal = parseFloat(oldValue) - 1; } else { newVal = 0; } } $("#boxinput").val(newVal); }); }); </script> <script> var basketBtn = document.getElementById("laegIkurv"); window.onload = basketBtn.removeAttribute("disabled", "disabled"); function disableBasketBtn() { basketBtn.setAttribute("disabled", "disabled"); //setTimeout(function () { // enableBasketBtn(); //}, 1500); } function enableBasketBtn() { basketBtn.removeAttribute("disabled", "disabled"); } window.onload = startSliderVariants(); </script> @SnippetStart("Datalayer") <script> ecomm_pagetype = "Product"; ecomm_totalvalue = @GetString("Ecom:Product.Price.Price").Replace(".","").Replace(",","."); ecomm_prodid = "@GetString("Ecom:Product.ID")"; </script> @SnippetEnd("Datalayer") @{ var userRaptorModal = Dynamicweb.Modules.UserManagement.User.GetCurrentUser(); var disableRaptorSpecificUserModal = false; if (userRaptorModal != null) { var userRaptorFieldValue = userRaptorModal.CustomFieldValues.Find(f => f.CustomField.SystemName == "AccessUser_DisableRaptor").Value.ToString(); if (userRaptorFieldValue == "False" || userRaptorFieldValue == null || userRaptorFieldValue.IsEmpty()) { disableRaptorSpecificUserModal = false; } else { disableRaptorSpecificUserModal = true; } } } <div>@{ var getCookieRecommendationsModal = GetLoop("RaptorRecommendation:GetCookieRecommendations"); }</div> <div id="addProductModal" class="modal fade" tabindex="-1"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <img src="/admin/public/getimage.ashx?Image=/files/templates/designs/hatting_ks_2013/img/checkmark.png&amp;crop=5&amp;Resolution=72&amp;Compression=80&amp;Height=30&amp;Width=30" style="margin-bottom:5px" /> <h3 class="modal-title">Produktet er tilføjet til din kurv</h3> </div> </div> </div> </div> <div id="addProductModalPS" class="modal fade" tabindex="-1" style="z-index: 10000"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header" style="text-align: center"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> <img src="/admin/public/getimage.ashx?Image=/files/templates/designs/hatting_ks_2013/img/checkmark.png&amp;crop=5&amp;Resolution=72&amp;Compression=80&amp;Height=30&amp;Width=30" style="margin-bottom: 5px" /> <h3 class="modal-title">Produktet er tilføjet til din kurv</h3> </div> @if (disableRaptorSpecificUserModal == false) { <div class="modal-body"> <div class="row heading"> <h3 style="text-align: center">Vi tror også du vil kunne lide</h3> </div> <div class="product-list-block"> <div class="product-block-container"> @RenderRaptorModule(getCookieRecommendationsModal, "GetCookieRecommendations", 4) </div> </div> </div> } </div> </div> </div> <div id="quantityselectorpopup" class="modal fade" tabindex="-1" style="z-index: 10000"> <div class="modal-dialog" style="width:890px;"> <div class="modal-content"> <div class="modal-header" style="text-align: center"> <button type="button" class="close" data-dismiss="modal" aria-label="Close"> <span aria-hidden="true">&times;</span> </button> <img src="/admin/public/getimage.ashx?Image=/files/templates/designs/hatting_ks_2013/img/checkmark.png&amp;crop=5&amp;Resolution=72&amp;Compression=80&amp;Height=30&amp;Width=30" style="margin-bottom: 5px" /> <h3 class="modal-title">Denne vare kan kun bestilles i antallet:</h3> </div> <div class="modal-body"> <div class="product-list-block"> <div class="product-block-container"> </div> </div> </div> </div> </div> </div> </div>