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

Save Customer Info

{exp:cartthrob:save_customer_info} is a legacy immediate-execution helper that validates and saves posted customer/shipping data, then optionally redirects.

This is a single tag (not a form tag). For modern form usage, prefer save_customer_info_form.

See also:

Parameters

required

Controls which fields are required before save runs.

Supported modes:

  • required="all"
    Requires every current customer-info key. If save_shipping is enabled, also requires shipping_option.
  • required="not field_a|field_b"
    Starts from the all set and excludes listed fields. If save_shipping is enabled, shipping_option is included unless excluded.
  • required="field_a|field_b|field_c"
    Uses only the listed fields as required.
  • Omitted/empty
    No required-field list is enforced by this helper.

Examples:

required="all"
required="not company|address2"
required="first_name|last_name|email_address"

save_shipping

Controls whether shipping_option is included when required is based on all/not ....

  • Default: yes (truthy)
  • Set save_shipping="no" to avoid requiring shipping_option in those modes

Examples:

save_shipping="yes"
save_shipping="no"

return

Optional redirect path after processing.

  • If provided, the tag redirects through tag_redirect(return).
  • If omitted, no redirect occurs.

Example:

return="checkout/customer"

Behavior and Constraints

Code-backed flow:

  1. Merges tag parameters into $_POST.
  2. Builds required-field list from required and save_shipping.
  3. Validates through form builder with:
    • set_require_rules(false)
    • set_require_errors(false)
    • set_require_form_hash(false)
  4. On validation success, calls ee()->cartthrob->save_customer_info().
  5. Always evaluates redirect via tag_redirect(return).

What ee()->cartthrob->save_customer_info() saves (when validation passes):

  • Posted customer-info keys from cart customer defaults
  • custom_data[...] into cart custom data
  • shipping_option and shipping[...] into cart shipping info
  • Derived country_code from country when country_code is missing and a mapping exists

Important constraints:

  • This helper is legacy and does not output form HTML.
  • If validation fails, save is skipped.
  • No installer/stub templates currently use this legacy tag directly; current templates use save_customer_info_form.

Examples

Legacy POST-processing endpoint with required fields:

{exp:cartthrob:save_customer_info
    required="first_name|last_name|email_address"
    return="checkout/customer"
}

Require all customer fields except selected optional fields:

{exp:cartthrob:save_customer_info
    required="not address2|company|phone"
    return="checkout/shipping"
}

Require all default customer fields, but do not require shipping_option:

{exp:cartthrob:save_customer_info
    required="all"
    save_shipping="no"
    return="checkout/review"
}