Add Cart Lines
Abstract
Developer tasks for using service method AddCartLine
.
AddCartLine
is used to add items to a specific cart.
At your Visual Studio solution setup:
Reference the Sitecore.Commerce.Connect.CommerceServer and Sitecore.Commerce.dll.
Pick the class in your solution where want to use this service method.
To use the service method, paste the following code:
var provider = new CartServiceProvider(); // load or create the cart var loadCartRequest = new LoadCartByNameRequest("MyWebShop", "MyBasket", "UserId1"); var cart = provider.LoadCart(loadCartRequest).Cart; var cartline = new CommerceCartLine("Adventure Works Catalog", "AW190-11", "16", 1); var addCartLinesRequest = new AddCartLinesRequest(cart, new List<CartLine> { cartline }); var addCartLinesResult = provider.AddCartLines(addCartLinesRequest); // cart with newly added cartline cart = addCartLinesResult.Cart;