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

Vaults (tag pair)

{exp:cartthrob:vaults} outputs saved payment-method vault records.

This tag is commonly used to list a member’s stored payment methods and to drive edit/delete/checkout-with-vault flows.

See also:

Parameters

id

Filter by vault id.

Supports a pipe-delimited list.

id="12"
id="12|13|14"

order_id

Filter by order entry id tied to vault records.

Supports a pipe-delimited list.

order_id="1099"
order_id="1099|1100"

primary

Filter by primary flag.

  • truthy values filter to primary vaults (1)
  • falsy values filter to non-primary vaults (0)

    primary=”yes” primary=”no”

member_id

Filter by member id.

Supported special values:

  • CURRENT_USER
  • {member_id}
  • {logged_in_member_id}

For special values, CartThrob resolves to the current member id. Otherwise, pipe-delimited member id lists are supported.

member_id="CURRENT_USER"
member_id="25|26"

limit

Maximum number of vault rows returned.

Default: 100.

limit="1"
limit="25"

Variables

This tag returns each matched vault row using model toArray() values.

Commonly used variables:

  • id
  • name
  • member_id
  • order_id
  • token
  • gateway
  • customer_id
  • last_four
  • primary
  • created_date
  • modified

Address/payment-profile fields are also available when present in the vault record, including:

  • first_name, last_name
  • address, address2, city, state, zip, country
  • shipping_first_name, shipping_last_name
  • shipping_address, shipping_address2, shipping_city, shipping_state, shipping_zip, shipping_country
  • exp_month, exp_year

Conditionals

no_results

If no vault rows match, use {if no_results} inside the tag pair.

{exp:cartthrob:vaults member_id="CURRENT_USER"}
  {if no_results}
    No saved payment methods found.
  {/if}
{/exp:cartthrob:vaults}

Behavior and Constraints

  1. The tag queries cartthrob:Vault model rows and applies parameter filters.
  2. If no filter params are provided (member_id, id, primary, order_id), it defaults to current member vaults.
  3. member_id special values (CURRENT_USER, {member_id}, {logged_in_member_id}) resolve to the current member id.
  4. limit defaults to 100.
  5. If no rows are found, the tag returns no_results.
  6. Output is row-based tag-pair parsing over matched vault records.

Examples

Current member vault list:

{exp:cartthrob:vaults member_id="CURRENT_USER"}
  {if no_results}
    You don't have any payment methods yet.
  {/if}

  {id} - {name} ({gateway}) ****{last_four}
  <a href="{path='store/edit_vault/{id}'}">Edit</a>
  <a href="{path='store/delete_vault/{id}'}">Delete</a>
{/exp:cartthrob:vaults}

Primary vault only (checkout-adjacent pattern):

{exp:cartthrob:vaults primary="yes" member_id="CURRENT_USER" limit="1"}
  {exp:cartthrob:checkout_form force_vault="yes" vault_id="{id}" return="store/order_info"}
    {vault_fields}
    <input type="submit" value="Complete Checkout" />
  {/exp:cartthrob:checkout_form}
{/exp:cartthrob:vaults}

Filter by specific vault id:

{exp:cartthrob:vaults id="{segment_3}"}
  {name} ({gateway})
{/exp:cartthrob:vaults}