Skip to main content

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 with 10OFF, and if they don’t return, send 20OFF or even 30OFF
    β†’ 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! πŸ’Έ