Selected Gateway Fields
selected_gateway_fields outputs gateway fields for the currently selected gateway context.
This tag prints gateway markup only. Hosted gateways may also require scripts, hidden state, and event handlers initialized with the complete checkout form. Do not use this tag by itself to swap payment methods on an existing checkout. Save the gateway selection and render a complete new checkout page instead.
See also:
Parameters
gateway
Optional gateway short name to force a specific gateway.
gateway="authorize_net"
Notes:
- If a
gatewayvalue is posted in the request, posted value is used first. - Encoded gateway values (for example from
gateway_select, which encrypts by default) are supported and decoded when possible.
Output
Returns gateway-field markup for the resolved gateway.
Depending on gateway configuration, output may be:
- Direct gateway field HTML, or
- An
{embed="..."}template reference returned by gateway template configuration.
Behavior and Constraints
- Gateway resolution priority:
- posted
gatewayvalue, - tag parameter
gateway, - configured default gateway.
- posted
- If selected gateway is not valid for currently available gateways, selection falls back to default gateway.
- If gateway selection is disabled, output is always forced to default gateway.
- Uses the store’s available-gateway list (
available_gateways) as allowed options. - Tag output only renders fields; it does not create/submit checkout forms by itself.
- A full checkout-page reload is required when changing gateways so the selected gateway can initialize its markup and scripts together.
Examples
Basic direct usage:
{exp:cartthrob:selected_gateway_fields gateway="authorize_net"}
Checkout form using the selected gateway:
{exp:cartthrob:checkout_form
id="checkout_form"
return="store/order_info"
}
{exp:cartthrob:gateway_select id="gateway" name="gateway"}
<div id="checkout_form_gateway_fields">
{gateway_fields}
</div>
{/exp:cartthrob:checkout_form}
See Allow the customer to select a gateway for the complete save-and-reload pattern.