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

Cart Items Info (tag pair)

{exp:cartthrob:cart_items_info} loops over items currently in the cart and exposes item-level, cart-level, and helper variables for rendering cart pages.

A video tutorial on this tag is available.

See also:

Parameters

In addition to the parameters below, this tag supports Global Number Formatting.

orderby

Sort field. Defaults to title.

orderby="title"

You can sort by variables available in each row (for example title, quantity, entry_id, row_id, item_price, item_options:size, custom entry vars, and other exposed row keys).

Use orderby (no underscore). Legacy snippets may show order_by, but this tag reads orderby.

sort

Sort direction. Defaults to asc.

sort="desc"

limit

Maximum number of rows returned. Defaults to no limit.

limit="10"

offset

Skip this many rows before limit is applied. Defaults to 0.

offset="20"

entry_id

Filter cart rows by product entry ID. Pipe-delimited values are supported.

entry_id="456|455|454"

row_id

Filter cart rows by cart row ID. Pipe-delimited values are supported.

row_id="2|3|4"

plan_id

Filter rows by subscription plan ID stored in item meta. Pipe-delimited values are supported.

plan_id="1|3|7"

search:field_name

Additional filtering against row data (processed by apply_search_filters).

Contains matching:

// rows where product_tag contains "pickles"
search:product_tag="pickles"

// rows where product_tag contains at least one of these values
search:product_tag="pickles|shoes"

// rows where product_tag contains both values
search:product_tag="pickles&&shoes"

// rows where product_tag contains neither value
search:product_tag="not pickles|shoes"

// rows where product_tag does not contain all listed values together
search:product_tag="not pickles&&shoes"

Exact (=):

// rows where product_tag is exactly "pickles"
search:product_tag="=pickles"

// rows where product_tag is exactly one of these values
search:product_tag="=pickles|shoes"

// rows where product_tag is not exactly one of these values
search:product_tag="=not pickles|shoes"

Numeric operators:

// rows where numeric price is less than 10
search:price_numeric="<10"

// rows where numeric price is greater than or equal to 20
search:price_numeric=">=20"

Variables

Each loop row includes:

  1. Item variables from the cart item (itemVars).
  2. Cart/global variables merged into each row (globalVariables + cart info).
  3. Loop helper variables added by this tag.

Common item variables:

  • entry_id, title, url_title, row_id
  • quantity, inventory
  • item_price, item_price:plus_tax, item_subtotal, item_subtotal:plus_tax
  • item_tax, item_total_tax
  • item_shipping, item_weight
  • base_price, base_price:plus_tax
  • discounted_price, discounted_subtotal, discount
  • no_tax, no_shipping

Numeric aliases (examples):

  • item_price:numeric, price:numeric
  • item_price_plus_tax:numeric, price_plus_tax:numeric
  • item_base_price:numeric, base_price:numeric
  • discounted_price:numeric, discount:numeric

Cart/global variables available in each row:

  • total_items, total_unique_items
  • cart_total, cart_subtotal, cart_subtotal:plus_tax
  • cart_tax, cart_shipping, cart_shipping:plus_tax
  • cart_discount, cart_tax_name, cart_weight, cart_id
  • customer info and custom_data:* variables

Loop helpers:

  • cart_count
  • cart_total_results
  • first_row
  • last_row

Options and subscription helpers:

  • item_options:* (for example item_options:size)
  • item_options (count of applied item options)
  • selected_options (array payload for selected options)
  • is_subscription / subscription flags
  • subscription_* values from stored subscription options
  • discounts pair (amount, amount:numeric, reason, coupon_code)
  • categories pair (when category data is available in the template context)

Path helpers:

  • entry_id_path=template/group
  • row_id_path=template/group

Switch helper:

  • {switch="odd|even"}

Quick variable examples:

{exp:cartthrob:cart_items_info}
    <p>Item: {title} ({entry_id})</p>
    <p>Row ID: {row_id}</p>
    <p>Qty: {quantity}</p>
    <p>Item price: {item_price}</p>
    <p>Item subtotal: {item_subtotal}</p>
    <p>Cart total: {cart_total}</p>
    <p>Loop count: {cart_count} of {cart_total_results}</p>
    <p>Size option: {item_options:size}</p>
{/exp:cartthrob:cart_items_info}

Package/Sub-item Output

This tag supports package loops in the tag body using either {package}...{/package} or {packages}...{/packages}.

When an item has sub-items, the package pair exposes sub: variables, including:

  • sub:title
  • sub:entry_id
  • sub:row_id (parent/child row format)
  • sub:parent_id
  • sub:child_id
  • sub:count
  • sub:first_row
  • sub:last_row

If an item is not a package, the package pair for that row is empty.

Conditionals

  • {if no_items}: explicit no-items branch supported by this tag.
  • {if is_package}: current row has package sub-items.
  • {if is_subscription}: current row is a subscription item.
  • {if item_options}: current row has one or more item options.
  • {if first_row}: first row in current result set.
  • {if last_row}: last row in current result set.

Compatibility note: if {if no_items} is not used, standard {if no_results} fallback behavior still works through template no-results handling.

Behavior and Constraints

  1. Starts with all cart items.
  2. Applies direct filters in this order:
    • entry_id
    • row_id
    • plan_id
  3. Builds row data (item vars + global/cart vars + package/sub-item vars).
  4. Sorts rows using orderby + sort.
  5. Applies offset and limit.
  6. Applies search:* filters.
  7. Adds loop helpers (cart_count, cart_total_results, first_row, last_row).
  8. Parses output.

Important nuance: because search:* runs after sort/offset/limit, filtered result size can be smaller than limit.

Examples

Basic cart loop

{exp:cartthrob:cart_items_info}
    {if no_items}<p>There's nothing in your cart.</p>{/if}
    <p>{title} x {quantity} = {item_subtotal}</p>
{/exp:cartthrob:cart_items_info}

Row-specific update/delete controls

{exp:cartthrob:cart_items_info}
    <p>{title}</p>
    <a href="{row_id_path=cart/change_quantity}/2">Set quantity to 2</a>
    <a href="{row_id_path=cart/delete_from_cart}">Delete</a>
{/exp:cartthrob:cart_items_info}

Filter by entry and plan

{exp:cartthrob:cart_items_info entry_id="12|13" plan_id="3" orderby="entry_id" sort="desc"}
    <p>{entry_id}: {title}</p>
{/exp:cartthrob:cart_items_info}

Search filters

{exp:cartthrob:cart_items_info search:title="not sample|test" search:price_numeric=">=20"}
    <p>{title} - {item_price}</p>
{/exp:cartthrob:cart_items_info}

Package/sub-item output examples

{exp:cartthrob:cart_items_info}
    <h4>{title}</h4>
    {if is_package}
        {package}
            <p>Sub item: {sub:title} ({sub:row_id})</p>
        {/package}
    {/if}
{/exp:cartthrob:cart_items_info}

Zebra rows with switch

{exp:cartthrob:cart_items_info}
    <div class="{switch='odd|even'}">{title}</div>
{/exp:cartthrob:cart_items_info}