Add Promotional Code

Current 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:

  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. 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);

Do you have some feedback for us?

If you have suggestions for improving this article,