示例#1
0
        private XmlDocument GetShoppingCartData()
        {
            XmlDocument xmlDocument = new XmlDocument();

            xmlDocument.XmlResolver = null;
            HttpCookie httpCookie = HttpContext.Current.Request.Cookies["Hid_Hishop_ShoppingCart_Data_New"];

            if (httpCookie == null || string.IsNullOrEmpty(httpCookie.Value))
            {
                xmlDocument = CookieShoppingDao.CreateEmptySchema();
            }
            else
            {
                try
                {
                    xmlDocument.LoadXml(Globals.UrlDecode(httpCookie.Value));
                }
                catch
                {
                    this.ClearShoppingCart();
                    xmlDocument = CookieShoppingDao.CreateEmptySchema();
                }
            }
            return(xmlDocument);
        }
示例#2
0
        public bool AddGiftItem(int giftId, int quantity)
        {
            XmlDocument shoppingCartData = this.GetShoppingCartData();
            XmlNode     xmlNode          = shoppingCartData.SelectSingleNode("//sc/gf");
            XmlNode     xmlNode2         = xmlNode.SelectSingleNode("l[@g=" + giftId + "]");

            if (xmlNode2 == null)
            {
                xmlNode2 = CookieShoppingDao.CreateGiftLineItemNode(shoppingCartData, giftId, quantity);
                xmlNode.InsertBefore(xmlNode2, xmlNode.FirstChild);
            }
            else
            {
                xmlNode2.Attributes["q"].Value = (int.Parse(xmlNode2.Attributes["q"].Value) + quantity).ToString(CultureInfo.InvariantCulture);
            }
            this.SaveShoppingCartData(shoppingCartData);
            return(true);
        }
示例#3
0
 public AddCartItemStatus AddLineItem(string skuId, int quantity, int storeId = 0)
 {
     if (this.IsExistSkuId(skuId))
     {
         XmlDocument shoppingCartData = this.GetShoppingCartData();
         XmlNode     xmlNode          = shoppingCartData.SelectSingleNode("//sc/lis");
         XmlNode     xmlNode2         = xmlNode.SelectSingleNode("l[@s='" + skuId + "|" + storeId + "']");
         if (xmlNode2 == null)
         {
             xmlNode2 = CookieShoppingDao.CreateLineItemNode(shoppingCartData, skuId + "|" + storeId, quantity);
             xmlNode.InsertBefore(xmlNode2, xmlNode.FirstChild);
         }
         else
         {
             xmlNode2.Attributes["q"].Value = (int.Parse(xmlNode2.Attributes["q"].Value) + quantity).ToString(CultureInfo.InvariantCulture);
         }
         this.SaveShoppingCartData(shoppingCartData);
         return(AddCartItemStatus.Successed);
     }
     return(AddCartItemStatus.ProductNotExists);
 }