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:
- Clears cart items.
- Clears coupon codes.
- Clears shipping info.
- Clears manual totals.
- Saves the cart.
- Redirects only if
returnis provided.
Optional behavior:
- If
clear_customer_infois 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}