Add Promotional Code
Version: 8.2
Developer tasks for using service method AddPromoCode
.
AddPromoCode
is used to add promotional codes to 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:
RequestResponsevar 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);