/// <summary> /// Save cart /// </summary> public void Save(Boolean debugMode = false) { if (Info != null) { Info.RemoveXmlNode("genxml/docs"); var strDocs = "<docs>"; foreach (var d in DocList) { var nbi = d.Value; if (nbi.XMLData != "") { strDocs += nbi.XMLData; } } strDocs += "</docs>"; Info.AddXmlNode(strDocs, "docs", "genxml"); var modCtrl = new NBrightBuyController(); Info.ItemID = modCtrl.Update(Info); if (StoreSettings.Current.DebugModeFileOut) { Info.XMLDoc.Save(PortalSettings.Current.HomeDirectoryMapPath + "debug_userdata.xml"); } Exists = true; } }
public void Update(NBrightInfo info) { var localfields = info.GetXmlProperty("genxml/hidden/localizedfields").Split(','); foreach (var f in localfields) { if (f == "genxml/edt/message") { // special processing for editor, to place code in standard place. if (DataLangRecord.XMLDoc.SelectSingleNode("genxml/edt") == null) { DataLangRecord.AddSingleNode("edt", "", "genxml"); } if (info.GetXmlProperty("genxml/textbox/message") == "") { DataLangRecord.SetXmlProperty(f, info.GetXmlProperty("genxml/edt/message")); } else { DataLangRecord.SetXmlProperty(f, info.GetXmlProperty("genxml/textbox/message")); // ajax on ckeditor (Ajax diesn't work for telrik) } } else { DataLangRecord.SetXmlProperty(f, info.GetXmlProperty(f)); } DataRecord.RemoveXmlNode(f); } var fields = info.GetXmlProperty("genxml/hidden/fields").Split(','); foreach (var f in fields) { DataRecord.SetXmlProperty(f, info.GetXmlProperty(f)); // if we have a image field then we need to create the imageurl field if (info.GetXmlProperty(f.Replace("textbox/", "hidden/hidinfo")) == "Img=True") { DataRecord.SetXmlProperty(f.Replace("textbox/", "hidden/") + "url", StoreSettings.Current.FolderImages + "/" + info.GetXmlProperty(f.Replace("textbox/", "hidden/hid"))); DataRecord.SetXmlProperty(f.Replace("textbox/", "hidden/") + "path", StoreSettings.Current.FolderImagesMapPath + "\\" + info.GetXmlProperty(f.Replace("textbox/", "hidden/hid"))); } if (f == "genxml/dropdownlist/ddlparentcatid") { var parentitemid = info.GetXmlProperty(f); if (!Utils.IsNumeric(parentitemid)) { parentitemid = "0"; } if (DataRecord.ParentItemId != Convert.ToInt32(parentitemid)) { _oldcatcascadeid = DataRecord.ParentItemId; _doCascadeIndex = true; DataRecord.ParentItemId = Convert.ToInt32(parentitemid); } } DataLangRecord.RemoveXmlNode(f); } }
public void Update(NBrightInfo updateInfo) { // update email var email = updateInfo.GetXmlProperty("genxml/textbox/email"); if (_userInfo != null && Utils.IsEmail(email) && (_userInfo.Email != email)) { _userInfo.Email = email; UserController.UpdateUser(PortalSettings.Current.PortalId, _userInfo); } // ClientEditorRole var clientEditorRole = updateInfo.GetXmlProperty("genxml/checkbox/clienteditorrole"); if (clientEditorRole == "True") { AddClientEditorRole(); } else { RemoveClientEditorRole(); } // save client data fields. var objCtrl = new NBrightBuyController(); DataRecord = objCtrl.GetByType(PortalId, -1, "CLIENT", _userInfo.UserID.ToString("")); DataRecord.XMLData = updateInfo.XMLData; DataRecord.RemoveXmlNode("genxml/hidden/xmlupdatediscountcodedata"); DataRecord.RemoveXmlNode("genxml/hidden/xmlupdatevouchercodedata"); objCtrl.Update(DataRecord); // update Discount codes var strXml = Utils.UnCode(updateInfo.GetXmlProperty("genxml/hidden/xmlupdatediscountcodedata")); UpdateDiscountCodes(strXml); strXml = Utils.UnCode(updateInfo.GetXmlProperty("genxml/hidden/xmlupdatevouchercodedata")); UpdateVoucherCodes(strXml); }
/// <summary> /// Save cart /// </summary> public void Save(Boolean debugMode = false) { //save cart var strXML = "<list>"; var lp = 0; foreach (var info in _discountcodesList) { info.SetXmlProperty("genxml/hidden/index", lp.ToString("D")); strXML += info.XMLData; lp += 1; } strXML += "</list>"; Info.RemoveXmlNode("genxml/list"); Info.AddXmlNode(strXML, "list", "genxml"); if (Info != null) { var modCtrl = new NBrightBuyController(); Info.ItemID = modCtrl.Update(Info); } }
/// <summary> /// Save cart /// </summary> public void Save(Boolean portallevelsave = true) { //save cart var strXml = "<plugin>"; var lp = 0; foreach (var info in _pluginList) { info.SetXmlProperty("genxml/hidden/index", lp.ToString(""), TypeCode.String, false); info.SetXmlProperty("genxml/textbox/ctrl", info.GetXmlProperty("genxml/textbox/ctrl").Trim().ToLower()); strXml += info.XMLData; lp += 1; } strXml += "</plugin>"; var nbi = new NBrightInfo(true); nbi.RemoveXmlNode("genxml/plugin"); nbi.AddXmlNode(strXml, "plugin", "genxml"); _templCtrl.SaveTemplate("menuplugin.xml", nbi.XMLData, portallevelsave); NBrightBuyUtils.RemoveModCache(0); Load(); // reload newly created plugin file, to ensure cache and pluigin list is correct. }
public void Update(NBrightInfo info) { // build list of xpath fields that need processing. var updatefields = new List <String>(); var fieldList = NBrightBuyUtils.GetAllFieldxPaths(info); foreach (var xpath in fieldList) { if (info.GetXmlProperty(xpath + "/@update") == "lang") { updatefields.Add(xpath); } } foreach (var f in updatefields) { if (f.EndsWith("/message")) { // special processing for editor, to place code in standard place. if (DataLangRecord.XMLDoc.SelectSingleNode("genxml/edt") == null) { DataLangRecord.AddSingleNode("edt", "", "genxml"); } if (info.GetXmlProperty("genxml/textbox/message") == "") { DataLangRecord.SetXmlProperty("genxml/edt/message", info.GetXmlPropertyRaw("genxml/edt/message")); } else { DataLangRecord.SetXmlProperty("genxml/edt/message", info.GetXmlPropertyRaw("genxml/textbox/message")); // ajax on ckeditor (Ajax diesn't work for telrik) } } else { DataLangRecord.RemoveXmlNode(f); var xpathDest = f.Split('/'); if (xpathDest.Count() >= 2) { DataLangRecord.AddXmlNode(info.XMLData, f, xpathDest[0] + "/" + xpathDest[1]); } } var datatype = info.GetXmlProperty(f + "/@datatype"); if (datatype == "date") { DataLangRecord.SetXmlProperty(f, info.GetXmlProperty(f), TypeCode.DateTime); } else if (datatype == "double") { DataLangRecord.SetXmlPropertyDouble(f, info.GetXmlProperty(f)); } else if (datatype == "html") { DataLangRecord.SetXmlProperty(f, info.GetXmlPropertyRaw(f)); } else { DataLangRecord.SetXmlProperty(f, info.GetXmlProperty(f).Trim()); } DataRecord.RemoveXmlNode(f); } updatefields = new List <String>(); fieldList = NBrightBuyUtils.GetAllFieldxPaths(info); foreach (var xpath in fieldList) { var id = xpath.Split('/').Last(); if (info.GetXmlProperty(xpath + "/@update") == "save") { updatefields.Add(xpath); } } foreach (var f in updatefields) { var datatype = info.GetXmlProperty(f + "/@datatype"); if (datatype == "date") { DataRecord.SetXmlProperty(f, info.GetXmlProperty(f), TypeCode.DateTime); } else if (datatype == "double") { DataRecord.SetXmlPropertyDouble(f, info.GetXmlProperty(f)); } else if (datatype == "html") { DataRecord.SetXmlProperty(f, info.GetXmlPropertyRaw(f)); } else { DataRecord.SetXmlProperty(f, info.GetXmlProperty(f)); } // if we have a image field then we need to create the imageurl field if (info.GetXmlProperty(f.Replace("textbox/", "hidden/hidinfo")) == "Img=True") { DataRecord.SetXmlProperty(f.Replace("textbox/", "hidden/") + "url", StoreSettings.Current.FolderImages + "/" + info.GetXmlProperty(f.Replace("textbox/", "hidden/hid"))); DataRecord.SetXmlProperty(f.Replace("textbox/", "hidden/") + "path", StoreSettings.Current.FolderImagesMapPath + "\\" + info.GetXmlProperty(f.Replace("textbox/", "hidden/hid"))); } if (f == "genxml/dropdownlist/ddlparentcatid") { var parentitemid = info.GetXmlProperty(f); if (!Utils.IsNumeric(parentitemid)) { parentitemid = "0"; } if (DataRecord.ParentItemId != Convert.ToInt32(parentitemid)) { _oldcatcascadeid = DataRecord.ParentItemId; _doCascadeIndex = true; DataRecord.ParentItemId = Convert.ToInt32(parentitemid); } } DataLangRecord.RemoveXmlNode(f); } }
private NBrightInfo ValidateCartItem(int portalId, int userId, NBrightInfo cartItemInfo, Boolean removeZeroQtyItems = false) { #region "get cart values" cartItemInfo = NBrightBuyUtils.ProcessEventProvider(EventActions.ValidateCartItemBefore, cartItemInfo); var modelid = cartItemInfo.GetXmlProperty("genxml/modelid"); var prdid = cartItemInfo.GetXmlPropertyInt("genxml/productid"); var qty = cartItemInfo.GetXmlPropertyDouble("genxml/qty"); var lang = cartItemInfo.GetXmlProperty("genxml/lang"); if (removeZeroQtyItems && qty == 0) { return(null); // Remove zero qty item } if (lang == "") { lang = Utils.GetCurrentCulture(); } var prd = ProductUtils.GetProductData(prdid, lang); if (!prd.Exists || prd.Disabled) { return(null); //Invalid product remove from cart } // update product xml data on cart (product may have change via plugin so always replace) cartItemInfo.RemoveXmlNode("genxml/productxml"); // add entitytype for validation methods prd.Info.SetXmlProperty("genxml/entitytypecode", prd.Info.TypeCode); cartItemInfo.AddSingleNode("productxml", prd.Info.XMLData, "genxml"); var prdModel = prd.GetModel(modelid); if (prdModel == null) { return(null); // Invalid Model remove from cart } // check if dealer (for tax calc) if (NBrightBuyUtils.IsDealer()) { cartItemInfo.SetXmlProperty("genxml/isdealer", "True"); } else { cartItemInfo.SetXmlProperty("genxml/isdealer", "False"); } // check for price change var unitcost = prdModel.GetXmlPropertyDouble("genxml/textbox/txtunitcost"); var dealercost = prdModel.GetXmlPropertyDouble("genxml/textbox/txtdealercost"); var saleprice = prdModel.GetXmlPropertyDouble("genxml/textbox/txtsaleprice"); var dealersalecost = prdModel.GetXmlPropertyDouble("genxml/textbox/txtdealersale"); // always make sale price best price if (unitcost > 0 && (unitcost < saleprice || saleprice <= 0)) { saleprice = unitcost; } // if we have a promoprice use it as saleprice (This is passed in via events provider like "Multi-Buy promotions") if (cartItemInfo.GetXmlPropertyDouble("genxml/promoprice") > 0 && cartItemInfo.GetXmlPropertyDouble("genxml/promoprice") < saleprice) { saleprice = cartItemInfo.GetXmlPropertyDouble("genxml/promoprice"); } // always assign the dealercost the best price. if (dealersalecost > 0 && dealersalecost < dealercost) { dealercost = dealersalecost; } if (saleprice > 0 && (saleprice < dealercost || dealercost <= 0)) { dealercost = saleprice; } if (unitcost > 0 && (unitcost < dealercost || dealercost <= 0)) { dealercost = unitcost; } // calc sell price // sellcost = the calculated cost of the item. var sellcost = unitcost; if (saleprice > 0 && saleprice < sellcost) { sellcost = saleprice; } if (NBrightBuyUtils.IsDealer()) { if (dealercost > 0 && dealercost < sellcost) { sellcost = dealercost; } } // -------------------------------------------- #endregion if (prdModel != null) { #region "Stock Control" var stockon = prdModel.GetXmlPropertyBool("genxml/checkbox/chkstockon"); var stocklevel = prdModel.GetXmlPropertyDouble("genxml/textbox/txtqtyremaining"); var minStock = prdModel.GetXmlPropertyDouble("genxml/textbox/txtqtyminstock"); if (minStock == 0) { minStock = StoreSettings.Current.GetInt("minimumstocklevel"); } var maxStock = prdModel.GetXmlPropertyDouble("genxml/textbox/txtqtystockset"); var weight = prdModel.GetXmlPropertyDouble("genxml/textbox/weight"); if (stockon) { stocklevel = stocklevel - minStock; stocklevel = stocklevel - prd.GetModelTransQty(modelid, _cartId); if (stocklevel < qty) { qty = stocklevel; if (qty <= 0) { qty = 0; cartItemInfo.SetXmlProperty("genxml/validatecode", "OUTOFSTOCK"); } else { cartItemInfo.SetXmlProperty("genxml/validatecode", "STOCKADJ"); } base.SetValidated(false); cartItemInfo.SetXmlPropertyDouble("genxml/qty", qty.ToString("")); } } #endregion #region "Addtional options costs" Double additionalCosts = 0; var optNods = cartItemInfo.XMLDoc.SelectNodes("genxml/options/*"); if (optNods != null) { var lp = 1; foreach (XmlNode nod in optNods) { var optid = nod.SelectSingleNode("optid"); if (optid != null) { var optvalueid = nod.SelectSingleNode("optvalueid"); if (optvalueid != null && optvalueid.InnerText != "False") { XmlNode optvalcostnod; if (optvalueid.InnerText == "True") { optvalcostnod = cartItemInfo.XMLDoc.SelectSingleNode("genxml/productxml/genxml/optionvalues[@optionid='" + optid.InnerText + "']/genxml/textbox/txtaddedcost"); } else { optvalcostnod = cartItemInfo.XMLDoc.SelectSingleNode("genxml/productxml/genxml/optionvalues/genxml[./hidden/optionvalueid='" + optvalueid.InnerText + "']/textbox/txtaddedcost"); } if (optvalcostnod != null) { var optvalcost = optvalcostnod.InnerText; if (Utils.IsNumeric(optvalcost)) { cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvalcost", optvalcost); var optvaltotal = Convert.ToDouble(optvalcost, CultureInfo.GetCultureInfo("en-US")) * qty; cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvaltotal", optvaltotal); additionalCosts += optvaltotal; } } else { cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvalcost", "0"); cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvaltotal", "0"); } } } lp += 1; } } if (qty > 0) // can't devide by zero { unitcost += (additionalCosts / qty); if (dealercost > 0) { dealercost += (additionalCosts / qty); // zero turns off } if (saleprice > 0) { saleprice += (additionalCosts / qty); // zero turns off } sellcost += (additionalCosts / qty); } #endregion var totalcost = qty * unitcost; var totalsellcost = qty * sellcost; var totalweight = weight * qty; cartItemInfo.SetXmlPropertyDouble("genxml/unitcost", unitcost); cartItemInfo.SetXmlPropertyDouble("genxml/dealercost", dealercost); cartItemInfo.SetXmlPropertyDouble("genxml/saleprice", saleprice); cartItemInfo.SetXmlPropertyDouble("genxml/totalweight", totalweight.ToString("")); cartItemInfo.SetXmlPropertyDouble("genxml/totalcost", totalcost); cartItemInfo.SetXmlPropertyDouble("genxml/totaldealerbonus", (totalcost - (qty * dealercost))); Double salediscount = 0; Double discountcodeamt = 0; Double totaldiscount = 0; //add update genxml/discountcodeamt var discountcode = PurchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/textbox/promocode"); if (discountcode != "") { cartItemInfo = DiscountCodeInterface.UpdateItemPercentDiscountCode(PortalId, UserId, cartItemInfo, discountcode); discountcodeamt = cartItemInfo.GetXmlPropertyDouble("genxml/discountcodeamt"); if (discountcodeamt > 0) { PurchaseInfo.SetXmlProperty("genxml/discountprocessed", "False"); } } if (NBrightBuyUtils.IsDealer()) { salediscount = (unitcost - dealercost); } else { salediscount = (unitcost - saleprice); } totaldiscount = (salediscount * qty) + discountcodeamt; // add on any promo code amount if (totaldiscount < 0) { totaldiscount = 0; } // if we have a promodiscount use it if (cartItemInfo.GetXmlPropertyDouble("genxml/promodiscount") > 0) { totaldiscount = cartItemInfo.GetXmlPropertyDouble("genxml/promodiscount"); totalcost = totalcost - totaldiscount; if (totalcost < 0) { totalcost = 0; } cartItemInfo.SetXmlPropertyDouble("genxml/appliedtotalcost", totalcost); } cartItemInfo.SetXmlPropertyDouble("genxml/totaldiscount", totaldiscount); // if product is on sale then we need to display the sale price in the cart, and any discount codes don;t show at this cart item level, only on the order total. cartItemInfo.SetXmlPropertyDouble("genxml/appliedtotalcost", totalsellcost); cartItemInfo.SetXmlPropertyDouble("genxml/appliedcost", sellcost); // calc tax for item var taxproviderkey = PurchaseInfo.GetXmlProperty("genxml/hidden/taxproviderkey"); var taxprov = TaxInterface.Instance(taxproviderkey); if (taxprov != null) { var nbi = (NBrightInfo)cartItemInfo.Clone(); cartItemInfo.SetXmlPropertyDouble("genxml/taxcost", taxprov.CalculateItemTax(nbi)); } } cartItemInfo = NBrightBuyUtils.ProcessEventProvider(EventActions.ValidateCartItemAfter, cartItemInfo); return(cartItemInfo); }
/// <summary> /// Save cart /// </summary> public void Save(Boolean portallevelsave = true) { //save cart var strXml = "<plugin>"; var lp = 0; foreach (var info in _pluginList) { info.SetXmlProperty("genxml/hidden/index", lp.ToString(""), TypeCode.String, false); info.SetXmlProperty("genxml/textbox/ctrl", info.GetXmlProperty("genxml/textbox/ctrl").Trim().ToLower()); strXml += info.XMLData; lp += 1; } strXml += "</plugin>"; var nbi = new NBrightInfo(true); nbi.RemoveXmlNode("genxml/plugin"); nbi.AddXmlNode(strXml, "plugin", "genxml"); _templCtrl.SaveTemplate("menuplugin.xml", nbi.XMLData, portallevelsave); NBrightBuyUtils.RemoveModCache(0); }
private NBrightInfo ValidateCartItem(int portalId, int userId, NBrightInfo cartItemInfo) { cartItemInfo = NBrightBuyUtils.ProcessEventProvider(EventActions.ValidateCartItemBefore, cartItemInfo); var modelid = cartItemInfo.GetXmlProperty("genxml/modelid"); var prdid = cartItemInfo.GetXmlPropertyInt("genxml/productid"); var qty = cartItemInfo.GetXmlPropertyDouble("genxml/qty"); var prd = ProductUtils.GetProductData(prdid, Utils.GetCurrentCulture()); if (!prd.Exists || prd.Disabled) return null; //Invalid product remove from cart var prdModel = prd.GetModel(modelid); if (prdModel == null) return null; // Invalid Model remove from cart // check if dealer (for tax calc) var userInfo = UserController.GetUserById(portalId, userId); if (userInfo != null && userInfo.IsInRole(StoreSettings.DealerRole) && StoreSettings.Current.Get("enabledealer") == "True") cartItemInfo.SetXmlProperty("genxml/isdealer", "True"); else cartItemInfo.SetXmlProperty("genxml/isdealer", "False"); // check for price change var unitcost = prdModel.GetXmlPropertyDouble("genxml/textbox/txtunitcost"); var dealercost = prdModel.GetXmlPropertyDouble("genxml/textbox/txtdealercost"); var saleprice = prdModel.GetXmlPropertyDouble("genxml/textbox/txtsaleprice"); // calc sale price var sellcost = unitcost; if (saleprice > 0 && saleprice < sellcost) sellcost = saleprice; //stock control if (prdModel != null) { var stockon = prdModel.GetXmlPropertyBool("genxml/checkbox/chkstockon"); var stocklevel = prdModel.GetXmlPropertyDouble("genxml/textbox/txtqtyremaining"); var minStock = prdModel.GetXmlPropertyDouble("genxml/textbox/txtqtyminstock"); if (minStock == 0) minStock = StoreSettings.Current.GetInt("minimumstocklevel"); var maxStock = prdModel.GetXmlPropertyDouble("genxml/textbox/txtqtystockset"); var weight = prdModel.GetXmlPropertyDouble("genxml/textbox/weight"); if (stockon) { stocklevel = stocklevel - minStock; stocklevel = stocklevel - prd.GetModelTransQty(modelid, _cartId); if (stocklevel < qty) { qty = stocklevel; if (qty <= 0) { qty = 0; cartItemInfo.SetXmlProperty("genxml/validatecode", "OUTOFSTOCK"); } else { cartItemInfo.SetXmlProperty("genxml/validatecode", "STOCKADJ"); } base.SetValidated(false); cartItemInfo.SetXmlPropertyDouble("genxml/qty", qty.ToString("")); } } Double additionalCosts = 0; var optNods = cartItemInfo.XMLDoc.SelectNodes("genxml/options/*"); if (optNods != null) { var lp = 1; foreach (XmlNode nod in optNods) { var optid = nod.SelectSingleNode("optid"); if (optid != null) { var optvalueid = nod.SelectSingleNode("optvalueid"); if (optvalueid != null && optvalueid.InnerText != "False") { XmlNode optvalcostnod; if (optvalueid.InnerText == "True") optvalcostnod = cartItemInfo.XMLDoc.SelectSingleNode("genxml/productxml/genxml/optionvalues[@optionid='" + optid.InnerText + "']/genxml/textbox/txtaddedcost"); else optvalcostnod = cartItemInfo.XMLDoc.SelectSingleNode("genxml/productxml/genxml/optionvalues/genxml[./hidden/optionvalueid='" + optvalueid.InnerText + "']/textbox/txtaddedcost"); if (optvalcostnod != null) { var optvalcost = optvalcostnod.InnerText; if (Utils.IsNumeric(optvalcost)) { cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvalcost", optvalcost); var optvaltotal = Convert.ToDouble(optvalcost, CultureInfo.GetCultureInfo("en-US"))*qty; cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvaltotal", optvaltotal); additionalCosts += optvaltotal; } } else { cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvalcost", "0"); cartItemInfo.SetXmlPropertyDouble("genxml/options/option[" + lp + "]/optvaltotal", "0"); } } } lp += 1; } } if (qty > 0) // can't devide by zero { unitcost += (additionalCosts / qty); if (dealercost > 0) dealercost += (additionalCosts / qty); // zero turns off if (saleprice > 0) saleprice += (additionalCosts / qty); // zero turns off sellcost += (additionalCosts / qty); } var totalcost = qty * sellcost; var totaldealercost = qty * dealercost; var totalweight = weight * qty; if (unitcost != cartItemInfo.GetXmlPropertyDouble("genxml/unitcost") || dealercost != cartItemInfo.GetXmlPropertyDouble("genxml/dealercost") || saleprice != cartItemInfo.GetXmlPropertyDouble("genxml/saleprice")) { cartItemInfo.SetXmlPropertyDouble("genxml/unitcost", unitcost); cartItemInfo.SetXmlPropertyDouble("genxml/dealercost", dealercost); cartItemInfo.SetXmlPropertyDouble("genxml/saleprice", saleprice); cartItemInfo.RemoveXmlNode("genxml/productxml"); cartItemInfo.AddSingleNode("productxml", prd.Info.XMLData, "genxml"); } cartItemInfo.SetXmlPropertyDouble("genxml/totalweight", totalweight.ToString("")); cartItemInfo.SetXmlPropertyDouble("genxml/totalcost", totalcost); cartItemInfo.SetXmlPropertyDouble("genxml/totaldealercost", totaldealercost); cartItemInfo.SetXmlPropertyDouble("genxml/totaldealerbonus", (totalcost - totaldealercost)); Double salediscount = 0; Double dealerdiscount = 0; Double discountcodeamt = 0; Double totaldiscount = 0; //add update genxml/discountcodeamt if (saleprice == 0) // discount codes are only valid for items not on sale { var discountcode = PurchaseInfo.GetXmlProperty("genxml/extrainfo/genxml/textbox/promocode"); cartItemInfo = DiscountCodeInterface.UpdateItemPercentDiscountCode(PortalId, UserId, cartItemInfo, discountcode); discountcodeamt = cartItemInfo.GetXmlPropertyDouble("genxml/discountcodeamt"); if (discountcodeamt > 0) PurchaseInfo.SetXmlProperty("genxml/discountprocessed", "False"); totaldiscount = discountcodeamt; } else { salediscount = (unitcost - saleprice); totaldiscount = salediscount * qty; } var totalsalediscount = salediscount * qty; var totaldealerdiscount = dealerdiscount * qty; cartItemInfo.SetXmlPropertyDouble("genxml/totaldiscount", totaldiscount); cartItemInfo.SetXmlPropertyDouble("genxml/salediscount", totalsalediscount); cartItemInfo.SetXmlPropertyDouble("genxml/totaldealerdiscount", totaldealerdiscount); cartItemInfo.SetXmlPropertyDouble("genxml/appliedtotalcost", AppliedCost(portalId, userId, totalcost, totaldealercost)); cartItemInfo.SetXmlPropertyDouble("genxml/appliedcost", AppliedCost(portalId, userId, sellcost, dealercost)); // calc tax for item var taxproviderkey = PurchaseInfo.GetXmlProperty("genxml/hidden/taxproviderkey"); var taxprov = TaxInterface.Instance(taxproviderkey); if (taxprov != null) { var nbi = (NBrightInfo)cartItemInfo.Clone(); cartItemInfo.SetXmlPropertyDouble("genxml/taxcost", taxprov.CalculateItemTax(nbi)); } } cartItemInfo = NBrightBuyUtils.ProcessEventProvider(EventActions.ValidateCartItemAfter, cartItemInfo); return cartItemInfo; }
/// <summary> /// Save cookie to client /// </summary> public void Save() { #region "Get temp filename" var tempfilename = ""; if (_storageType == DataStorageType.SessionMemory) { if (HttpContext.Current.Session[_cookieName + "tempname"] != null) tempfilename = (String) HttpContext.Current.Session[_cookieName + "tempname"]; } else { tempfilename = Cookie.GetCookieValue(_portalId, _cookieName, "tempname", ""); } if (tempfilename == "") tempfilename = Utils.GetUniqueKey(12); if (_storageType == DataStorageType.SessionMemory) { HttpContext.Current.Session[_cookieName + "tempname"] = tempfilename; } else { Cookie.SetCookieValue(_portalId, _cookieName, "tempname", tempfilename, 1, ""); } #endregion var nbi = new NBrightInfo(true); if (XmlData != "") nbi.XMLData = XmlData; nbi.SetXmlProperty("genxml/Criteria", _criteria); nbi.SetXmlProperty("genxml/PageModuleId", PageModuleId); nbi.SetXmlProperty("genxml/PageNumber", PageNumber); nbi.SetXmlProperty("genxml/PageName", PageName); nbi.SetXmlProperty("genxml/PageSize", PageSize); nbi.SetXmlProperty("genxml/OrderBy", OrderBy); nbi.SetXmlProperty("genxml/CategoryId", CategoryId.ToString("D")); nbi.SetXmlProperty("genxml/RecordCount", RecordCount); nbi.SetXmlProperty("genxml/Mode", Mode); nbi.SetXmlProperty("genxml/OrderByIdx", OrderByIdx); if (!String.IsNullOrEmpty(SearchFormData)) { nbi.RemoveXmlNode("genxml/SearchFormData"); nbi.SetXmlProperty("genxml/SearchFormData", "",TypeCode.String,false); nbi.AddXmlNode(SearchFormData,"genxml", "genxml/SearchFormData"); } var filePath = StoreSettings.Current.FolderTempMapPath + "\\" + tempfilename; Utils.SaveFile(filePath, nbi.XMLData); Exists = true; }
/// <summary> /// Save cookie to client /// </summary> public void Save() { #region "Get temp filename" var tempfilename = ""; if (_storageType == DataStorageType.SessionMemory) { if (HttpContext.Current.Session[_cookieName + "tempname"] != null) tempfilename = (String)HttpContext.Current.Session[_cookieName + "tempname"]; } else { tempfilename = Cookie.GetCookieValue(_portalId, _cookieName, "tempname", ""); } if (tempfilename == "") tempfilename = Utils.GetUniqueKey(12); if (_storageType == DataStorageType.SessionMemory) { HttpContext.Current.Session[_cookieName + "tempname"] = tempfilename; } else { Cookie.SetCookieValue(_portalId, _cookieName, "tempname", tempfilename, 1, ""); } #endregion var nbi = new NBrightInfo(true); if (XmlData != "") nbi.XMLData = XmlData; nbi.SetXmlProperty("genxml/Criteria", _criteria); nbi.SetXmlProperty("genxml/PageModuleId", PageModuleId); nbi.SetXmlProperty("genxml/PageNumber", PageNumber); nbi.SetXmlProperty("genxml/PageName", PageName); nbi.SetXmlProperty("genxml/PageSize", PageSize); nbi.SetXmlProperty("genxml/OrderBy", OrderBy); nbi.SetXmlProperty("genxml/CategoryId", CategoryId.ToString("D")); nbi.SetXmlProperty("genxml/RecordCount", RecordCount); nbi.SetXmlProperty("genxml/Mode", Mode); nbi.SetXmlProperty("genxml/OrderByIdx", OrderByIdx); nbi.SetXmlProperty("genxml/FilterPropertyList", FilterPropertyList); var filterCSV = ""; foreach (var f in _filterPropertiesByProduct) { filterCSV += f.ToString() + ","; } nbi.SetXmlProperty("genxml/filterpropertycsv", filterCSV.TrimEnd(',')); if (!String.IsNullOrEmpty(SearchFormData)) { nbi.RemoveXmlNode("genxml/SearchFormData"); nbi.SetXmlProperty("genxml/SearchFormData", "", TypeCode.String, false); nbi.AddXmlNode(SearchFormData, "genxml", "genxml/SearchFormData"); } var filePath = StoreSettings.Current.FolderTempMapPath + "\\" + tempfilename; try { Utils.SaveFile(filePath, nbi.XMLData); } catch (Exception e) { // this is because the file's in use sometimes // we call it bad luck in those cases } Exists = true; }
/// <summary> /// Save cookie to client /// </summary> public void Save() { #region "Get temp filename" var tempfilename = ""; if (_storageType == DataStorageType.SessionMemory) { if (HttpContext.Current.Session[_cookieName + "tempname"] != null) { tempfilename = (String)HttpContext.Current.Session[_cookieName + "tempname"]; } } else { tempfilename = Cookie.GetCookieValue(_portalId, _cookieName, "tempname", ""); } if (tempfilename == "") { tempfilename = Utils.GetUniqueKey(12); } if (_storageType == DataStorageType.SessionMemory) { HttpContext.Current.Session[_cookieName + "tempname"] = tempfilename; } else { Cookie.SetCookieValue(_portalId, _cookieName, "tempname", tempfilename, 1, ""); } #endregion var nbi = new NBrightInfo(true); if (XmlData != "") { nbi.XMLData = XmlData; } nbi.SetXmlProperty("genxml/Criteria", _criteria); nbi.SetXmlProperty("genxml/PageModuleId", PageModuleId); nbi.SetXmlProperty("genxml/PageNumber", PageNumber); nbi.SetXmlProperty("genxml/PageName", PageName); nbi.SetXmlProperty("genxml/PageSize", PageSize); nbi.SetXmlProperty("genxml/OrderBy", OrderBy); nbi.SetXmlProperty("genxml/CategoryId", CategoryId.ToString("D")); nbi.SetXmlProperty("genxml/RecordCount", RecordCount); nbi.SetXmlProperty("genxml/Mode", Mode); nbi.SetXmlProperty("genxml/OrderByIdx", OrderByIdx); if (!String.IsNullOrEmpty(SearchFormData)) { nbi.RemoveXmlNode("genxml/SearchFormData"); nbi.SetXmlProperty("genxml/SearchFormData", "", TypeCode.String, false); nbi.AddXmlNode(SearchFormData, "genxml", "genxml/SearchFormData"); } var filePath = StoreSettings.Current.FolderTempMapPath + "\\" + tempfilename; Utils.SaveFile(filePath, nbi.XMLData); Exists = true; }