Clear shopping cart

This section describes how to remove all items from the shopping cart, and also remove information in CheckoutFlowInfo property of it.

To clear the shopping cart call the CurrentState.Current.ShoppingCart.Clear() method.

This will empty the shopping cart, and also remove the CheckoutFlowInfo contained in it. The shopping cart should be cleared to prepare it for a new order. Usually this step should be performed after the user is shown the receipt of the order he has made.

Therefore, you can use the Page_Unload event in your Order Receipt page, to call the Clear() method.

Using a button to clear shopping cart

Sometimes, it is necessary to provide the end customer with a option to clear his shopping cart. In that case you can use a normal ASP.net button control to clear the shopping cart. Call the ShoppingCart.Clear() method on the click event.

protected void Clear_Cart(object sender, EventArgs e)
        {
            CurrentState.ShoppingCart.Clear();
        }
Is this page helpful?
Thank you for your feedback!