How-To: Auto-Apply WooCommerce Coupon via FluentCRM Automation in Abandoned Cart Email Link
We all love FluentCRM and the powerful features it brings - especially Cart Abandonment Recovery. But one thing is still missing:
π A clickable recovery URL that automatically applies the coupon code when the customer clicks it.
By default, WooCommerce does not apply coupons reliably when extra parameters are in the URL for coupons. But donβt worry - hereβs a simple workaround using FluentSnippets.
β Step 1: Add this Snippet using FluentSnippets or functions.php
Paste the following code into FluentSnippets (or your child themeβs functions.php). This snippet ensures that the coupon parameter from the URL is saved and applied once the cart or checkout is available.
// 1. Store coupon from URL in session (works on any page)
function fc_save_coupon_from_url_to_session() {
if ( isset($_GET['coupon']) ) {
$coupon_code = sanitize_text_field($_GET['coupon']);
WC()->session->set( 'fc_deferred_coupon', $coupon_code );
}
}
add_action( 'init', 'fc_save_coupon_from_url_to_session' );
// 2. Apply coupon from session when cart is available (e.g. checkout)
function fc_apply_deferred_coupon_from_session() {
if ( ! is_admin() && WC()->cart && ! is_ajax() ) {
$coupon_code = WC()->session->get( 'fc_deferred_coupon' );
if ( $coupon_code && ! WC()->cart->has_discount( $coupon_code ) ) {
WC()->cart->add_discount( $coupon_code );
wc_add_notice( sprintf( __( 'Coupon "%s" was applied.', 'woocommerce' ), $coupon_code ), 'success' );
WC()->session->__unset( 'fc_deferred_coupon' ); // Apply once
}
}
}
add_action( 'woocommerce_before_checkout_form', 'fc_apply_deferred_coupon_from_session' );
π© Step 2: Use this in your FluentCRM automation email
Inside your abandoned cart automation reminder email, use the following format in your button or link:
##ab_cart_woo.recovery_url##&coupon={{woo_coupon.1_3}}
β οΈ Important: Use Your Coupon Shortcode!
Donβt forget to insert your actual FluentCRM dynamic coupon shortcode in place of {{woo_coupon.1_3}}.
This ensures each user gets a valid and personalized code.
If you're not using dynamic coupons, you can hardcode it like &coupon=10OFF
π What happens:
- The customer clicks the recovery link in the email
- The cart is restored via FluentCRM as usual
- The coupon is applied automatically, without needing manual input
Pro Tips
- π§ Use urgency in your email copy ("Your 10% off expires in 24 hours!")
- π― Segment your coupons based on abandonment level:
β Start with10OFF, and if they donβt return, send20OFFor even30OFF
β You can replace the coupon code dynamically in FluentCRM automations depending on email step or time delay - π οΈ Combine this with FluentCRMβs automation conditions and custom fields to boost performance
π Happy recovering - and even happier selling! πΈ
