Skip to main content
These hooks allow you to respond to checkout events and customize the checkout experience.

Actions

Actions are triggered during the checkout process and when orders are confirmed. This is at the end, after payment is successuflly confirmed by the processor.

surecart/checkout_confirmed

Fired after an order is confirmed and all purchases have been processed. Use this for post-checkout operations like analytics tracking, external notifications, or custom logging.
Action Parameters

Filters

Form Validation

These filters run during the finalize step of checkout, before the order is submitted. Use them to validate form data and prevent checkout if validation fails.

surecart/checkout/validate

Add custom server-side validation to checkout forms. This filter runs during the finalize step, after client-side validation passes but before the order is submitted to the payment processor.
Filter Parameters
Validate Email Domain
Block specific email domains from purchasing:
Validate Custom Fields
Validate custom form fields added to your checkout:
Validate Based on Form ID
Apply validation only to specific checkout forms:

User Creation

surecart/checkout/auto-login-new-user

Control whether newly created users are automatically logged in after checkout.

Display

surecart_checkout_show_converted_total

Control whether converted currency totals are shown when using currency conversion.

sc_checkout_price_selector_first_price_as_default

Control whether the first price is selected by default in price selectors.

Payment Mode

surecart/payments/mode

Filter the payment mode (live/test). Useful for testing or staging environments.

JavaScript Filters

SureCart provides JavaScript filters using the WordPress hooks system (wp.hooks) to customize the Stripe Payment Element. These filters allow you to modify payment method order, wallet visibility, legal terms display, billing fields, and the underlying Elements configuration.
These filters use the @wordpress/hooks package, which is automatically available on pages with SureCart checkout.

Payment Method Order

Use surecart_stripe_payment_element_payment_method_order to reorder the payment methods displayed in Stripe’s Payment Element.
See the Stripe Payment Element documentation for available payment method types.

Wallet Visibility

Use surecart_stripe_payment_element_wallets to control the visibility of digital wallets like Apple Pay, Google Pay, and Link within the Payment Element.
See the Stripe wallets documentation for more options. Use surecart_stripe_payment_element_terms to manage the display of mandates and other legal agreements within the Payment Element. By default, these are shown only when necessary.
See the Stripe terms documentation for available options.

Billing Fields

Use surecart_stripe_payment_element_fields to control which billing address fields are displayed within the Stripe Payment Element. This is useful when you’re already collecting billing information elsewhere in your checkout form.
To show specific fields, simply remove them from the object or set them to 'auto'. For example, to hide all fields except country:
See the Stripe fields documentation for all available options.

Elements Configuration

Use surecart_stripe_payment_element_elements_config to modify the Elements group options that wrap the Payment Element. This is a lower-level filter than the ones above: it receives the entire configuration object SureCart builds, including mode, amount, currency, setupFutureUsage, and appearance. It is also where you control which payment methods Stripe offers, with excludedPaymentMethodTypes or paymentMethodTypes. See Hide a Payment Method for Specific Products. Always return a complete configuration object. Spread the original config and override only the keys you need:
SureCart re-applies this configuration with elements.update() every time the checkout changes, such as when a coupon is applied or the total updates. Stripe accepts only a subset of options on update, so fonts, loader, customerOptions, and paymentMethodCreation apply when the element is first created and are ignored on subsequent updates. mode, amount, currency, setupFutureUsage, captureMethod, paymentMethodTypes, excludedPaymentMethodTypes, paymentMethodConfiguration, appearance, and locale apply in both cases.

Address Countries

Use surecart_address_countries to customize the list of countries available in address fields. You can add, remove, reorder, or translate country names.
To add custom JavaScript filters to your site, you can use plugins like Simple Custom CSS and JS. Be sure to load scripts in the footer for checkout page compatibility.
Each country object must include both value (ISO country code) and label (display name) properties.

Address Regions

Use surecart_address_regions to customize the regions (states, provinces, etc.) available for specific countries. You can add, remove, or translate region names.
The filter receives the current regions array and the country code. Each region object must include both value and label properties.

Use Cases

Analytics & Conversion Tracking

Send to Slack

Validate Minimum Order Amount

Restrict Purchases by Country

Require Terms Acceptance

Validate Tax Identifier

Use the built-in tax_identifier field to validate VAT/tax ID numbers:

Force Test Mode for Non-Production

JavaScript Filter Use Cases

Sell Only to Specific Countries

Restrict your checkout to only allow purchases from certain countries:

Exclude Specific Countries

Remove certain countries from the dropdown while keeping all others:

Change County Name Translations

Change the transled country names to something different.

Prioritize Common Countries

Move your most common customer countries to the top of the list:

Prioritize Card Payments

Show card payment first for faster checkout:
Hide Stripe Link for recurring payments:

Show Bank Terms for High-Value Orders

Always display ACH terms for orders over a certain amount:

Hide a Payment Method for Specific Products

Use excludedPaymentMethodTypes to remove individual payment methods while leaving the rest of Stripe’s automatic payment methods intact. This example hides Klarna when a specific product is in the cart:
The filter re-runs whenever line items change, so you can swap the condition for anything on the checkout. Testing item.price?.recurring_interval instead, for example, hides the method only for subscriptions. When the condition stops matching, returning config unchanged shows the method again.
Use the payment method’s Stripe API identifier, not its display name. Klarna is klarna, Afterpay and Clearpay share afterpay_clearpay, and Cash App Pay is cashapp. See Stripe’s payment method types for the full list. Link can’t be excluded this way. Stripe rejects link as an excluded type, so hide it with Wallet Visibility instead.
To declare what to keep instead of what to remove, use paymentMethodTypes. This example allows only cards for subscriptions:
paymentMethodTypes is an allowlist that replaces Stripe’s automatic payment methods entirely, so every method you leave out is hidden. Each one you list must be enabled in your Stripe dashboard. Stripe doesn’t accept paymentMethodTypes and excludedPaymentMethodTypes together. When your filter sets both, SureCart sends only paymentMethodTypes. Switching the allowlist on or off reloads the Payment Element, which clears any payment details the customer already entered. Apple Pay and Google Pay count as card, so they still show; hide them with Wallet Visibility. Prefer excludedPaymentMethodTypes when you only need to remove one or two methods.

Modifying Templates

You can customize the HTML output of SureCart blocks using WordPress’s render_block filter and the HTML Tag Processor.

Templates

Learn how to modify block HTML, add custom attributes, wrap content, and inject elements into templates.

Cart

Customize cart icon and visibility.

Login

Customize login redirects and authentication.

Purchases

Hook into individual purchase events.

Orders

Hook into order and payment events.

Templates

Modify blocks, shortcodes, and inject content.