SwftSubscriptions
Subscription product support for Swft Checkout. Enables WooCommerce Subscriptions (or WooCommerce Simple Subscriptions) products to go through the Swft checkout flow, with recurring billing handled via Stripe’s subscription APIs.
What it does
Section titled “What it does”- Detects subscription products in the cart
- Passes subscription billing interval, period, and trial data through the session
- Creates a Stripe
SetupIntent(for future billing) instead of aPaymentIntentwhen the cart is subscription-only - Creates a
PaymentIntent+SetupIntentfor mixed carts (subscription + regular products) - After payment, creates a Stripe Customer and Subscription
- Syncs subscription state to WooCommerce Subscriptions
Compatibility
Section titled “Compatibility”| Plugin | Status |
|---|---|
| WooCommerce Subscriptions | Supported |
| WooCommerce Simple Subscriptions | Supported |
| YITH WooCommerce Subscriptions | Partial (contact support) |
Installation
Section titled “Installation”- Install and activate WooCommerce Subscriptions (or compatible plugin)
- Download
swft-subscriptions.zipfrom swft.co.uk/modules - Install and activate SwftSubscriptions
Configuration
Section titled “Configuration”Go to WooCommerce → Settings → SwftSubscriptions:
| Setting | Option | Default |
|---|---|---|
| Enable trial period display | swft_subs_show_trial | yes |
| Trial label | swft_subs_trial_label | Free for {days} days, then {price}/{period} |
| Cancel at period end | swft_subs_cancel_at_period_end | no |
Extension data
Section titled “Extension data”SwftSubscriptions adds the following to extensions.subscription in the session when the cart contains a subscription product:
{ "product_id": 101, "type": "subscription", "billing_period": "month", "billing_interval": 1, "trial_length": 14, "trial_period": "day", "initial_amount": 0, "recurring_amount": 2999, "currency": "GBP", "sign_up_fee": 0}The checkout frontend reads this to:
- Replace the pay button label:
Start free trial/Subscribe — £29.99/mo - Show a trial period notice below the pay button
- Use a
SetupIntentflow instead ofPaymentIntentfor zero-amount initial charges
Payment flow
Section titled “Payment flow”Regular subscription (no trial)
Section titled “Regular subscription (no trial)”SetupIntent created → customer enters card → Stripe charges initial amount → Stripe Customer created → Stripe Subscription created → WooCommerce Subscription activatedTrial subscription (initial amount = 0)
Section titled “Trial subscription (initial amount = 0)”SetupIntent created → customer enters card → card saved, no charge → Stripe Customer created → Stripe Subscription created with trial_end date → Trial billing fires automatically at trial end → WooCommerce Subscription activatedMixed cart (subscription + regular products)
Section titled “Mixed cart (subscription + regular products)”PaymentIntent created for regular items → SetupIntent for subscription card → Both confirmed in one Stripe Elements flow → Regular order + Subscription created in WooCommerceOrder meta
Section titled “Order meta”| Meta key | Value |
|---|---|
_swft_ext_subscription | Full subscription data as JSON |
_swft_stripe_customer_id | Stripe Customer ID |
_swft_stripe_subscription_id | Stripe Subscription ID |
PHP hooks
Section titled “PHP hooks”// Modify subscription extension data before it is sentadd_filter( 'swft_subscription_extension_data', function( array $data, WC_Product $product ): array { return $data;}, 10, 2 );
// Fired after the Stripe Subscription is createdadd_action( 'swft_subscription_created', function( string $stripe_sub_id, int $wc_order_id ): void { // sync to your CRM}, 10, 2 );
// Fired when a subscription renewal payment succeeds (Stripe webhook)add_action( 'swft_subscription_renewed', function( string $stripe_sub_id, int $wc_order_id ): void { // update member access}, 10, 2 );
// Fired when a subscription is cancelledadd_action( 'swft_subscription_cancelled', function( string $stripe_sub_id, int $wc_subscription_id ): void { // revoke access}, 10, 2 );