shopping cart for anonymous user & logged in user

harshal bundelkhandi asked on March 10, 2020 15:36

Hi Support, User come to website and user logged in and added 2 items in the cart and user logged out and closed the browser. Again user visited the site and added 2 items in the shopping cart as anonymous user(without login) then he logged in so as per my understanding shopping cart must contained 4 items(previous 2 with login and 2 as anonymous user).

But shopping cart showing only 2 items added by anonymous user.

Can you please help me out on below:

1)Which shopping cart service can we have for above scenario. 2)How & where i can check where the shopping cart is override for the user. Thanks, Harshal

Correct Answer

Brenden Kehren answered on March 11, 2020 03:10

I believe there is a scheduled task which clears the shipping carts after a given time. You might want to check that scheduled task and possibly turn it off or set the value to a longer date if possible. This may resolve your problem.

1 votesVote for this answer Unmark Correct answer

Recent Answers


Dmitry Bastron answered on March 11, 2020 15:44

Hi Harshal,

This is a default behavior to override user's existing cart with anonymous visitor when he logs in. This can be customized, please refer to shopping cart customization docs. You need to implement your desired logic in custom implementation of ICurrentShoppingCartService interface. To start with something, look at the decompiled default Kentico implementation CurrentShoppingCartService, note HandleCandidateCart method there, my best guess would be that you need to merge two cards somewhere here. And to merge carts you can use the following method:

ShoppingCartInfoProvider.CopyShoppingCartItems(sourceCart, destinationCard);
0 votesVote for this answer Mark as a Correct answer

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