Exemplo n.º 1
0
        public void UpdateCartItem(string skuId, int count, long memberId)
        {
            if (memberId > 0)
            {
                CartApplication.UpdateCart(skuId, count, memberId);
            }
            else
            {
                string cartInfo = WebHelper.GetCookie(CookieKeysCollection.HIMALL_CART);
                if (!string.IsNullOrWhiteSpace(cartInfo))
                {
                    string[] cartItems   = cartInfo.Split(',');
                    string   newCartInfo = string.Empty;
                    foreach (string cartItem in cartItems)
                    {
                        var cartItemParts = cartItem.Split(':');
                        if (cartItemParts[0] == skuId)
                        {
                            newCartInfo += "," + skuId + ":" + count;
                        }
                        else
                        {
                            newCartInfo += "," + cartItem;
                        }
                    }

                    if (!string.IsNullOrWhiteSpace(newCartInfo))
                    {
                        newCartInfo = newCartInfo.Substring(1);
                    }
                    WebHelper.SetCookie(CookieKeysCollection.HIMALL_CART, newCartInfo);
                }
                else
                {
                    WebHelper.SetCookie(CookieKeysCollection.HIMALL_CART, string.Format("{0}:{1}", skuId, count));
                }
            }
        }