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

Save Customer Info Form (tag pair)

{exp:cartthrob:save_customer_info_form} outputs an HTML form that posts to save_customer_info_action and saves customer/session data to the current cart. It does not add, update, or remove cart line items.

See also:

Parameters

In addition to the items below, this tag also supports Global Form Parameters.

Tag-specific passthrough parameters

These parameters are initialized directly by this tag:

  • return: Redirect location after successful submit.
  • secure_return: Redirect to HTTPS return URL.
  • derive_country_code: Accepted by the form layer. Current save behavior already derives country_code from country when needed.
  • error_handling: Controls form error behavior through the form builder.

required

Use the global form required parameter to enforce required posted fields for this form.

required="first_name|last_name|email_address"

save_shipping (legacy anchor)

This parameter was used in older legacy behavior and is kept here for anchor compatibility. In the current tag/action flow, shipping data is saved by posting shipping_option and/or shipping[...] fields.

Required names for input fields

By default, CartThrob saves posted values for keys that exist in customer_info_defaults, plus supported extra payloads such as custom_data, shipping_option, and shipping[...].

If a posted field name is not part of the configured customer info keys, it is not saved to customer info by this action.

Default customer info keys include:

  • Contact and billing: first_name, last_name, address, address2, city, state, zip, country, country_code, company, phone, email_address, ip_address, description
  • Shipping contact/address: shipping_first_name, shipping_last_name, shipping_phone, shipping_address, shipping_address2, shipping_city, shipping_state, shipping_zip, shipping_country, shipping_country_code, shipping_company, shipping_region
  • Payment/session fields: CVV2, card_type, expiration_month, expiration_year, begin_month, begin_year, bday_month, bday_day, bday_year, currency_code, language, gateway
  • Shipping and tax context: shipping_option, weight_unit, region, use_billing_info
  • Redirect and checkout metadata: success_return, cancel_return
  • Additional checkout fields: po_number, card_code, issue_number, transaction_type, bank_account_number, bank_account_name, bank_name, check_type, account_type, routing_number
  • Member-related fields: username, screen_name

Where is the credit_card_number field?

CartThrob intentionally does not store raw credit card numbers in this session/customer info flow.

Form fields

  • custom_data
  • shipping_option
  • shipping[key]
  • use_billing_info
  • save_member_data

custom_data

Use custom_data[key] to save custom values into cart custom data.

<input type="text" name="custom_data[something]" value="" />

shipping_option

If posted, saves the selected shipping option into shipping info.

<input type="radio" name="shipping_option" value="ground" />

shipping[key]

Use this array for additional shipping values that should be saved into cart shipping info.

<input type="text" name="shipping[method]" value="ground" />
<input type="text" name="shipping[eta]" value="5 days" />

use_billing_info

When truthy, shipping customer fields are copied from billing fields during save.

<input type="checkbox" name="use_billing_info" value="1" />

save_member_data

If a member context exists, posting this enables manual-save member update behavior.

<input type="hidden" name="save_member_data" value="1" />

Variables

This tag parses with Global Tag Variables, including customer/cart values and inline form error variables used by global form error handling.

Behavior and constraints

1. The form validates through the form builder. 2. On success, CartThrob saves posted customer/session data. 3. On validation failure, error values are set for inline/global error output. 4. If country_code is not posted but country is posted, CartThrob derives country_code. 5. When use_billing_info is truthy, shipping fields are copied from billing fields. 6. custom_data[...] is saved to cart custom data. 7. shipping_option and shipping[...] are saved to shipping info. 8. If member context exists, customer info can be pushed through member update logic.

Examples

1) Basic customer info form

{exp:cartthrob:save_customer_info_form
    return="cart/order_info"
    required="first_name|last_name|email_address"
}
    <input type="text" name="first_name" value="" />
    <input type="text" name="last_name" value="" />
    <input type="email" name="email_address" value="" />
    <input type="submit" value="Save" />
{/exp:cartthrob:save_customer_info_form}

2) Prefill from saved customer info

{exp:cartthrob:save_customer_info_form return="cart_examples/shipping_test"}
    {exp:cartthrob:customer_info}
        <input type="text" name="first_name" value="{customer_first_name}" />
        <input type="text" name="last_name" value="{customer_last_name}" />
        <input type="text" name="email_address" value="{customer_email_address}" />
        <input type="text" name="zip" value="{customer_zip}" />
    {/exp:cartthrob:customer_info}
    <input type="submit" value="Save" />
{/exp:cartthrob:save_customer_info_form}

3) Shipping and custom data capture

{exp:cartthrob:save_customer_info_form return="checkout/contact"}
    <input type="text" name="first_name" value="" />
    <input type="text" name="shipping_first_name" value="" />

    <label>
        <input type="checkbox" name="use_billing_info" value="1" />
        Use billing info for shipping
    </label>

    <select name="shipping_option">
        <option value="ground">Ground</option>
        <option value="priority">Priority</option>
    </select>

    <input type="hidden" name="shipping[method]" value="ground" />
    <input type="text" name="custom_data[delivery_note]" value="" />

    <input type="submit" value="Save" />
{/exp:cartthrob:save_customer_info_form}

4) Hidden autosave-style form

<div id="hidden_save_customer_info_form_wrapper" style="display:none">
    {exp:cartthrob:save_customer_info_form return="" id="hidden_save_customer_info_form"}
        <div class="cart_data"></div>
        <input type="hidden" name="custom_data[last_step]" value="shipping" />
    {/exp:cartthrob:save_customer_info_form}
</div>