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

Cart Form (tag pair)

{exp:cartthrob:cart_form} is a legacy/general cart wrapper form. It outputs an items pair for current cart rows and posts to cart_action by default.

This tag is mainly useful for custom flows where you need to render cart rows and submit customer/session fields in one form.

For standard cart editing workflows, use update_cart_form. For adding products, use add_to_cart_form.

See also:

Parameters

In addition to Global Form Parameters, cart_form supports these tag-specific behaviors:

  • action
  • return
  • secure_return
  • language
  • order_by or orderby
  • sort
  • limit
  • offset

action

Optional custom action URL override (global form behavior). If not set, this form posts to CartThrob’s cart_action.

action="/en/cart/custom-endpoint"

return

Redirect location after form completion.

return="store/cart"

secure_return

Use secure return behavior for redirect handling.

secure_return="yes"

language

Language code/name used by CartThrob language handling for form messages.

language="en"

order_by / orderby

Column used to sort the items array before output. order_by is checked first; orderby is used as fallback.

order_by="title"

sort

Sort direction passed to the data filter sort step.

sort="asc"

limit and offset

Limit and offset applied to the items output after sorting.

limit="10" offset="0"

Variables

cart_form parses Global Tag Variables and provides an items pair representing current cart rows.

Inside {items}...{/items}, each row contains item data from the cart item object (plus product data merged by item type), including common values such as:

  • {entry_id}
  • {row_id}
  • {title}
  • {quantity}
  • {price}
  • {item_options:*} values when present

cart_form also runs item option helper variable parsing for each row (same helper style used across CartThrob item option output).

Behavior and Constraints

1. Builds items from the current cart contents. 2. Applies optional sorting and limit/offset to the items output. 3. Renders a form posting to cart_action unless action is overridden. 4. Default cart_action saves customer/session data (save_customer_info()). 5. Default cart_action does not add products, remove rows, or update row quantities.

If you need cart-row mutation (quantity changes, deletes), use update_cart_form.

Example

Display rows and save customer field

{exp:cartthrob:cart_form return="store/cart" order_by="title" sort="asc"}
    {items}
        <p>{title} - {price}</p>
    {/items}

    <label>Email</label>
    <input type="text" name="email_address" value="{customer_email_address}" />
    <input type="hidden" name="custom_data[last_step]" value="cart_review" />

    <button type="submit">Save and Continue</button>
{/exp:cartthrob:cart_form}