Selected Gateway Fields
selected_gateway_fields outputs gateway fields for the currently selected gateway context.
This tag is commonly used in AJAX-loaded templates so checkout field markup can be swapped when customers change payment method.
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.
- In installer templates, this tag is usually rendered in a dedicated AJAX template and injected into a container like
#checkout_form_gateway_fields.
Examples
Basic direct usage:
{exp:cartthrob:selected_gateway_fields gateway="authorize_net"}
Template used for AJAX field replacement:
{!-- ajax_cart_form template --}
{exp:cartthrob:selected_gateway_fields}
Typical checkout flow pattern:
{exp:cartthrob:checkout_form return="store/order_info"}
Pay By: {exp:cartthrob:gateway_select id="gateway" name="gateway"}
<div id="checkout_form_gateway_fields">
{gateway_fields}
</div>
{/exp:cartthrob:checkout_form}
{!-- JS posts selected gateway to an AJAX template containing selected_gateway_fields --}