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

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 gateway value 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:

  1. Direct gateway field HTML, or
  2. An {embed="..."} template reference returned by gateway template configuration.

Behavior and Constraints

  1. Gateway resolution priority:
    • posted gateway value,
    • tag parameter gateway,
    • configured default gateway.
  2. If selected gateway is not valid for currently available gateways, selection falls back to default gateway.
  3. If gateway selection is disabled, output is always forced to default gateway.
  4. Uses the store’s available-gateway list (available_gateways) as allowed options.
  5. Tag output only renders fields; it does not create/submit checkout forms by itself.
  6. 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 --}