More in this section
Forums / Ecommerce / ClearCart

ClearCart

The forums are in read-only mode. In case that you want to directly contact the Progress Sitefinity team use the support center. In our Google Plus group you can find more than one thousand Sitefinity developers discussing different topics. For the Stack Overflow threads don’t forget to use the “Sitefinity” tag.
5 posts, 1 answered
  1. Nick
    Nick avatar
    113 posts
    Registered:
    21 Oct 2008
    17 Feb 2012
    Link to this post
    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?)
  2. Jochem Bökkers
    Jochem Bökkers avatar
    787 posts
    Registered:
    13 Aug 2007
    17 Feb 2012
    Link to this post
    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.}
    Answered
  3. Nick
    Nick avatar
    113 posts
    Registered:
    21 Oct 2008
    17 Feb 2012
    Link to this post
    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!
  4. Jochem Bökkers
    Jochem Bökkers avatar
    787 posts
    Registered:
    13 Aug 2007
    17 Feb 2012
    Link to this post
    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...
  5. Nick
    Nick avatar
    113 posts
    Registered:
    21 Oct 2008
    17 Feb 2012
    Link to this post
    No worries. The code you provided does what was required so that'll do!

    Thanks
5 posts, 1 answered