ClearCart - Ecommerce - Ecommerce - Progress Community
 Ecommerce

ClearCart

  • ClearCart
  • 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?)
  • 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.
  • 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!
  • 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...
  • No worries. The code you provided does what was required so that'll do!

    Thanks