CartThrob 9 documentation for ExpressionEngine commerce teams Visit CartThrob.com
CartThrob.com

Clear Cart

{exp:cartthrob:clear_cart} is an immediate-execution single tag that clears cart data. It is not a form tag.

By default, it clears cart items, coupon codes, shipping info, and manual totals.

See also:

Parameters

return

Optional redirect URL after the clear operation. If omitted, no redirect occurs.

return="cart/home"

clear_customer_info

If truthy, also clears:

  • customer info
  • custom data

Without this parameter, customer info/custom data are not cleared.

clear_customer_info="yes"

Behavior and Constraints

Default behavior:

  1. Clears cart items.
  2. Clears coupon codes.
  3. Clears shipping info.
  4. Clears manual totals.
  5. Saves the cart.
  6. Redirects only if return is provided.

Optional behavior:

  • If clear_customer_info is set, customer info and custom data are cleared in addition to the default clear operations.

Example

Basic clear + redirect

{exp:cartthrob:clear_cart return="cart/home"}

Clear cart + customer/custom data

{exp:cartthrob:clear_cart clear_customer_info="yes" return="cart/home"}

Clear cart without redirect

{exp:cartthrob:clear_cart}