Delete from Cart
{exp:cartthrob:delete_from_cart} is an immediate-execution single tag. It removes one matching item and can optionally redirect. It is not a form tag.
See also:
Parameters
row_id
Removes the item with this exact cart row_id.
row_id="{segment_3}"
If row_id is present, this path is used first.
entry_id
If row_id is not provided, CartThrob can match an item by entry_id and remove the first matched row.
entry_id="{segment_3}"
item_options:your_option_name
Optional item-option match criteria used with entry_id matching.
item_options:size="large"
item_option:your_option_name (singular) is also accepted.
return
Optional redirect URL after processing. If omitted, no redirect occurs.
return="cart/view_cart"
Behavior and Constraints
- Executes start/end hooks:
cartthrob_delete_from_cart_startcartthrob_delete_from_cart_end
- If
row_idis provided, removes that row directly. - Otherwise, if
entry_idis provided, tries to find one matching item (optionally refined byitem_options:*) and removes that matched row. - If neither path finds an item, nothing is removed.
- Saves the cart.
- Redirects only when
returnis provided.
For form-based delete actions, use delete_from_cart_form.
Examples
Delete by row ID (cart loop pattern)
{exp:cartthrob:cart_items_info}
<a href="{path=cart/delete_from_cart/{row_id}/cart/view_cart}">Delete {title}</a>
{/exp:cartthrob:cart_items_info}
Template target:
{exp:cartthrob:delete_from_cart row_id="{segment_3}" return="{segment_4}/{segment_5}"}
Delete by entry ID
{exp:cartthrob:delete_from_cart entry_id="1" return="cart_examples/single_page_checkout"}
Delete by entry ID + item option match
{exp:cartthrob:delete_from_cart
entry_id="1"
item_options:size="large"
return="cart/view_cart"}
Delete without redirect
{exp:cartthrob:delete_from_cart row_id="{segment_3}"}