Exception in template (Designs\TasteTest\eCom/Product/TOTProduct.cshtml): System.InvalidOperationException: Sequence contains no elements
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at CompiledRazorTemplates.Dynamic.efbbaaadaa.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()
@using System.Text.RegularExpressions @using System.Web @using System.Globalization; @using System.Web.Helpers; @functions{ public class ProducerItem{ public int Id {get;set;} public string Url {get;set;} public string Logo {get;set;} public string Name {get;set;} } public class WrapMethods { //Gets the contrasting color public static string getContrastYIQ(string hexcolor) { if (hexcolor != "") { hexcolor = Regex.Replace(hexcolor, "[^0-9a-zA-Z]+", ""); int r = Convert.ToByte(hexcolor.Substring(0, 2), 16); int g = Convert.ToByte(hexcolor.Substring(2, 2), 16); int b = Convert.ToByte(hexcolor.Substring(4, 2), 16); int yiq = ((r * 299) + (g * 587) + (b * 114)) / 1000; if (yiq >= 128) { return "black"; } else { return "white"; } } else { return "black"; } } //Truncate text public static string Truncate (string value, int count, bool strip=true) { if (strip == true){ value = StripHtmlTagByCharArray(value); } if (value.Length > count) { value = value.Substring(0, count - 1) + "..."; } return value; } //Strip text from HTML public static string StripHtmlTagByCharArray(string htmlString) { char[] array = new char[htmlString.Length]; int arrayIndex = 0; bool inside = false; for (int i = 0; i < htmlString.Length; i++) { char let = htmlString[i]; if (let == '<') { inside = true; continue; } if (let == '>') { inside = false; continue; } if (!inside) { array[arrayIndex] = let; arrayIndex++; } } return new string(array, 0, arrayIndex); } //Make the correct count of columns public static string ColumnMaker(int Col, string ScreenSize) { string Columns = ""; switch (Col) { case 1: Columns = "col-"+ScreenSize+"-12"; break; case 2: Columns = "col-"+ScreenSize+"-6"; break; case 3: Columns = "col-"+ScreenSize+"-4"; break; case 4: Columns = "col-"+ScreenSize+"-3"; break; case 6: Columns = "col-"+ScreenSize+"-2"; break; default: Columns = "col-"+ScreenSize+"-3"; break; } return Columns; } public static string FirstLetterToUpper(string text) { return CultureInfo.CurrentCulture.TextInfo.ToTitleCase(text.ToLower()); } private string Custom(string firstoption, string secondoption) { if (firstoption == "custom") { return secondoption; } else { return firstoption; } } } } @using Dynamicweb.Modules.Common.CustomFields @using Dynamicweb.Modules.UserManagement <style> .ribbon.base::before { border-top: 27px solid #BF3E38 !important; } .ribbon.base::after { border-bottom: 27px solid #BF3E38 !important; } .text_info { color: #BF3E38; } .ribbon.base { background: #BF3E38 !important; border-left:#BF3E38 !important; font-size:10px; } strong { font-weight:bold; } .product-country{ font-size:12px; } </style> @helper GetProductList(dynamic Loop,int ColMD = 3, int ColSM = 6, int ColXS = 1) { int Count = 0; string ColumnsMD = WrapMethods.ColumnMaker(ColMD, "md"); string ColumnsSM = WrapMethods.ColumnMaker(ColSM, "sm"); string ColumnsXS = WrapMethods.ColumnMaker(ColXS, "xs"); string usergroups = GetGlobalValue("Global:Extranet.Groups"); bool b2b = false; bool staff = false; if(!string.IsNullOrEmpty(usergroups)) { List<string> usergrouplist = new List<string>(usergroups.Split(',')); if(usergrouplist.Count>0) { foreach(var group in usergrouplist) { if(Convert.ToInt32(group) == 5) { b2b = true; break; } } } } if (Dynamicweb.Input.FormatBoolean(GetGlobalValue("Global:Extranet.UserName"))) { int i = Convert.ToInt32(GetGlobalValue("Global:Extranet.UserID")); Dynamicweb.Modules.UserManagement.User u = Dynamicweb.Modules.UserManagement.User.GetUserByID(i); foreach (CustomFieldValue val in u.CustomFieldValues) { CustomField field = val.CustomField; string fieldValue = (val.Value).ToString(); string ff=field.Name; if(fieldValue=="Staff") { staff = true; } } } foreach (LoopItem product in Loop) { string Image = product.GetString("Ecom:Product.ImageSmall.Default.Clean"); string GroupLink = product.GetString("Ecom:Product.LinkGroup.Clean"); string wineRating = ""; string Active = product.GetString("Ecom:Product.IsActive"); string Name = product.GetString("Ecom:Product:Field.ProductName2"); string Offer = product.GetString("Ecom:Product:Field.ProductOffer"); string Hidden = ""; string Brand = product.GetString("Ecom:Product:Field.ProductItemGroup"); string Description = product.GetString("Ecom:Product.ShortDescription"); string Discount = product.GetString("Ecom:Product.Discount.Price"); string Price = product.GetString("Ecom:Product.Price"); string Vintage = ""; string country = product.GetString("Ecom:Product:Field.ProductCountryOfOrigin"); string region = WrapMethods.FirstLetterToUpper(product.GetString("Ecom:Product:Field.ProductRegionOfOrigin")); string subregion = WrapMethods.FirstLetterToUpper(product.GetString("Ecom:Product:Field.ProductSubRegionOfOrigin")); string wineStyle = product.GetString("Ecom:Product:Field.ProductWineStyle").Replace("-c-", ","); var pid = product.GetString("Ecom:Product.ID"); var ProductFormClean = product.GetValue("Ecom:Product.Form.Clean"); string favLink = product.GetString("Ecom:Product.AddToFavorites").Replace("/Default.aspx?/Default.aspx/Default.aspx/Default.aspx", "/Default.aspx?ID=38"); string volume = product.GetString("Ecom:Product:Field.ProductVolumeML") + "ml"; double Stock = product.GetDouble("Ecom:Product.Stock"); //DateTime ArrivalDate = (product.GetValue("Ecom:Product:Field.ProductArrivalDate") != null) ? DateTime.MinValue : (DateTime)product.GetValue("Ecom:Product:Field.ProductArrivalDate"); if(@GetString("Ecom:ProductList:Page.ID")=="496") { GroupLink = GroupLink.Replace("ID=496","ID=512"); } if (!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product:Field.ProductWineRating1"))) { wineRating = product.GetString("Ecom:Product:Field.ProductWineRating1")+" Points"; } if("Pre-arrival offer" == @Offer){ Hidden = "hidden"; } if (!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product:Field.ProductVintage"))) { Vintage = product.GetString("Ecom:Product:Field.ProductVintage").Replace("NV", ""); } wineStyle = wineStyle.Replace("-a-", "&amp;"); Brand = Brand.Replace("-a-", "&amp;").Replace("-c-", ",").Replace("-s-", "'"); <script> @if(b2b) { <text> function revealprice(id) { document.getElementById("priceperbottlelabel"+id).removeAttribute("hidden"); document.getElementById("priceperbottle"+id).removeAttribute("hidden"); } function hideprice(id) { document.getElementById("priceperbottlelabel"+id).setAttribute("hidden",""); document.getElementById("priceperbottle"+id).setAttribute("hidden",""); } </text> } </script> <script type="text/javascript"> function newPrice(price1, id) { var pricelist = price1.split('|'); @if(b2b) { <text> document.getElementById(id).innerHTML ="$"+parseFloat(Math.round(pricelist[1] * 100) / 100).toFixed(2); </text> } else { <text> document.getElementById("online"+id).innerHTML = "$"+parseFloat(Math.round(pricelist[1] * 100) / 100).toFixed(2); </text> } @if(b2b) { <text> document.getElementById("trade"+id).innerHTML="$"+parseFloat(Math.round(pricelist[0] * 100) / 100).toFixed(2); document.getElementById("priceperbottle"+id).innerHTML = "$"+ Math.round(parseFloat(pricelist[6]) * 100.0) / 100.0; </text> } } </script> <div class="productlist @ColumnsMD col-sm-6 @ColumnsXS" style="min-height:250px;margin-bottom:15px;"> <div class="boxproduct wp-block product" style="padding:15px 10px;float:left;width:100%;"> <div class="listproductright"> <a href="@GroupLink" title="@Name"> <figure style="border-bottom: 1px solid #E0EDED;" class="productfigure"> <img class="rotate90" alt="" src="/Admin/Public/Getimage.ashx?width=180&amp;height=180&amp;compression=85&amp;Crop=5&amp;image=@Image" /> </figure> </a> </div> <div> <p hidden id="discountFlag@(pid)" class="ribbon base"> <span> Buy @product.GetString("MinimumQuantity") get </span> <span> @product.GetString("Percentage") % discount. </span> </p> </div> <div class="extracolumn listproductleft wp-block-footer" style="min-height: 200px;"> <div name="productDes" id="productDes"> <span class="product-title" style="font-size:12px;"> <a href="@GroupLink"> <span class="product-brand"> @Brand </span><br /> <span class="product-name"> @Name @Vintage</span> </a> </span> <br/> <span class="product-country"> @country - @region @if(@subregion!="-"){ <text>- @subregion </text>}</span> <br/> <div name="longdescription"> <span hidden name="longdes"> @WrapMethods.Truncate(@product.GetString("Ecom:Product.LongDescription"),150).Replace("...","_") <a href="@GroupLink"><b>&nbsp;read more...</b></a> </span> <br/> <span name="winestyles" class="sub_title"> @wineStyle ( @volume.Replace(",","") ) </span> </div> </div> @{ var priceid = "price" + pid; } <div class="sub_title1"> @if(b2b) { <span class="productprice price"><strong id='@pid'></strong></span> } else { <span class="productprice price"><strong id='online@(pid)'></strong></span> } <span>&nbsp;(incl. GST)</span> <br/> @if (Discount != Price) { if(b2b) { <text>Trade Price:</text> } <span class="productprice price"><strong>@Discount</strong></span><span>&nbsp;(incl. GST)</span> <span class="productoldprice price " style="margin-top: 0px !important; padding-top: 0px !important;position: absolute; text-decoration: line-through;">( @Price )</span> } else { if(b2b) { if(!staff) { <text>Trade Price:</text> } else { <text>Staff Price:</text> } <span class="productprice price sub_notitle error"><span id="trade@(pid)"></span></span> <span>&nbsp;(excl. GST)</span> <p style="margin:0px"> <text id="priceperbottlelabel@(pid)" hidden>Price per bottle:</text> <span class="productprice price"><strong hidden id='priceperbottle@(pid)'></strong></span> </p> } } </div> <p id="winerating"> <span name="winestyles" class="sub_title">@wineRating</span> </p> </div> @if (Discount != Price) { <span class="ribbon base">@Translate("On sale!", "On sale!")</span> @*if (@Pageview.Area.Item["EcommerceStickerType"].ToString() == "ribbon") { <span class="ribbon base">@Translate("On sale!", "On sale!")</span> } if (@Pageview.Area.Item["EcommerceStickerType"].ToString() == "ball") { <span class="ball">@Translate("On sale!", "On sale!")</span> }*@ } <div class="addtocart" style="min-height:105px;border-top:1px solid #BBBBBB;"> @{ var discountPString =""; var discountslist = new List<String>(); var quantitylist = new List<String>(); var stockRelation =""; var stockPString = ""; var stocklist = new List<int>(); if(!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product:Field.ProductDiscount"))) { discountPString = product.GetString("Ecom:Product:Field.ProductDiscount"); } string[] discountstring = discountPString.Split('|'); for(int i=0; i < discountstring.Length - 1; i++) { string[] discountsArray = discountstring[i].Split(':'); var percentage = discountsArray[1]; var quantity = discountsArray[2]; if(quantity == "0") { quantity ="1"; } discountslist.Add(percentage); quantitylist.Add(quantity); } if(!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product:Field.StockRelationship"))) { stockRelation = product.GetString("Ecom:Product:Field.StockRelationship"); } if(!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product:Field.OnlinePrice"))) { stockPString = product.GetString("Ecom:Product:Field.SaleStock"); } var stockstring = stockPString.Split('|'); for(int i=0; i < stockstring.Length - 1; i++) { string[] stockArray = stockstring[i].Split(':'); stocklist.Add(Int32.Parse(stockArray[1])); } <text> <script> </script> </text> var onlinePString = product.GetString("Ecom:Product:Field.OnlinePrice.Value"); var retailPString = product.GetString("Ecom:Product:Field.ProductRetailPrice.Value"); if((!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product:Field.OnlinePrice"))) && (!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product:Field.ProductRetailPrice")))) { var basePString = ""; if(!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product:Field.ProductBasePrice"))) { basePString = product.GetString("Ecom:Product:Field.ProductBasePrice.Value"); } string[] basestring = basePString.Split('|'); var basePrice = new List<String>(); for(int i=0; i < basestring.Length - 1; i++) { string[] baseArray = basestring[i].Split(':'); basePrice.Add(baseArray[1]); } var campaignPString =""; if(!string.IsNullOrWhiteSpace(product.GetString("Ecom:Product:Field.ProductCampaign.Value"))) { campaignPString = product.GetString("Ecom:Product:Field.ProductCampaign.Value"); } string[] campaignstring = campaignPString.Split('|'); var campaignNo = new List<String>(); var campaignDate = new List<String>(); var campaignPercent = new List<String>(); var campaignQuantity = new List<String>(); for(int i=0; i < campaignstring.Length - 1; i++) { string[] campaignArray = campaignstring[i].Split(':'); campaignNo.Add(campaignArray[1]); if (campaignArray[2]!="0") { var dateString = campaignArray[2].Split('/'); var date = dateString[1]+"/"+dateString[0]+"/"+dateString[2]; campaignDate.Add(date); } else { campaignDate.Add(campaignArray[2]); } campaignPercent.Add(campaignArray[4]); campaignQuantity.Add(campaignArray[5]); } string[] onlinestring = onlinePString.Split('|'); string[] retailstring = retailPString.Split('|'); var prices = new List<String>(); var units = new List<String>(); var pricesretail = new List<String>(); var unitsretail = new List<String>(); for(int i=0; i < retailstring.Length - 1; i++) { string[] pricesArrayretail = retailstring[i].Split(':'); var pricewithdollar1 = pricesArrayretail[1]; pricesretail.Add(pricewithdollar1); unitsretail.Add(pricesArrayretail[0]); } for(int i=0; i < onlinestring.Length - 1; i++) { string[] pricesArray = onlinestring[i].Split(':'); var pricewithdollar = pricesArray[1]; prices.Add(pricewithdollar); units.Add(pricesArray[0]); } bool loopExist = true; var outofstock =false; if(@stocklist[0] <=0) { outofstock = true; } if ((@Offer=="Pre-arrival offer")||@stocklist[0] >0) { <input @Hidden id="quantityinput@(pid)" data-maxstock = "@stocklist.Max()" data-uom = "@units[0]" data-stockrelation = "@stockRelation" onchange="changeLinkquantity(this.value, this, '@pid');" type="number" name="Quantity" value="1" class="qtyBox" min="1" max="@stocklist[0]" style="width:50px;margin:10px 1px 10px -20px;border-radius:5px;padding:2px;border:2px solid #BF3E38;text-align:right;" /> <select style="width:80px;margin:10px 1px;padding:2px;border-radius:5px;border:2px solid #BF3E38;text-align:right;" id="unitID@(pid)" name="UnitID1" onchange="newPrice(this.value, '@pid');changeLink(this, '@pid');changeCampaign(this.value, '@pid',this.options[this.selectedIndex].innerHTML);"> @for(var i =0; i< prices.Count; i++) { if (i==0) { <option selected data-unit="@units[i]" value='@prices[i]|@pricesretail[i]|@campaignNo[i]|@campaignDate[i]|@discountslist[i]|@quantitylist[i]|@basePrice[i]|@stocklist[i]|@pid'>@units[i].First().ToString().ToUpper()@(units[i].Substring(1).ToLower())</option> } else { <option data-unit="@units[i]" value='@prices[i]|@pricesretail[i]|@campaignNo[i]|@campaignDate[i]|@discountslist[i]|@quantitylist[i]|@basePrice[i]|@stocklist[i]|@pid'>@units[i].First().ToString().ToUpper()@(units[i].Substring(1).ToLower())</option> } } </select> <script> var totalquantity = 0; var select = document.getElementById("unitID"+productid); var link1 = document.getElementById("addtocart@(pid)"); var variantnamedefault = "@units[0]"; var defaultprice = '@prices[0] | @pricesretail[0]'; var defaultquantity ="1"; var productid = "@pid"; var linkstring = ""; var quantityvalue = ""; var unitvalue = ""; var selectedindex = ""; var currentuom = ""; newPrice(defaultprice, productid); function changeLink(select,id) { @if (@Offer!="Pre-arrival offer") { <text> selectedindex = select.selectedIndex; @if(b2b) { <text> if (parseInt(selectedindex)>0) { revealprice(id); } else { hideprice(id); } </text> } link1 = document.getElementById("addtocart"+id); link1.removeAttribute("disabled"); unitvalue = select.getElementsByTagName('option')[select.selectedIndex].text.toUpperCase(); quantityvalue = document.getElementById("quantityinput"+id).value; if (select==null) { unitvalue = variantnamedefault; } linkstring='/default.aspx?ID=496&productid='+id+'&VariantId='+unitvalue+'&cartcmd=add&quantity='+quantityvalue; link1.setAttribute("href",linkstring); var optionvalue = select.getElementsByTagName('option')[select.selectedIndex].value.split('|'); var inputbox = document.getElementById("quantityinput"+id); inputbox.max = optionvalue[7]; currentuom = unitvalue; var inputjq = jQuery(inputbox); $(inputjq).data('uom',unitvalue); </text> } } function changeLinkquantity(quantity1, input, id) { var inputjq = jQuery(input); currentuom = $(inputjq).data('uom'); var defaultuomstock =$(inputjq).data('maxstock'); var link2 = document.getElementById("addtocart"+id); link2.removeAttribute("disabled"); var link = link2.href; var temp = link.split('quantity='); var stockrelationjs = $(inputjq).data('stockrelation'); if (typeof(Storage) != "undefined") { // Store localStorage.setItem("stockrelation"+id, stockrelationjs+";"+defaultuomstock); } else { document.getElementById("result").innerHTML = "Sorry, Please use another browser!"; } var orderstocks = $(inputjq).data('stockcontrol'); if(orderstocks != null) { var currentstockrelation = ""; var currentuomorderstock = ""; var relationlist = stockrelationjs.split("|"); for(var i = 0; i<relationlist.length; i++) { var relationsplit = relationlist[i].split(":"); if (relationsplit[0]==currentuom) { currentstockrelation = relationsplit[1]; } } var ordertotalquantity = 0; var orderstocklist = orderstocks.split("|"); for (var i =0; i< orderstocklist.length-1;i++) { var ordersplit = orderstocklist[i].split(":"); for(var j = 0; j<relationlist.length-1; j++) { var relationsplit = relationlist[j].split(":"); if(ordersplit[1]==relationsplit[0]) { ordertotalquantity += parseInt(ordersplit[0])*parseInt(relationsplit[1]); } } } var totalquantity = ordertotalquantity+(parseInt(quantity1)*currentstockrelation); var currenttotal = parseInt(input.max)*parseInt(currentstockrelation); if(totalquantity <= defaultuomstock) { link = (temp[0]+"quantity="+ quantity1); link2.href = link; return true; } else { alert("Exceeded Maximum Stock!"); input.value = 1; link = (temp[0]+"quantity="+ 1); link2.href = link; return false; } } else { if (parseInt(quantity1) <= parseInt(input.max)) { link = (temp[0]+"quantity="+ quantity1); link2.href = link; return true; } else { alert("Maximum allowed quantity for this product is "+input.max); input.value = input.max; link = (temp[0]+"quantity="+ input.max); link2.href = link; return false; } } } function checkquantity(addtocartlink, id) { console.log("Add to cart Link:"+addtocartlink); var input2 = document.getElementById("quantityinput"+id); var quantity2 = document.getElementById("quantityinput"+id).value; if(changeLinkquantity(quantity2, input2, id)==false) { addtocartlink.setAttribute("disabled",""); return false; } else { addtocartlink.removeAttribute("disabled"); return true; } } function firsttimeLink () { @if("Pre-arrival offer"!=@Offer) { <text> var firstSelect = document.getElementById("unitID"+productid); var firstUnit = firstSelect.getElementsByTagName('option')[firstSelect.selectedIndex].text.toUpperCase(); var firstLink = '/default.aspx?ID=@GetString("Ecom:Product.PrimaryOrCurrentPageID")&productid='+productid+'&VariantId='+firstUnit+'&cartcmd=add&quantity=1'; var link3 = document.getElementById("addtocart"+productid); link3.setAttribute("href",firstLink); </text> } var firstOption = select.getElementsByTagName('option')[select.selectedIndex].value; var firstValueList = firstOption.split('|'); if(firstValueList[2]!=0){ document.getElementById("test"+firstValueList[8]).innerHTML = "Now on offer until: "+firstValueList[3]+"<br> Campaign No: "+firstValueList[2]; } if(firstValueList[5]!=0) { var flag = document.getElementById("discountFlag"+firstValueList[8]); flag.removeAttribute("hidden"); flag.getElementsByTagName("span")[0].innerHTML = "Buy "+firstValueList[5]+" "+ select.getElementsByTagName('option')[select.selectedIndex].text; flag.getElementsByTagName("span")[1].innerHTML =" get "+ firstValueList[4]+"% discount"; } } </script> if("Pre-arrival offer"!=@Offer) { <text> <a href='/default.aspx?ID=496&productid=@pid&VariantId=BOTTLE&cartcmd=add&quantity=1' onclick="return checkquantity(this,'@pid')" id="addtocart@(pid)" class="btn btn-sm btn-two" style="padding-bottom:2px;margin-bottom:2px;"><i class="glyphicon glyphicon-shopping-cart" title="@Translate("Add to cart","Add to cart")"></i></a> <script> $( document ).ready(function() { select = document.getElementById("unitID"+productid); link1 = document.getElementById("addtocart"+productid); variantnamedefault = "@units[0]"; defaultprice = "@prices[0]" defaultquantity ="1"; productid = "@pid"; linkstring = ""; firsttimeLink (); }); </script> </text> } else { <text> @if(@discountslist[0]!="") { <script> $( document ).ready(function() { select = document.getElementById("unitID"+productid); //link1 = document.getElementById("addtocart"+productid); variantnamedefault = "@units[0]"; defaultprice = "@prices[0]" defaultquantity ="1"; productid = "@pid"; linkstring = ""; firsttimeLink (); }); </script> } <a href="@GroupLink" class="btn btn-sm btn-two" style="padding-bottom:2px;margin-bottom:2px;">More Detail</a> </text> } } else { <p class="ribbon base"><span >&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sold Out&nbsp;&nbsp;&nbsp;&nbsp;</span></p> <button type="submit" style="font-size:12px;text-decoration: line-through;display:none" class="btn btn-two" > <i class="glyphicon glyphicon-shopping-cart" title="@Translate("Add to cart","Add to cart")"></i> </button> } if (Dynamicweb.Input.FormatBoolean(GetGlobalValue("Global:Extranet.UserName"))&&("Pre-arrival offer"!=@Offer)) { <a onclick='AddToFavorites("@favLink","@pid")' class="add-fav tooltipHere" style="top:inherit;right:inherit;margin-top:8px;float:right;@if(outofstock){<text>display:none</text>}" data-toggle="tooltip"> <i id="gly_@pid" class="glyphicon glyphicon-heart"></i> <i id="gid_@pid" class="glyphicon glyphicon-heart" style="display:none;color:#a73c4a !important"></i> <img id="img_@pid" src="Files/Images/TOT/favloading.gif" style="display:none;margin-bottom:6px;width:20px;height:20px;"> </a> } } <div id="campaign@(pid)" class="text_info" style="min-height:39px;"> <p id="test@(pid)"></p> </div> } <script> //Set min discount qty $(document).ready(function() { var tagIsExist = (document.getElementById("unitID"+"@(pid)"))!==null; if(tagIsExist) { var minDiscountQty = (((document.getElementById("unitID"+"@(pid)")).getElementsByTagName('option')[(document.getElementById("unitID"+"@(pid)")).selectedIndex].value).split('|')[5]); if(minDiscountQty < 1) { minDiscountQty = 1 } $('#quantityinput@(pid)').val(minDiscountQty); } }); $('#unitID@(pid)').change(function() { var minDiscountQty = (((document.getElementById("unitID"+"@(pid)")).getElementsByTagName('option')[(document.getElementById("unitID"+"@(pid)")).selectedIndex].value).split('|')[5]); if(minDiscountQty < 1) { minDiscountQty = 1 } $('#quantityinput@(pid)').val(minDiscountQty); }); </script> </div> </div> </div> Count++; if (Count == ColMD) { <div name="row3" class="row"></div> Count = 0; } else if (Count == 4) { <div hidden name="row4" class="row"></div> } } } <script> function changeCampaign(value, id, unit) { var valuelist = value.split('|'); if (valuelist[4]!=0) { var flag = document.getElementById("discountFlag"+id); flag.removeAttribute("hidden"); flag.getElementsByTagName("span")[0].innerHTML = "Buy "+valuelist[5]+" "+unit; flag.getElementsByTagName("span")[1].innerHTML = " get "+valuelist[4]+"% discount"; document.getElementById("test"+id).innerHTML = ""; if(valuelist[2]!=0) { var string1 = "Now on offer until: "+valuelist[3]+"<br> Campaign No: "+valuelist[2]; document.getElementById("test"+id).innerHTML = string1; } } else { var flag = document.getElementById("discountFlag"+id); flag.setAttribute("hidden",""); document.getElementById("test"+id).innerHTML = ""; } } </script> @using Dynamicweb.Modules.Common.CustomFields @using Dynamicweb.Modules.UserManagement <style> .ribbon.base::before { border-top: 27px solid #BF3E38 !important;} .ribbon.base::after { border-bottom: 27px solid #BF3E38 !important; } .text_info { color: #BF3E38; } .ribbon.base { background: #BF3E38 !important; border-left:#BF3E38 !important; } </style> @{ string image = ""; var grouplink = ""; <text><script>console.log('hehe'+'@GetString("Ecom:Product:Field.ProductName2")')</script></text> string productname = GetString("Ecom:Product.Name").Replace("&", "-A-"); var pid = GetValue("Ecom:Product.ID"); var pnumber = GetValue("Ecom:Product.Number"); var uom = GetString("Ecom:Product.DefaultUnitID").Replace("Unit_","").ToLower(); var volume = GetString("Ecom:Product:Field.ProductVolumeML"); string vintage = ""; if (!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductVintage"))){ vintage = GetString("Ecom:Product:Field.ProductVintage").Replace("NV", ""); } string tastingSource = ""; if(GetString("Ecom:Product:Field.ProductTastingNoteSource.Value")=="-"){ tastingSource = ""; } else if (!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductTastingNoteSource.Value"))&& string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductTastingNoteWriter.Value"))){ tastingSource = GetString("Ecom:Product:Field.ProductTastingNoteSource.Value"); } else if (!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductTastingNoteSource.Value"))){ tastingSource = GetString("Ecom:Product:Field.ProductTastingNoteSource.Value")+" , "; } string tastingWriter = ""; if(GetString("Ecom:Product:Field.ProductTastingNoteWriter.Value").Contains("-")){ tastingWriter = ""; } else if (!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductTastingNoteWriter.Value"))){ tastingWriter = GetString("Ecom:Product:Field.ProductTastingNoteWriter.Value"); } string tastingDate = ""; if(GetString("Ecom:Product:Field.ProductTastingNoteDate.Value").Contains("-")){ tastingDate = ""; } else if (!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductTastingNoteDate.Value"))){ tastingDate = " - "+GetString("Ecom:Product:Field.ProductTastingNoteDate.Value"); } } <style> *{ padding: 0; margin: 0; } #tabview{ width: 100%; padding:10px 0px; margin:10px 0px; } #header, #content-container{ border:2px solid #DDDDDD; } #header{ border-radius: 6px 6px 0 3px; font-weight: 700; color:#111111; display: inline-block; position: relative; top:8px; margin:0; padding:4px 15px; border-bottom: 3px solid #F5F5F5; } #content-container{ border-radius: 0 6px 6px 6px; padding:20px 10px; } .detailLabel{ font-weight:700; font-size:13px; color:#111111; } .detailValue{ font-size: 12px; font-weight:700; color:#AAAAAA; } .volume{ margin: 4px; } .year{ margin: 4px; } </style> <script type="text/javascript"> $(document).ready(function(){ var currentpid = $('#productDetail').attr("data-productid"); var currentpnumber = $('#productDetail').attr("data-productnumber"); var currentvolume = $('#productDetail').attr("data-productvolume"); var currentvintage = $('#productDetail').attr("data-productvintage"); var url = "/Default.aspx?id=509&number=" + currentpnumber; var arrVolume=[]; var arrVintage=[]; var volumelist=''; var vintagelist=''; var arrVintage2 = []; $.get(url, function(data, status){ var jsonlist = data.products; jsonlist.sort(function(a, b) { return parseFloat(a.volume.replace(',','')) - parseFloat(b.volume.replace(',','')); }); $.each(data.products,function(i){ //var isVolumeExist = $.inArray(data.products[i].volume,arrVolume); var isVintageExist = $.inArray(data.products[i].year,arrVintage); var detailLink = data.products[i].link.replace("509","499"); if(data.products[i].volume == currentvolume) { if(isVintageExist === -1){ vintagelist += '<a href="' + detailLink + '"><button class="year btn btn-info" data-year="'+ data.products[i].year +'">' + data.products[i].year + '</button></a>'; arrVintage.push(data.products[i].year); } } }); $.each(data.products,function(j){ var isVolumeExist = $.inArray(data.products[j].volume,arrVolume); //var isVintageExist = $.inArray(data.products[i].year,arrVintage); var detailLink = data.products[j].link.replace("509","499"); if(isVolumeExist == -1){ volumelist += '<a href="' + detailLink +'"><button class="volume btn btn-info" data-volume="' + data.products[j].volume +'">' + data.products[j].volume.replace(",","") + ' ml </button></a>'; arrVolume.push(data.products[j].volume); } $.each(arrVintage,function(i){ //console.log(isVolumeExist+" "+data.products[j].volume); if(arrVintage[i] == data.products[j].year){ } }) }); document.getElementById('volume').innerHTML = volumelist; document.getElementById('vintage').innerHTML = vintagelist; $('.volume').each(function(){ var datavolume = $(this).attr('data-volume'); if(datavolume == currentvolume ){ $(this).removeClass('btn btn-info'); $(this).addClass('btn btn-danger'); } }); $('.year').each(function(){ var datayear = $(this).attr('data-year'); if(datayear == currentvintage){ $(this).removeClass('btn btn-info'); $(this).addClass('btn btn-danger'); } }); }); }); /* CLASSES */ function VariantGroup(id, name) { this.Id = id; this.Name = name; this.Options = []; } function VariantOption(id, name) { this.Id = id; this.Name = name; } function VariantCombination(id) { this.Id = id; } function VariantSelector() { this.Groups = []; this.Combinations = []; } /* FUNCTIONS */ function ByGroupOrder(varid) { var vars = []; for (g = 0; g < Selector.Groups.length; g++) { for (o = 0; o < Selector.Groups[g].Options.length; o++) { for (v = 0; v < varid.length; v++) { if (Selector.Groups[g].Options[o].Id == varid[v]) { vars.push(varid[v]); } } } } return vars; } function PresetCombo(combono, value) { document.getElementById('COMBO' + combono).value = value; UpdateCombo(combono); } function CombinationExist(query) { found = false; for (ci = 0; ci < Selector.Combinations.length; ci++) { combis = Selector.Combinations[ci].Id.split("."); queryfoundincombination = true; for (q = 0; q < query.length; q++) { queryitemfoundincombination = false; for (cs = 0; cs < combis.length; cs++) { if (combis[cs] == query[q]) queryitemfoundincombination = true; } if (!queryitemfoundincombination) queryfoundincombination = false; } if (queryfoundincombination) found = true; } return found; } function FillCombo(combono) { ClearCombo(combono); @{ var selectiontext = @Translate("Choose variant", "Choose variant"); } var op = document.createElement("option"); op.text = "@selectiontext"; op.value = ""; document.getElementById('COMBO' + combono).options.add(op); for (i = 0; i < Selector.Groups[combono].Options.length; i++) { option = Selector.Groups[combono].Options[i]; includeoption = true; curcombination = []; for (g = 0; g < combono; g++) { curcombination.push(document.getElementById('COMBO' + g).value); } curcombination.push(option.Id); includeoption = CombinationExist(curcombination); if (includeoption) { var op = document.createElement("option"); op.text = option.Name; op.value = option.Id; document.getElementById('COMBO' + combono).options.add(op); document.getElementById('COMBO' + combono).disabled = false; } } } function ClearCombo(combono) { while (document.getElementById('COMBO' + combono).options.length > 0) { document.getElementById('COMBO' + combono).options[0] = null; } document.getElementById('COMBO' + combono).disabled = true; } function UpdateCombo(combono) { if (combono < Selector.Groups.length - 1) { if (document.getElementById('COMBO' + combono).value != "") FillCombo((combono + 1)); if (combono > -1) { fromcombo = (document.getElementById('COMBO' + combono).value == "") ? combono + 1 : combono + 2; for (c = fromcombo; c < Selector.Groups.length; c++) { ClearCombo(c); } } } else { if (!presetting && (document.getElementById('COMBO' + (Selector.Groups.length - 1)).value != "")) { id = ""; for (c = 0; c < Selector.Groups.length; c++) { id += (c == 0) ? document.getElementById('COMBO' + c).value : "." + document.getElementById('COMBO' + c).value; } document.location.href = Page + "&VariantID=" + id; //Spinner var opts = { lines: 9, // The number of lines to draw length: 0, // The length of each line width: 10, // The line thickness radius: 18, // The radius of the inner circle corners: 1, // Corner roundness (0..1) rotate: 0, // The rotation offset direction: 1, // 1: clockwise, -1: counterclockwise color: '#000', // #rgb or #rrggbb or array of colors speed: 1, // Rounds per second trail: 35, // Afterglow percentage shadow: false, // Whether to render a shadow hwaccel: false, // Whether to use hardware acceleration className: 'spinner', // The CSS class to assign to the spinner zIndex: 2e9, // The z-index (defaults to 2000000000) top: '50%', // Top position relative to parent left: '50%' // Left position relative to parent }; var target = document.getElementById('productinfo'); var spinner = new Spinner(opts).spin(target); } } } function UpdateCart() { document.getElementById('minipagecart').className = " dw-minicart-update"; document.getElementById('minipagecart-button').className = "btn btn-sm dw-minicart-update"; } </script> @{ string imagesize = "3"; string Offer = GetString("Ecom:Product:Field.ProductOffer"); string Hidden = ""; if("Pre-arrival offer"==@Offer){Hidden = "hidden";} string infosize = "6"; string sidebar = "3"; string leftcolumn = "3"; string rightcolumn = "6"; string grapecode=""; string RatingsTitle="Wine Ratings :";string comma=", "; if(!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductGrapeCode"))){ grapecode = GetString("Ecom:Product:Field.ProductGrapeCode"); grapecode = grapecode.Substring(0,grapecode.Length-1); string[] arrgrapecode = grapecode.Split(','); string percentage = ""; int count = arrgrapecode.Length;; if(count >0){ grapecode = ""; foreach(var arr in arrgrapecode){ if(arr.Substring(0,3)=="100"){ percentage = arr.Substring(0,3); } else{ percentage = arr.Substring(0,2); } grapecode += arr + ", "; } if(grapecode.Length > 0){ grapecode = grapecode.Substring(0,grapecode.Length-2); } } } string usergroups = GetGlobalValue("Global:Extranet.Groups"); bool b2b=false; if(!string.IsNullOrEmpty(usergroups)){ List<string> usergrouplist = new List<string>(usergroups.Split(',')); if(usergrouplist.Count>0) { foreach(var group in usergrouplist){ if(Convert.ToInt32(group) == 5){ b2b= true; break; } } } } bool staff= false; if (Dynamicweb.Input.FormatBoolean(GetGlobalValue("Global:Extranet.UserName"))) { int i=Convert.ToInt32(GetGlobalValue("Global:Extranet.UserID")); Dynamicweb.Modules.UserManagement.User u = Dynamicweb.Modules.UserManagement.User.GetUserByID(i); foreach (CustomFieldValue val in u.CustomFieldValues) { CustomField field = val.CustomField; string fieldValue = (val.Value).ToString(); string ff=field.Name; if(fieldValue=="Staff"){ staff = true; } } } <script> @if(b2b){ <text>function revealprice(id){ document.getElementById("priceperbottlelabel"+id).removeAttribute("hidden"); document.getElementById("priceperbottle"+id).removeAttribute("hidden"); } function hideprice(id){ document.getElementById("priceperbottlelabel"+id).setAttribute("hidden",""); document.getElementById("priceperbottle"+id).setAttribute("hidden",""); } </text> } </script> <script type="text/javascript"> function newPrice(price1, id) { var pricelist = price1.split('|'); @if(b2b){<text> document.getElementById("retailprice"+id).innerHTML = "$"+parseFloat(Math.round(pricelist[1] * 100) / 100).toFixed(2); </text> } else{<text> document.getElementById("online"+id).innerHTML = "$"+parseFloat(Math.round(pricelist[1] * 100) / 100).toFixed(2); </text> } @if(b2b){<text> document.getElementById("trade"+id).innerHTML="$"+parseFloat(Math.round(pricelist[0] * 100) / 100).toFixed(2); document.getElementById("priceperbottle"+id).innerHTML = "$"+Math.round(parseFloat(pricelist[6]) * 100.0) / 100.0; </text> } } </script> } <div id="productDetail" data-productid="@pid" data-productnumber="@pnumber" data-productvolume="@volume" data-productvintage="@vintage" class="row well"> <div class="col-md-@imagesize col-sm-4 col-xs-12"> <div class="product-gallery"> <!-- Discount sticker --> @if (GetString("Ecom:Product.Discount.Price") != GetString("Ecom:Product.Price")) { <span class="ribbon base" style="right:300;">@Translate("On sale!", "On sale!")</span> } <p hidden id="discountFlag@(pid)" class="ribbon base"> <span style="font-size:12px;"> Buy @GetString("MinimumQuantity") get </span> <span style="font-size:12px;"> @GetString("Percentage") % discount. </span> </p> @{ image = GetString("Ecom:Product.ImageLarge.Default.Clean"); } <div class="primary-image"> <a href="@image" class="fancybox"> <img src="@image" class="img-responsive" alt="Product image"> </a> <script> $('.jzoom').jzoom({bgColor: "#222"}); </script><script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-36251023-1']); _gaq.push(['_setDomainName', 'jqueryscript.net']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> </div> <div class="clearfix"><p>&nbsp;</p></div> <div class="row"> @foreach (LoopItem detail in GetLoop("Details")) { image = System.Web.HttpContext.Current.Server.UrlEncode(detail.GetString("Ecom:Product.ImageLarge.Default.Clean")); <div class="col-md-3 col-sm-4 col-xs-6"> <div class="thumbnail-images"> <a href="@image" class="fancybox"> <img src="@image" alt=""> </a> </div> </div> } </div> </div> </div> <div class="col-md-@infosize col-sm-6 col xs-12"> <div class="product-info" vocab="http://schema.org/" typeof="Product" id="productinfo"> <p style="font-size:15px;font-weight:800;"> <span property="name" style="color:#7B302D;text-transform:uppercase;"> @GetString("Ecom:Product:Field.ProductItemGroup").Replace("-a-", "&") </span> <br/> <span property="name" style="color:#000000;font-size:14px;text-transform:uppercase;"> @GetString("Ecom:Product:Field.ProductName2") @GetString("Ecom:Product:Field.ProductVintage").Replace("NV", "") </span> </p> <p style="font-size:12px;color:#AAAAAA;font-weight:700;" class="capitalize"> <span property="name"> @if(!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductCountryOfOrigin"))){ @GetString("Ecom:Product:Field.ProductCountryOfOrigin"); } @if(!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductRegionOfOrigin"))){ @comma; @GetString("Ecom:Product:Field.ProductRegionOfOrigin").ToLower(); } @if(@GetString("Ecom:Product:Field.ProductSubRegionOfOrigin").Replace("-", "") !="" ){ @comma; @GetString("Ecom:Product:Field.ProductSubRegionOfOrigin").ToLower(); } </span> </p> <span class="clearfix"></span> <div> <span style="color:#000000;font-size:11px;text-transform:uppercase;font-weight:bold;">@GetString("Ecom:Product:Field.ProductWineType") | @GetString("Ecom:Product:Field.ProductAppellation") @if(!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductClassification"))){<text>| </text> @GetString("Ecom:Product:Field.ProductClassification")}</span> </div> <div property="description" id="description" style="font-size:12px;"> @GetString("Ecom:Product.ShortDescription") </div> <div style="font-size:12px;font-weight:bold;"> @if (@GetString("Ecom:Product:Field.ProductWineRating1").Replace(" ", "") !="") { @RatingsTitle <span class="detailValue"> @GetString("Ecom:Product:Field.ProductWineRating1") Points </span> <br /> <br /> } </div> <span class="clearfix"></span> <!-- DYNAMIC VARIANT OPTION --> <div id="productvariants"> <!-- SELECTOR MAIN --> @{ var pageid = GetValue("Ecom:Product:Page.ID"); var productid = GetValue("Ecom:Product.ID"); } <script type="text/javascript"> var presetting = true; var VariantID = "@GetValue("Ecom:Product.SelectedVariantComboID")"; var VariantOptions = VariantID.split('.'); var Page = "/Default.aspx?ID=@pageid&ProductID=@productid"; var Selector = new VariantSelector(); </script> <script type="text/javascript"> @foreach (LoopItem variantgroup in GetLoop("VariantGroups")) { var variantgroupid = variantgroup.GetValue("Ecom:VariantGroup.ID"); var variantgroupname = variantgroup.GetString("Ecom:VariantGroup.Name"); <text>group = new VariantGroup("@variantgroupid", "@variantgroupname");</text> foreach (LoopItem variantoption in variantgroup.GetLoop("VariantOptions")) { var variantoptionid = variantoption.GetValue("Ecom:VariantOption.ID"); var variantoptionname = variantoption.GetString("Ecom:VariantOption.Name"); <text>group.Options.push(new VariantOption("@variantoptionid", "@variantoptionname"));</text> } <text>Selector.Groups.push(group);</text> } </script> <script type="text/javascript"> @foreach (LoopItem variantcomb in GetLoop("VariantCombinations")) { var variantcombid = variantcomb.GetValue("Ecom:VariantCombination.VariantID"); <text>Selector.Combinations.push(new VariantCombination("@variantcombid"));</text> } </script> <script type="text/javascript"> for (g = 0; g < Selector.Groups.length; g++) { document.write("<br><b>" + Selector.Groups[g].Name + "</b><br>"); document.write("<select id='COMBO" + g + "' style='width:40%' onchange=\"UpdateCombo(" + g + ");\">\n</select><br>\n"); } FillCombo(0); for (vo = 0; vo < VariantOptions.length; vo++) { PresetCombo(vo, VariantOptions[vo]); } presetting = false; </script> </div> <div property="offers" typeof="Offer"> <div class="row"> <span class="clearfix"></span> <div class="product-short-info"> @if (!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Stock.Text"))) { image = GetString("Ecom:Product:Stock.Image.Clean"); <div class="col-md-6 col-sm-12 col-xs-12"> <p><small>@Translate("Availability", "Availability"): <span property="availability">@GetString("Ecom:Product:Stock.Text")</span>: </small> <img src="@image" alt="@GetString("ecom:product:stock.text")" style="width:7px !important; height:7px !important" /></p> </div> } @*<div class="col-md-6 col-sm-12 col-xs-12"> <p><small>@Translate("Delivery", "Delivery"): @GetString("Ecom:Product:Stock.DeliveryText")&nbsp;@GetString("Ecom:Product:Stock.DeliveryUnit")</small></p> </div> <div class="col-md-6 col-xs-12"> <p><small>@Translate("Product number", "Product number"): <span property="identifier">@GetString("Ecom:Product.Number")</span></small></p> </div>*@ @if (GetLoop("BOMProducts").Count > 0) { <div class="col-md-12 col-sm-12 col-xs-12" id="includingproducts"> <hr /> <h3 class="section-title">@Translate("Including products", "Including products")</h3> @foreach (LoopItem bomproduct in GetLoop("BOMProducts")) { var bomimage = bomproduct.GetString("Ecom:Product.ImageSmall.Clean"); <ul> <li class="bomlist"> <a href="@bomproduct.GetString("Ecom:Product.Link.Clean.PID")"> <img src="/Admin/Public/GetImage.ashx?width=50&amp;image=@bomimage&amp;Compression=99" alt=""> <text>&nbsp;&nbsp;&nbsp;</text>@bomproduct.GetString("Ecom:Product.Name") </a> </li> </ul> } <table cellspacing="0" cellpadding="0" border="0"> @foreach (LoopItem bomconfig in GetLoop("BOMConfigurators")) { <tr> <td> <b>@bomconfig.GetString("Ecom:Product.Configurator.Name")</b><br> <select name="@bomconfig.GetString("Ecom:Product.Configurator.ID")"> @foreach (LoopItem configproduct in GetLoop("ConfiguratorProducts")) { <option value="@configproduct.GetString("Ecom:Product.ID")" @configproduct.GetString("Ecom:Product.Configurator.Selected")> @configproduct.GetString("Ecom:Product.Name") ( @configproduct.GetString("Ecom:Product.ActualPrice")" ) </option> } </select> </td> </tr> } </table> </div> } </div> </div> </div> </div> </div> <div class="col-md-@sidebar col-sm-12 col-xs-12"> <div class="row border-pbox"> <div class="col-md-12 col-xs-12"> @{ var currency = GetString("Ecom:Product.Price.Currency.Code"); var priceid = "price" + pid;} <meta property="priceCurrency" content="@currency" /> <div class="listproductleft wp-block-footer" style="text-align:right;"> @if(b2b) { <span class="productprice price" style="font-size: 16px !important"><strong id='retailprice@(pid)'></strong></span> } else if ("Pre-arrival offer"==System.Web.HttpContext.Current.Request["offer"]){ string OnlinePriceString = String.IsNullOrEmpty(GetString("Ecom:Product:Field.OnlinePrice")) ? "0" : GetString("Ecom:Product:Field.OnlinePrice"); var string1 = OnlinePriceString.Split(':')[1]; <span class="productprice price" style="font-size: 16px !important"><strong id='online@(pid)'>$@string1.Remove(string1.Length -1).00</strong></span> } else { <span class="productprice price" style="font-size: 16px !important"><strong id='online@(pid)'></strong></span> } <span style="font-size:12px">&nbsp;(incl. GST)</span><br/> @if(b2b) { if(!staff){<text>Trade Price:</text>}else{<text>Staff Price:</text>} <span class="productprice price" style="color:red;font-size: 14px !important"><strong id="trade@(pid)">online price</strong></span><span style="font-size:12px">&nbsp;(excl. GST)</span> <p><text id="priceperbottlelabel@(pid)" hidden>Price per bottle:</text> <span class="productprice price" style="font-size: 16px !important"><strong hidden id='priceperbottle@(pid)'></strong></span></p> } </div> </div> <div class="col-md-12 col-sm-12 col-xs-12" style="display:block;"> <span> Available in : </span> <div id="volume"> <span style="border:1px solid black;padding:0px 5px 0px 5px;">@GetString("Ecom:Product:Field.ProductVolumeML")ml</span> </div> </div> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12" style="text-align:right;margin-top:20px;"> <div style="margin:8px 15px;"> <div> @{ bool loopExist = true; } @{ var stockHidden = ""; var discountPString =""; var stockDisplayNone = ""; if(!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductDiscount"))){ discountPString = GetString("Ecom:Product:Field.ProductDiscount"); } string[] discountstring = discountPString.Split('|'); var discountslist = new List<String>(); var quantitylist = new List<String>(); for(int i=0; i < discountstring.Length - 1; i++){ string[] discountsArray = discountstring[i].Split(':'); var percentage = discountsArray[1]; var quantity = discountsArray[2]; if(quantity == "0"){ quantity ="1"; } discountslist.Add(percentage); quantitylist.Add(quantity); } var stockRelation =""; if(!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.StockRelationship"))){ stockRelation = GetString("Ecom:Product:Field.StockRelationship"); } var stockPString = ""; if(!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.OnlinePrice"))){ stockPString = GetString("Ecom:Product:Field.SaleStock"); } var stockstring = stockPString.Split('|'); var stocklist = new List<int>(); for(int i=0; i < stockstring.Length - 1; i++){ string[] stockArray = stockstring[i].Split(':'); stocklist.Add(Int32.Parse(stockArray[1])); } if((!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.OnlinePrice")))&&(!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductRetailPrice")))){ var onlinePString = GetString("Ecom:Product:Field.OnlinePrice.Value"); var retailPString = GetString("Ecom:Product:Field.ProductRetailPrice.Value"); var basePString = ""; if(!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductBasePrice"))){ basePString = GetString("Ecom:Product:Field.ProductBasePrice.Value"); } string[] basestring = basePString.Split('|'); var basePrice = new List<String>(); for(int i=0; i < basestring.Length - 1; i++){ string[] baseArray = basestring[i].Split(':'); basePrice.Add(baseArray[1]); } var campaignPString = GetString("Ecom:Product:Field.ProductCampaign.Value"); string[] campaignstring = campaignPString.Split('|'); var campaignNo = new List<String>(); var campaignDate = new List<String>(); var campaignPercent = new List<String>(); var campaignQuantity = new List<String>(); for(int i=0; i < campaignstring.Length - 1; i++){ string[] campaignArray = campaignstring[i].Split(':'); campaignNo.Add(campaignArray[1]); campaignDate.Add(campaignArray[2]); campaignPercent.Add(campaignArray[4]); campaignQuantity.Add(campaignArray[5]); } string[] onlinestring = onlinePString.Split('|'); string[] retailstring = retailPString.Split('|'); var prices = new List<String>(); var units = new List<String>(); var pricesretail = new List<String>(); var unitsretail = new List<String>(); for(int i=0; i < retailstring.Length - 1; i++){ string[] pricesArrayretail = retailstring[i].Split(':'); var pricewithdollar1 = pricesArrayretail[1]; pricesretail.Add(pricewithdollar1); unitsretail.Add(pricesArrayretail[0]); } for(int i=0; i < onlinestring.Length - 1; i++){ string[] pricesArray = onlinestring[i].Split(':'); var pricewithdollar = pricesArray[1]; prices.Add(pricewithdollar); units.Add(pricesArray[0]); } var outofstock =false; if(@stocklist[0] <=0){ outofstock = true; stockHidden = "hidden"; stockDisplayNone = "display:none"; <text><script> document.getElementById("discountFlag@(pid)").removeAttribute("hidden"); document.getElementById("discountFlag@(pid)").innerHTML = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Sold Out&nbsp;&nbsp;&nbsp;&nbsp;"; </script></text> } var offerFunction = ""; if (@Offer!="Pre-arrival offer"){ offerFunction = "changeLink(this, '"+@pid+"');"; } <input @Hidden @stockHidden id="quantityinput@(pid)" data-maxstock = "@stocklist.Max()" data-uom = "@units[0]" data-stockrelation = "@stockRelation" onchange="changeLinkquantity(this.value, this, '@pid');" type="number" name="Quantity" value="1" class="qtyBox" min="1" max="@stocklist[0]" style="width:40px;margin:10px 1px 10px -20px;border-radius:5px;border:2px solid #BF3E38;text-align:right;" /> <select @stockHidden style="width:80px;margin:10px 1px;padding:2px;border-radius:5px;border:2px solid #BF3E38;text-align:right;" id="unitID@(pid)" name="UnitID1" onchange="newPrice(this.value, '@pid');@(offerFunction)changeCampaign(this.value, '@pid',this.options[this.selectedIndex].innerHTML);"> @for(var i =0; i< prices.Count; i++){ if (i==0){ <option selected data-unit="@units[i]" value='@prices[i]|@pricesretail[i]|@campaignNo[i]|@campaignDate[i]|@discountslist[i]|@quantitylist[i]|@basePrice[i]|@stocklist[i]|@pid'>@units[i].First().ToString().ToUpper()@(units[i].Substring(1).ToLower())</option> } else{ <option data-unit="@units[i]" value='@prices[i]|@pricesretail[i]|@campaignNo[i]|@campaignDate[i]|@discountslist[i]|@quantitylist[i]|@basePrice[i]|@stocklist[i]|@pid'>@units[i].First().ToString().ToUpper()@(units[i].Substring(1).ToLower())</option> } } </select> <script> var link1 = document.getElementById("addtocart@(pid)"); var variantnamedefault = "@units[0]"; var defaultprice = '@prices[0]|@pricesretail[0]'; var defaultquantity ="1"; var productid = "@pid"; var linkstring = ""; var quantityvalue = ""; var unitvalue = ""; var selectedindex = ""; var currentuom = ""; newPrice(defaultprice, productid); $( document ).ready(function() { link1 = document.getElementById("addtocart"+productid); variantnamedefault = "@units[0]"; defaultprice = "@prices[0]" defaultquantity ="1"; productid = "@pid"; linkstring = ""; firsttimeLink(); }); function changeLink(select,id){ selectedindex = select.selectedIndex; @if(b2b){<text> if (parseInt(selectedindex)>0){ revealprice(id); } else{ hideprice(id); } </text> } link1 = document.getElementById("addtocart"+id); link1.removeAttribute("disabled"); unitvalue = select.getElementsByTagName('option')[select.selectedIndex].text.toUpperCase(); quantityvalue = document.getElementById("quantityinput"+id).value; if (select==null){ unitvalue = variantnamedefault; } linkstring='/default.aspx?ID=1&productid='+id+'&VariantId='+unitvalue+'&cartcmd=add&quantity='+quantityvalue; link1.setAttribute("href",linkstring); var optionvalue = select.getElementsByTagName('option')[select.selectedIndex].value.split('|'); var inputbox = document.getElementById("quantityinput"+id); inputbox.max = optionvalue[7]; currentuom = unitvalue; var inputjq = jQuery(inputbox); $(inputjq).data('uom',unitvalue); } function changeLinkquantity(quantity1, input, id){ var inputjq = jQuery(input); currentuom = $(inputjq).data('uom'); var defaultuomstock =$(inputjq).data('maxstock'); var link2 = document.getElementById("addtocart"+id); link2.removeAttribute("disabled"); var link = link2.href; var temp = link.split('quantity='); var stockrelationjs = $(inputjq).data('stockrelation'); if (typeof(Storage) != "undefined") { // Store localStorage.setItem("stockrelation"+id, stockrelationjs+";"+defaultuomstock); } else { document.getElementById("result").innerHTML = "Sorry, Please use another browser!"; } var orderstocks = $(inputjq).data('stockcontrol'); if(orderstocks != null){ var currentstockrelation = ""; var currentuomorderstock = ""; var relationlist = stockrelationjs.split("|"); for(var i = 0; i<relationlist.length; i++){ var relationsplit = relationlist[i].split(":"); if (relationsplit[0]==currentuom){ currentstockrelation = relationsplit[1]; } } var ordertotalquantity = 0; var orderstocklist = orderstocks.split("|"); for (var i =0; i< orderstocklist.length-1;i++){ var ordersplit = orderstocklist[i].split(":"); for(var j = 0; j<relationlist.length-1; j++){ var relationsplit = relationlist[j].split(":"); if(ordersplit[1]==relationsplit[0]){ ordertotalquantity += parseInt(ordersplit[0])*parseInt(relationsplit[1]); } } } var totalquantity = ordertotalquantity+(parseInt(quantity1)*currentstockrelation); var currenttotal = parseInt(input.max)*parseInt(currentstockrelation); console.log("Max: "+defaultuomstock+"Current: "+totalquantity); if(totalquantity <= defaultuomstock){ link = (temp[0]+"quantity="+ quantity1); link2.href = link; return true; } else{ alert("Exceeded Maximum Stock!"); input.value = 1; link = (temp[0]+"quantity="+ 1); link2.href = link; return false; } } else { if (parseInt(quantity1) <= parseInt(input.max)){ link = (temp[0]+"quantity="+ quantity1); link2.href = link; return true; } else{ alert("Maximum allowed quantity for this product is "+input.max); input.value = input.max; link = (temp[0]+"quantity="+ input.max); link2.href = link; return false; } } } function firsttimeLink (){ var firstSelect = document.getElementById("unitID"+"@(pid)"); @if("Pre-arrival offer"!=@Offer){ <text> var firstUnit = firstSelect.getElementsByTagName('option')[firstSelect.selectedIndex].text.toUpperCase(); var firstLink = '/default.aspx?ID=@GetString("Ecom:Product.PrimaryOrCurrentPageID")&productid='+productid+'&VariantId='+firstUnit+'&cartcmd=add&quantity=1'; var link3 = document.getElementById("addtocart"+"@(pid)"); link3.setAttribute("href",firstLink); </text> } var firstOption = firstSelect.getElementsByTagName('option')[firstSelect.selectedIndex].value; console.log(firstOption); var firstValueList = firstOption.split('|'); if(firstValueList[2]!=0){ document.getElementById("test"+firstValueList[8]).innerHTML = "Now on offer until: "+firstValueList[3]+"<br> Campaign No: "+firstValueList[2]; } if(firstValueList[5]!=0){ var flag = document.getElementById("discountFlag"+firstValueList[8]); flag.removeAttribute("hidden"); flag.getElementsByTagName("span")[0].innerHTML = "Buy "+firstValueList[5]+" "+ firstSelect.getElementsByTagName('option')[firstSelect.selectedIndex].text; flag.getElementsByTagName("span")[1].innerHTML =" get "+ firstValueList[4]+"% discount"; } } function checkquantity(addtocartlink, id){ var input2 = document.getElementById("quantityinput"+id); var quantity2 = document.getElementById("quantityinput"+id).value; if(changeLinkquantity(quantity2, input2, id)==false){ addtocartlink.setAttribute("disabled",""); return false; } else{ addtocartlink.removeAttribute("disabled"); return true; } } </script> }} @if(("Pre-arrival offer"!=@Offer)){ <a class="btn btn-sm btn-two" style="padding-bottom:1px;@stockDisplayNone" onclick="return checkquantity(this,'@pid')" href='/default.aspx?ID=@GetString("Ecom:Product.PrimaryOrCurrentPageID")&productid=@pid&VariantId=BOTTLE&cartcmd=add&quantity=1' id="addtocart@(pid)"> Add to Cart </a> } else{ <text> @if(@discountslist[0]!=""){ <script> $( document ).ready(function() { productid = "@(pid)"; defaultquantity ="1"; linkstring = ""; firsttimeLink(); }); </script> } </text> } <div id="campaign@(pid)" class="text_info"> <p id="test@(pid)"></p> </div> </div> @if("Pre-arrival offer"==@Offer){ <div style="text-align: left; margin-left: 15px;"> <div class="row">Please contact us to pre-order this product.</div> <div class="row"><a href="default.aspx?id=526&pid=@pid&pname=@productname" style="font-size:12px;margin:3px;" class="btn btn-two">Contact Us</a></div> </div> } </div> </div> @* <div style="margin:8px 15px;"> <input type="number" name="" value="1" id="" style="width:50px;border-radius:5px; border:2px solid #000000;text-align:right;" /> <button type="submit" class="btn btn-primary" style="font-size:11px;background:#000000; width:90px;"> Add Case(s) </button> </div> *@ </div> </div> <div class="row border-pbox"> <div class="col-md-12 col-sm-12 col-xs-12"> <span style="text-transform: uppercase;font-weight:bold;"> All vintages of this wine volume </span> <div id="vintage"> </div> </div> </div> </div> <div class="clearfix"></div> <div class="col-md-@leftcolumn col-sm-12 col-xs-12 details-box"> <div class="col-md-12 col-sm-12 col-xs-12"> <p style="font-size:14px;color:#A73C4A;font-weight:bold;border:none;padding-left:10px">Details</p> <hr/> <div id="content-container" style="border:none;padding-top:0px"> @if(grapecode.Length>0){ var grapearray = grapecode.Split(' '); <span class="detailLabel"> Grape Variety </span> <br /> if(grapearray[0]!="0%"){ <span class="detailValue"> @grapecode </span> <br /> <br /> } else{ <span class="detailValue"> @grapecode.Replace("0%","") </span> <br /> <br /> } } <span class="detailLabel"> Harvest </span> <br /> <span class="detailValue"> @GetString("Ecom:Product:Field.ProductHarvest") </span> <br /> <br /> <span class="detailLabel"> Packaging </span> <br /> <span class="detailValue"> @GetString("Ecom:Product:Field.ProductInnerPack") @if (!string.IsNullOrWhiteSpace(GetString("Ecom:Product:Field.ProductInnerPack"))) { <text>@uom @Translate("per","per")</text> } @GetString("Ecom:Product:Field.ProductCartonType") </span> <br /> <br /> <span class="detailLabel"> Closure </span> <br /> <span class="detailValue"> @GetString("Ecom:Product:Field.ProductClosure") </span> <br /> <br /> <span class="detailLabel"> Foil Type </span> <br /> <span class="detailValue"> @GetString("Ecom:Product:Field.ProductFoilType") </span> <br /> <br /> <span class="detailLabel"> Alcohol </span> <br /> @if (@GetString("Ecom:Product:Field.ProductAlcohol") != "0" && @GetString("Ecom:Product:Field.ProductAlcohol") != "0.00" ) { <span class="detailValue"> @GetString("Ecom:Product:Field.ProductAlcohol") % </span> <br /> <br /> } <!--<div style="width:100%;text-align:right;"> <a href="#" data-toggle="modal" data-target="#ModalInfo" class="btn btn-two"> <span class="hidden-xs">Info</span> <i class="glyphicon glyphicon-log-in hide visible-xs "></i> </a> </div>--> </div> </div> </div> <div class="col-md-@rightcolumn col-sm-12 col-xs-12"> <div class="col-md-12 col-sm-12 col-xs-12"> <p style="font-size:14px;color:#A73C4A;font-weight:bold;margin-top:5px">Tasting Notes</p> <hr/> <span class="detailLabel">@tastingSource @tastingWriter @tastingDate</span> <p> @GetString("Ecom:Product.LongDescription") </p> </div> </div> <div class="col-md-3 col-sm-12 col-xs-12"> &nbsp; </div> </div> <div class="col-md-12 col-sm-12 col-xs-12"> @if (Dynamicweb.Base.IsModuleInstalled("LoyaltyPoints")) { @* Buy with loyalty points start *@ var productPoints = GetDouble("Ecom:Product.PointPrice"); <div class="col-md-6 col-sm-12 col-xs-12"> @if (productPoints > 0) { <span class="price pull-left" style="font-size: 22px !important; margin-top:4px !important">@productPoints @Translate("Points", "Points")</span> var user = Dynamicweb.Modules.UserManagement.User.get_Current(Dynamicweb.Modules.UserManagement.PagePermissionLevels.Frontend); if (user == null) { <div class="alert alert-info">@Translate("Sign in to buy this product using points")</div> } else { var availablePoints = user != null ? user.PointBalance : 0; var cart = Dynamicweb.eCommerce.Common.Context.Cart; var pointsUsedInCart = cart != null ? cart.TotalPoints : 0; if (availablePoints < productPoints + pointsUsedInCart) { <div class="alert alert-danger">@string.Format(Translate("You don't have enough points to buy this product using points ({0:0.00}/{1:0.00})"), availablePoints, productPoints + pointsUsedInCart)</div> } else { var ProductID = GetValue("Ecom:Product.ID"); <form method="post" role="form"> <input type="hidden" name="ProductID" value="@ProductID" /> <button type="submit" onclick="UpdateCart();" class="btn btn-dw-secondary pull-right" name="CartCmd" value="addWithPoints">@Translate("Buy for") @productPoints @Translate("points")</button> </form> } } } </div> @* Buy with loyalty points end *@ } @* Related Products *@ <div> @if (GetString("Ecom:Product.RelatedCount") != "0") { <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12"> <h3 class="dw-section-title"><span>@Translate("Related products", "Related products")</span></h3> </div> </div> foreach (LoopItem relatedgroup in GetLoop("ProductRelatedGroups")) { <div class="row"> @{ var relatedproductloop = relatedgroup.GetLoop("RelatedProducts").OrderByDescending(g => g.GetString("Ecom:Product.LoopCounter")).Take(3).ToList(); } @GetProductList(relatedproductloop, 3, 3, 1) </div> <div class="row"><hr /></div> } } </div> </div> @* Product Custom Fields *@ <div class="modal signUpContent fade" id="ModalInfo"> <div class="modal-dialog "> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> &times; </button> <h3 class="modal-title-site text-center"> Product Info </h3> </div> <div class="row"> <div class="col-md-12 col-sm-12 col-xs-12" > <p style="background:#D00000;color:#FFFFFF;font-weight:bold;padding:3px 10px;"> @GetString("Ecom:Product.Name") </p> <div style="height:550px;overflow:auto;"> <table cellpadding=2 style="font-size:12px;font-family: Helvetica, Arial;color:#666666;"> @foreach (LoopItem field in GetLoop("CustomFieldList")) { var fieldName = "Ecom:Product:Field." + field.GetString("Ecom:CustomField.System") + ".Value.Clean"; if (!string.IsNullOrWhiteSpace(GetString(fieldName))) { <tr> <td style="text-align:right;font-weight:bold;padding:4px 3px 4px 8px;"> @field.GetString("Ecom:CustomField.Name") : </td> <td style="padding:4px 3px 4px 15px;text-align:left;"> @GetString(@fieldName)<br /> </td> </tr> } } </table> </div> </div> </div> </div> </div> </div> <script> //Set min discount qty $(document).ready(function(){ var tagIsExist = (document.getElementById("unitID"+"@(pid)"))!==null; if(tagIsExist) { var minDiscountQty = (((document.getElementById("unitID"+"@(pid)")).getElementsByTagName('option')[(document.getElementById("unitID"+"@(pid)")).selectedIndex].value).split('|')[5]); if(minDiscountQty < 1) { minDiscountQty = 1 } $('#quantityinput@(pid)').val(minDiscountQty); } }); $('#unitID@(pid)').change(function(){ var minDiscountQty = (((document.getElementById("unitID"+"@(pid)")).getElementsByTagName('option')[(document.getElementById("unitID"+"@(pid)")).selectedIndex].value).split('|')[5]); if(minDiscountQty < 1) { minDiscountQty = 1 } $('#quantityinput@(pid)').val(minDiscountQty); }); </script>