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 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 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. 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.