Add Parties
Abstract
Developer tasks for using service method AddParties
.
AddParties
is used to add party information to an existing cart. In Sitecore Commerce 8.2 powered by Commerce Server and Commerce Server 11.4, parties are equivalent to Addresses on a basket.
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.
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"); var loadRequest = new LoadCartByNameRequest("Website","MyBasket", userId); var loadResult = provider.LoadCart(loadRequest); CommerceCart cart = loadResult.Cart as CommerceCart; CommerceParty party = new CommerceParty() { ExternalId = Guid.NewGuid().ToString("B"), Name = "ShippingAddress", Address1 = "Address 1 field", Address2 = "Address 2 field", City = "City field", Company = "Company field", Country = "Country field", CountryCode = "CND", Email = "a@b.com", EveningPhoneNumber = "111 111-1111", FaxNumber = "222 222-2222", FirstName = "John", LastName = "Smith", PhoneNumber = "333 333-3333", RegionCode = "01", RegionName = "Region field", State = "State field", ZipPostalCode = "HOH OHO" }; AddPartiesRequest request = new AddPartiesRequest(cart, new List<Party> { party });var result = provider.AddParties(request);