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

Gateway Fields URL

gateway_fields_url returns the CartThrob action endpoint URL for loading gateway fields dynamically.

This is used when you want to request selected-gateway fields through an action URL instead of routing through a template.

See also:

Parameters

This tag has no tag-specific parameters.

Output

Returns a URL string in the format:

{site_index}?ACT={action_id}

The action ID is resolved for Cartthrob::change_gateway_fields_action.

Behavior and Constraints

  1. The tag only outputs a URL; it does not output gateway field HTML itself.
  2. The target action is designed for AJAX requests (change_gateway_fields_action exits when request is not AJAX).
  3. The action path uses selected-gateway field rendering logic and prepares gateway field output plus CSRF hash data for the request flow.
  4. In the installer templates, the common pattern is posting gateway changes to an AJAX template endpoint (for example ajax_cart_form) that renders {exp:cartthrob:selected_gateway_fields}. gateway_fields_url is the direct-action alternative.

Examples

Output the direct action endpoint:

{exp:cartthrob:gateway_fields_url}

Use in JavaScript for gateway switch requests:

<script>
var gatewayFieldsUrl = "{exp:cartthrob:gateway_fields_url}";
// Example POST payload usually includes selected gateway and csrf_token.
</script>

Template-based pattern used in shipped templates:

{!-- ajax_cart_form template --}
{exp:cartthrob:selected_gateway_fields}