Checkout Form (tag pair)
checkout_form outputs an HTML checkout form that posts to checkout_action, saves customer data, validates required fields, and starts payment processing.
A video tutorial on this tag is available.
See also:
- gateway_fields
- selected_gateway_fields
- gateway_fields_url
- gateway_select
- submitted_order_info
- global_form_settings
Parameters
In addition to the parameters listed here, this tag also supports Global Form Parameters such as return, secure_return, error_handling, show_errors, required, rules:*, action, secure_action, id, class, name, onsubmit, enctype, and logged_out_redirect.
- required
- cart_empty_redirect
- gateway
- gateway_method
- price
- allow_user_price
- shipping
- allow_user_shipping
- tax
- country_code
- expiration_date
- create_user
- group_id
- force_processing
- force_vault
- vault_id
- member_id
- order_id
- authorized_redirect / failed_redirect / declined_redirect / processing_redirect
- custom_js
required
Adds required validation rules for additional fields on this checkout form.
Use a pipe-delimited list:
required="first_name|last_name|email_address"
Gateway-required fields are validated automatically. To exclude specific gateway-required fields, use the not prefix:
required="not first_name|last_name"
cart_empty_redirect
If the cart is empty when the tag renders, the customer is redirected to this path.
cart_empty_redirect="cart/index"
gateway
Sets the payment gateway short name for this checkout form.
- If gateway selection is disabled in CartThrob settings, this parameter is ignored.
You can also post
gatewayfrom an input field (for example, fromgateway_select).gateway=”authorize_net”
gateway_method
Sets an optional gateway-specific method (for gateways that support it).
gateway_method="ideal"
allow_user_price
Allows a posted price form field to override calculated cart subtotal during checkout.
allow_user_price="yes"
price
Sets a fixed subtotal override for this checkout form.
price="100"
allow_user_shipping
Allows a posted shipping form field to override calculated shipping during checkout.
allow_user_shipping="yes"
shipping
Sets a fixed shipping override for this checkout form.
shipping="15"
tax
Sets a fixed tax override for this checkout form.
tax="8.25"
country_code (legacy note)
country_code is commonly used as an input field value (for example, name="country_code") and saved through customer-info handling.
In current implementation, it is not a dedicated encoded checkout-form parameter like price, shipping, or tax.
expiration_date
When orders are saved as channel entries, sets entry expiration in days from now.
expiration_date="365"
create_user
Enables member creation during checkout.
create_user="yes"
When enabled, include create-member fields in your form (username, email_address, optional screen_name, password, password_confirm).
group_id
Sets the member group for create_user="yes".
- Values below
5are forced to5. role_idis accepted as an alias in current code.group_id=”6”
force_processing
Skips immediate card charge and marks order as processing.
force_processing="yes"
force_vault
Forces vault creation even when no subscription is present.
force_vault="yes"
vault_id
Uses an existing vault record for payment.
- Vault ownership is validated against the current member.
When
vault_idis used, render{vault_fields}instead of{gateway_fields}.vault_id=”1”
member_id
Admin checkout parameter: checkout on behalf of another member (allowed admin groups only).
member_id="123"
order_id
Completes an existing order in processing status. If this is set, member_id is ignored.
authorized_redirect, failed_redirect, declined_redirect, processing_redirect
Optional status-specific return paths used after checkout completion.
authorized_redirect="store/order/success"
declined_redirect="store/order/declined"
failed_redirect="store/order/failed"
processing_redirect="store/order/processing"
custom_js
Set to yes/true to disable gateway-provided auto-injected JavaScript (form_extra) so you can provide your own implementation.
custom_js="yes"
Variables
In addition to the variables below, you can use Global Tag Variables, including cart/customer/custom-data values and form error values when inline error handling is used.
{gateway_fields}
Outputs the HTML fields required by the active gateway.
If gateway selection is enabled, this reflects the selected gateway context.
{vault_fields}
When vault_id is used, this outputs gateway vault fields for tokenized payment flows.
{captcha}
When guest checkout captcha is enabled, outputs the captcha image markup.
Error Variables
When using inline error handling, these are available inside the form:
errors_existfield_errors_existglobal_errors_exist{errors}...{/errors}{field_errors}...{/field_errors}{global_errors}...{/global_errors}error:field_name(per-field message)
Conditionals
{if captcha}
True when captcha is required for this checkout context.
{if captcha}
<p>Please enter the word in the image:</p>
<p>{captcha}</p>
<input type="text" name="captcha" />
{/if}
{if errors_exist}
True when the previous submit failed validation/processing and errors are available.
{if errors_exist}
{errors}
<p>{if field_error}<strong>{field}:</strong>{/if} {error}</p>
{/errors}
{/if}
{if no_results} (legacy compatibility)
Legacy docs referenced this conditional, but checkout form behavior is currently controlled by cart_empty_redirect or your own outer cart checks (for example with total_items_count).
Use cart_empty_redirect when you want an automatic redirect for empty carts.
Form Fields
- use_billing_info
- price
- shipping
- tax
- coupon_code
- shipping_option / shipping[key]
- custom_data[key]
- meta:some_key
use_billing_info
If truthy, posted shipping fields are copied from billing fields during customer-info save.
<input type="checkbox" name="use_billing_info" value="1" />
price (form field)
Posted price is used only when allow_user_price is enabled.
<input type="text" name="price" value="11" />
shipping (form field)
Posted shipping is used only when allow_user_shipping is enabled.
<input type="hidden" name="shipping" value="10" />
tax (form field)
Posts a tax override value for this checkout request.
<input type="hidden" name="tax" value="2.50" />
coupon_code
Adds a coupon code during checkout submission.
<input type="text" name="coupon_code" />
shipping_option and shipping[key]
These are saved as shipping info during checkout save flow.
<input type="hidden" name="shipping_option" value="ground" />
<input type="hidden" name="shipping[service_code]" value="ground" />
custom_data[key]
Stores custom cart data values on submit.
<input type="hidden" name="custom_data[source]" value="newsletter" />
meta:some_key
For Stripe gateways, posted fields prefixed with meta: are forwarded as Stripe metadata.
<input type="hidden" name="meta:ReferredBy" value="Wanda Sellalot" />
<input type="text" name="meta:GiftFor" placeholder="Gift Recipient Name" />
Behavior and Constraints
- Checkout form validates inventory before rendering. If inventory is invalid, the tag errors immediately.
- If
cart_empty_redirectis provided and cart is empty, customer is redirected. - Gateway selection logic:
- uses configured default gateway by default
- respects
gatewayonly when gateway selection is allowed - can use customer-selected posted gateway
save_customer_info()runs during checkout action unless bypassed by admin/order-specific flows.- Required fields come from gateway-required fields plus your
required/rules:*settings. coupon_codeis applied before payment processing.- Redirect behavior:
returnis standard fallback- status redirects (
authorized_redirect,processing_redirect,declined_redirect,failed_redirect) are supported.
vault_idis ownership-checked; invalid vault IDs are ignored.custom_js="yes"disables auto gateway JS injection so custom integration can control gateway scripts.- Subscription-compatible
subscription_*encoded parameters are accepted by checkout form/action and are processed during checkout subscription handling.
Examples
Standard checkout with gateway fields:
{exp:cartthrob:checkout_form
id="checkout_form"
class="form-horizontal"
return="store/order_info"
}
{gateway_fields}
<input type="submit" value="Complete Checkout" />
{/exp:cartthrob:checkout_form}
Checkout with inline errors and coupon field:
{exp:cartthrob:checkout_form
error_handling="inline"
required="first_name|last_name|email_address"
return="store/order_info"
}
{if errors_exist}
{errors}
<p>{if field_error}<strong>{field}:</strong>{/if} {error}</p>
{/errors}
{/if}
{gateway_fields}
<input type="text" name="coupon_code" />
<input type="submit" value="Checkout" />
{/exp:cartthrob:checkout_form}
Create member during checkout:
{exp:cartthrob:checkout_form
create_user="yes"
group_id="6"
return="store/order_info"
}
{gateway_fields}
<input type="text" name="username" />
<input type="text" name="email_address" />
<input type="text" name="screen_name" />
<input type="password" name="password" />
<input type="password" name="password_confirm" />
<input type="submit" value="Checkout" />
{/exp:cartthrob:checkout_form}
Vault checkout example:
{exp:cartthrob:checkout_form
vault_id="1"
force_vault="yes"
return="store/order_info"
}
{vault_fields}
<input type="submit" value="Charge Saved Method" />
{/exp:cartthrob:checkout_form}