Docs

SureCart Checkout Integration

3 min readUpdated June 22, 2026

SureCart is a WordPress ecommerce platform with a headless checkout architecture. Because SureCart’s checkout is a client-side Web Component experience, the WP Smart Consent integration uses a specific two-phase approach to capture and forward consent correctly.

Enabling the Integration#

In the WP Smart Consent dashboard, go to Checkout Sources and toggle SureCart on. No additional configuration is needed on the SureCart side. The checkbox appears on all SureCart checkout pages immediately after saving.

A screenshot of the SureCart plugin settings. The "Enable" toggle is switched on. The "Forward to CRMs" section states, "Only active CRMs above will receive data." At the bottom is a green "Save SureCart" button. The status at the top right is "Active.

Custom Fields#

SureCart does not have a per-form field selector. To forward additional data beyond the standard fields, use the Global data fields tab in the WP Smart Consent dashboard. Set the source to Order meta and enter the relevant SureCart checkout metadata key as the source key.

How It Works#

SureCart’s checkout is a <sc-checkout> Web Component that takes over the page render after initial PHP output. Standard PHP hooks cannot inject markup into the component’s internal DOM. WP Smart Consent uses the render_block filter targeting the surecart/submit block — the submit button block — and prepends the opt-in checkbox as plain HTML directly before it. This approach is documented in SureCart’s official developer docs and is the supported method for adding custom fields to a SureCart checkout form.

Because SureCart’s JavaScript preserves the output of the surecart/submit block in its frontend render tree, the prepended checkbox survives the client-side takeover. A fetch interceptor script loaded in <head> captures the checkbox value before SureCart’s own JavaScript sends the checkout finalize request.

SureCart’s checkout uses two separate REST calls. The /finalize call submits form data and is the only moment the body parameters are available server-side. The /confirm call handles post-payment status and carries no form data.

WP Smart Consent hooks into surecart/checkout/validate during /finalize to read the wpsc_optin value from the request body. SureCart’s parseFormData() collects unrecognized fields under a metadata key, so the value is read from $raw['metadata']['wpsc_optin']. An unchecked checkbox is omitted from the FormData entirely per standard HTML behavior, so absence of the key means unchecked.

The captured value is stored in a WordPress transient keyed to the checkout ID — the same pattern SureCart itself uses internally. When surecart/checkout_confirmed fires after payment is confirmed, the transient is read, deleted, and the wpsc_optin_trigger action fires if consent was given.

What Gets Forwarded#

Email, first name, last name, billing address, city, state, postcode, and country. Phone is collected via the fetch interceptor if phone collection is enabled in the SureCart integration settings. All fields are normalized into the same flat array shape used by WooCommerce so downstream CRM integrations need no SureCart-specific code.

Send on Unchecked#

When enabled on a specific CRM destination in its Options tab, that destination receives contact data from every confirmed SureCart order regardless of whether the checkbox was ticked. Every checkout is logged regardless of consent state so the Logs tab always shows a complete record.

Troubleshooting#

Checkbox not appearing — confirm the SureCart integration is enabled and that your checkout page uses the surecart/submit block. If a custom checkout template bypasses the standard block structure, the render_block filter will not find the target block.

Consent not captured — the fetch interceptor must load before SureCart’s JavaScript. WP Smart Consent loads wpsc-surecart.js in <head> with no defer or async attribute for this reason. If a performance plugin moves scripts to the footer or adds defer, it may prevent the interceptor from registering before SureCart’s fetch calls begin.

Contact not forwarded after purchase — forwarding fires on surecart/checkout_confirmed. Free or zero-amount orders may skip the /finalize step, meaning no transient is stored and the opt-in defaults to unchecked. Confirm the order reached confirmed status in SureCart before troubleshooting further.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only