Creating ShoppingCart in WebAPI2

Ashish Kashyap asked on April 21, 2020 16:57

Hi, I would like to know if Kentico will work seemlessly with WebAPI2 or not considering Web APIs are state less? I tried to get a shopping cart using IShoppingService GetCurrentShoppingCart() method but I am not getting the shopping cart. Here are few scenarios: 1. I am using WebAPI2. Not using Cookies, Caching or Session. 2. I am using Token based authentication. 3. I am using Postman to consume WebAPI and passing Autorization Token. 4. I have front end as AngularJS and Mobile (Xamarin) who will be consuming WebAPI2.

Here is the architecture we are proposing: Front End : (AngularJS) & (Mobile APP - Xamarin) -> This will consume WebAPI2 Backend : WebAPI2 --> Web API2 will consume to Kentico APIs. Database : SQL Server

I would like to know if Kentico will work seemlessly with WebAPI2 or not?

Recent Answers


Dmitry Bastron answered on April 21, 2020 18:32

Hi Ashish,

What you are asking for is technically achievable but will require customizations. It is by design that Shopping Cart relies on cookie and cache in the session because it works well for most e-commerce web scenarios. But shopping cart behavior is customizable, please refer to the documentation.

For example, you can have your own custom implementation of ICurrentShoppingCartService which will be reading cart GUID from Web API request parameters rather than cookies. And in the code you can use ShoppingCartInfoProvider with ShoppingCartInfo objects. I hope it gives you an idea how to proceed with this.

1 votesVote for this answer Mark as a Correct answer

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