it.thienthan
-
3/23/2012 11:27:59 PM
API AddShoppingCartItem v5 not using v6
Hello everybody !
My function using best on version 3,4,5 but don't using version 6, can you help me?
public static bool AddToShoppingCart(int skuId, int quantity) { try { // Get current shopping cart ShoppingCartInfo cart = ECommerceContext.CurrentShoppingCart; if (cart == null) { // If current shopping cart hasn't been created yet -> create new empty one cart = ShoppingCartInfoProvider.CreateShoppingCartInfo(CMSContext.CurrentSite.SiteID); // Associate new shopping cart with the current session ECommerceContext.CurrentShoppingCart = cart; } // Ensure shopping cart is saved to DB if (cart.ShoppingCartID == 0) { ShoppingCartInfoProvider.SetShoppingCartInfo(cart); } // Add item to the shopping cart ShoppingCartItemInfo product = cart.AddShoppingCartItem(skuId, quantity, null); // Update shopping cart item in database ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(product); // Update product options in database foreach (ShoppingCartItemInfo option in product.ProductOptions) { ShoppingCartItemInfoProvider.SetShoppingCartItemInfo(option); }
return true; } catch { } return false; }
|