Remove Parties

Developer tasks for using service method RemoveParties.

RemoveParties is used to remove party information from an existing cart.

At your visual studio solution setup:

  1. Reference the Sitecore.Commerce.Connect.CommerceServer and Sitecore.Commerce.dll.
  2. Pick the class in your solution where want to use this service method.
  3. Paste in the code below to use the service method.
    CartServiceProvider provider = new CartServiceProvider(); 
    // You should get a real user id.
    string userId = Guid.NewGuid().ToString("B");
    string anonymousUserId = Guid.NewGuid().ToString("B"); 
    var loadRequest =  new LoadCartByNameRequest("Website","MyBasket", userId);
    var loadResult = provider.LoadCart(loadRequest); 
    CommerceCart cart = loadResult.Cart as CommerceCart; 
    RemovePartiesRequest request = new RemovePartiesRequest(cart, new List<Party> cart.Parties.ElementAt(0) }); 
    var result = provider.RemoveParties(request);