Adding to ShoppingCart Using REST API

benyamin jain asked on March 4, 2018 11:03


I want to know is it possible to add product to shopping cart using REST API?

Correct Answer

Dragoljub Ilic answered on March 4, 2018 16:34

Hi Benyamin,

Here is peace of code that allows you to add products to shopping cart:

// Gets a product to add to the shopping cart
SKUInfo product = SKUInfoProvider.GetSKUs()
                                    .WhereEquals("SKUName", "NewProduct")

if (product != null)
    // Gets the current shopping cart
    ShoppingCartInfo cart = ECommerceContext.CurrentShoppingCart;

    // Creates the shopping cart in the database if it does not exist yet
    if (cart.ShoppingCartID == 0)

    // Prepares a shopping cart item representing 1 unit of the product
    ShoppingCartItemParameters parameters = new ShoppingCartItemParameters(product.SKUID, 1);
    ShoppingCartItemInfo cartItem = ShoppingCartInfoProvider.SetShoppingCartItem(cart, parameters);

    // Saves the shopping cart item to the shopping cart

    // Evaluates and recalculates the shopping cart (discounts, shipping, price totals, etc).

I took this code from Kentico 11 documentation. You can find more on this link.

Best regards, Dragoljub

0 votesVote for this answer Unmark Correct answer

Recent Answers

Juraj Ondrus answered on March 5, 2018 10:15

Maybe this article can be helpful too, althought it is for v9, the idea should be still the same.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.