ClearCart

Posted by Community Admin on 05-Aug-2018 14:38

ClearCart

All Replies

Posted by Community Admin on 17-Feb-2012 00:00

What's the correct way to use this method? It's called against the OrdersManager rather than the CartOrder, so how do I tell it which cart to clear? (I assume it deletes the cart order and relevant details?)

Posted by Community Admin on 17-Feb-2012 00:00

Hey Nick,

This should clean up any left overs...

01.private void CleanUp()
02.
03.    var cartOrder = this.OrdersManager.GetCartOrder(this.GetShoppingCartId());
04.    this.OrdersManager.DeleteCartOrder(cartOrder);
05.    this.OrdersManager.SaveChanges();
06.    this.OrdersManager.DeleteOrphanedCartAddresses();
07.    this.OrdersManager.SaveChanges();
08.    this.RemoveShoppingCartCookie();
09.

Posted by Community Admin on 17-Feb-2012 00:00

Ok, thanks.

Does that suggest that ClearCart() doesn't do anything? Certainly it didn't do anything whenever I tried it earlier, and I couldn't find any documentation on it!

Posted by Community Admin on 17-Feb-2012 00:00

I think 'clearcart' ultimately is meant to empty a cart (not delete the cart itself, just the content in it) but I'm guessing here - like you can't find the documentation on it atm. But if I have time this weekend will test it out...

Posted by Community Admin on 17-Feb-2012 00:00

No worries. The code you provided does what was required so that'll do!

Thanks

This thread is closed