Developer tasks for using service method
RemovePromoCode.
RemovePromoCode is used to remove a promotional code from a
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();
var userId = Guid.NewGuid().ToString();
var loadCartRequest = new LoadCartByNameRequest("MyWebShop", "MyCart", userId);
var cart = provider.LoadCart(loadCartRequest).Cart;
var request = new AddPromoCodeRequest(cart, "12345");
var result = provider.AddPromoCode(request);
var removeRequest = new RemovePromoCodeRequest(cart, "12345");
var removeResult = provider.RemovePromoCode(removeRequest);