please help me to solve this issue

ramesh perera asked on October 30, 2014 08:48

In kentico 7 i used following line. can you please explain me how it look like in kentico 8.1

CMSContext.ClearShoppingCart();

Thanks Ramesh

Recent Answers


Michal Kadák answered on October 30, 2014 10:31

Hi,

you can use the following code:

ECommerceContext.CurrentShoppingCart = null;

Let me know if I can help you any further.

0 votesVote for this answer Mark as a Correct answer

ramesh perera answered on October 30, 2014 12:24

Hi michal Thanks for the reply but it is not working. what i need to know is clear the contents of the current shopping cart and add new blank shopping cart to current shopping cart object

Thanks

0 votesVote for this answer Mark as a Correct answer

Michal Kadák answered on October 30, 2014 13:49

Hi,

previous code clears the cart from cookies and session, but the cart is still in the database and it can be loaded via "current user -> cart" binding. Please use this:

ShoppingCartInfoProvider.DeleteShoppingCartInfo(ECommerceContext.CurrentShoppingCart.ShoppingCartID);
ECommerceContext.CurrentShoppingCart = null;

Sorry for the inconvenience.

0 votesVote for this answer Mark as a Correct answer

ramesh perera answered on October 30, 2014 14:08

Thanks michal. i use the following code to empty the cart content. and try to add new empty shopping cart. it clear all the items. but not create new shoppingcart

ShoppingCartInfoProvider.EmptyShoppingCart(ShoppingCart); ECommerceContext.CurrentShoppingCart = ShoppingCartInfoProvider.CreateShoppingCartInfo(SiteContext.CurrentSiteID);

0 votesVote for this answer Mark as a Correct answer

Michal Kadák answered on October 30, 2014 14:31

ECommerceContext.CurrentShoppingCart will automatically create new one if the current cart is null. Just delete the cart from the database, set ECommerceContext.CurrentShoppingCart to null and try to get the cart object from ECommerceContext.CurrentShoppingCart. You will get brand new cart object.

0 votesVote for this answer Mark as a Correct answer

Yehuda Lando answered on October 30, 2014 19:14

I use ShoppingCart.CartItems.Clear(); to clear the items in the shopping cart.

0 votesVote for this answer Mark as a Correct answer

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