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

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

  1. Executes start/end hooks:
    • cartthrob_delete_from_cart_start
    • cartthrob_delete_from_cart_end
  2. If row_id is provided, removes that row directly.
  3. Otherwise, if entry_id is provided, tries to find one matching item (optionally refined by item_options:*) and removes that matched row.
  4. If neither path finds an item, nothing is removed.
  5. Saves the cart.
  6. Redirects only when return is 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}"}