コード例 #1
0
ファイル: CartHelper.cs プロジェクト: sky63886/Himall3.3
 public void RemoveFromCart(IEnumerable <string> skuIds, long memberId)
 {
     if (memberId > 0)
     {
         CartApplication.DeleteCartItem(skuIds, 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)
             {
                 string[] cartItemParts = cartItem.Split(':');
                 string   cartItemSkuId = cartItemParts[0];
                 if (!skuIds.Contains(cartItemSkuId))
                 {
                     newCartInfo += "," + cartItem;
                 }
             }
             if (!string.IsNullOrWhiteSpace(newCartInfo))
             {
                 newCartInfo = newCartInfo.Substring(1);
             }
             WebHelper.SetCookie(CookieKeysCollection.HIMALL_CART, newCartInfo);
         }
     }
 }