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

Overriding Gateway Fields

The checkout_form tag has a {gateway_fields} variable that outputs the customer and payment markup required by the active gateway.

Choose one source of gateway fields

Use either the default {gateway_fields} output or your customized markup. Do not render both. Duplicate inputs with the same name or id can make CartThrob validate one field while the browser submits a different value.

Configure a Gateway Fields Template

  1. Go to CartThrob Settings → Payments and manage the gateway.
  2. Review the displayed checkout markup and the gateway’s required fields.
  3. Create an EE template containing your customized version of that markup.
  4. Select that template in Gateway Fields Template and save the gateway.
  5. Keep {gateway_fields} in checkout_form. CartThrob embeds your configured template in its place.

The configured template is a full replacement for the default gateway output. It must include every required customer field, hosted-field container, hidden field, and gateway integration element.

Replace the variable directly

Alternatively, remove {gateway_fields} from checkout_form and paste the complete customized markup directly into that form. Again, replace the variable; do not supplement it with duplicate gateway-owned fields.

Populate ordinary customer fields with CartThrob variables so failed validation does not erase the customer’s values:

<label for="first_name">First name</label>
<input type="text" id="first_name" name="first_name" value="{first_name}">

With error_handling="inline", you can place a field-specific message beside custom markup:

{if error:first_name}
    <p class="error">{error:first_name}</p>
{/if}

See Gateway-generated fields and inline errors for the error-summary pattern and the behavior of generated fields.