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

Change Quantity

{exp:cartthrob:change_quantity} is an immediate-execution single tag. It updates quantity for one cart row and can optionally redirect. It is not a form tag.

See also:

Parameters

row_id

Required. Row ID of the cart item to update.

row_id="{segment_3}"

quantity

Required. Target quantity for the cart row.

quantity="{segment_4}"

return

Optional redirect URL after processing. If omitted, no redirect occurs.

return="cart/index"

Behavior and Constraints

  1. Looks up the cart item by row_id.
  2. If the row exists, calls set_quantity(quantity) on that item.
  3. Quantity handling is performed by item logic:
    • input is sanitized
    • value is normalized to absolute
    • fractional quantities are rounded down when fractional quantities are disabled
    • quantity <= 0 removes the row
  4. If the row is not found, no item is changed.
  5. Saves the cart.
  6. Redirects only when return is provided.

Examples

{exp:cartthrob:cart_items_info}
    <a href="{row_id_path=cart/change_quantity}/10">Change quantity to 10</a>
{/exp:cartthrob:cart_items_info}

Segment-driven update template

{exp:cartthrob:change_quantity row_id="{segment_3}" quantity="{segment_4}" return="cart/index"}

Set quantity to 0 (removes the row)

{exp:cartthrob:change_quantity row_id="{segment_3}" quantity="0" return="cart/index"}

Update without redirect

{exp:cartthrob:change_quantity row_id="{segment_3}" quantity="2"}