Update Parties

Developer tasks for using service method UpdateParties.

UpdateParties is used to update party information in 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); 
    CommerceCarttoCart = loadResult.Cart as CommerceCart; 
    loadRequest = newLoadCartByNameRequest("Website", "MyBasket" anonymousUserId);
    loadResult = provider.LoadCart(loadRequest); 
    CommerceCart fromCart = loadResult.Cart as CommerceCart; 
    var mergeRequest = new MergeCartRequest(fromCart, toCart);
    provider.MergeCart(mergeRequest);