Example #1
0
        public override bool AddGiftItem(int giftId, int quantity)
        {
            XmlDocument shoppingCartData = this.GetShoppingCartData();
            XmlNode     xmlNode          = shoppingCartData.SelectSingleNode("//sc/gf");
            XmlNode     xmlNode2         = xmlNode.SelectSingleNode(string.Concat(new object[]
            {
                "l[@g=",
                giftId,
                " and @d='",
                HiContext.Current.SiteSettings.UserId.Value,
                "']"
            }));

            if (xmlNode2 == null)
            {
                xmlNode2 = CookieShoppingData.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);
        }
Example #2
0
        private XmlDocument GetShoppingCartData()
        {
            XmlDocument xmlDocument = new XmlDocument();
            HttpCookie  httpCookie  = HiContext.Current.Context.Request.Cookies["Hid_distro_ShoppingCart_Data_New"];

            if (httpCookie == null || string.IsNullOrEmpty(httpCookie.Value))
            {
                xmlDocument = CookieShoppingData.CreateEmptySchema();
            }
            else
            {
                try
                {
                    xmlDocument.LoadXml(Globals.UrlDecode(httpCookie.Value));
                }
                catch
                {
                    this.ClearShoppingCart();
                    xmlDocument = CookieShoppingData.CreateEmptySchema();
                }
            }
            return(xmlDocument);
        }