AffiliateWP 2.6 is still in beta. Interested in helping us test it? Opt-in for beta releases in Affiliates → Settings → Misc and you should receive an update notification.
In AffiliateWP 2.6, we’re introducing a new feature to the affiliate coupons API called dynamic coupons. This functionality will initially only be supported when used with the WooCommerce integration.
The idea for dynamic affiliate coupons is simple: affiliate managers create and configure a single “template” coupon that all relevant dynamic coupons will magically inherit attributes from. If the template coupon’s settings are changed, the dynamic coupons instantly inherit those changes from that single source of truth.
When a dynamic affiliate coupon is used in an eligible context – such as with a WooCommerce order – the API will automatically draw the discount attributes from the coupon template for that context.
For this new feature to work, a WooCommerce coupon must be created and designated as the dynamic coupon template in AffiliateWP’s global Coupons settings.
Once that template is set, dynamic coupon codes can be generated for existing affiliates using the the bulk generation tool. Any new affiliates will receive their own unique coupon code (if generation during registration settings are configured).
How Dynamic Coupons Work In WooCommerce
In order to make dynamic coupons work in WooCommerce, we used their built-in “manual coupons” functionality which allows for generating pseudo-coupons on the fly.
In order for dynamic coupons to work in 2.6, the following baseline requirements must be met:
- The WooCommerce integration is enabled
- A Coupon Template is set on the Coupons settings tab
When a dynamic coupon code is applied on the cart or checkout page the following steps are carried out:
- We check to see if the coupon supplied at checkout matches a dynamic coupon code stored in the
- If there is a match and the baseline requirements above are met, the process is allowed to proceed
- A manual coupon is then generated on the fly via the
woocommerce_get_shop_coupon_datafilter using attributes from the coupon template
- Any discount-related attributes will be applied, and a referral will be generated crediting the affiliate whose dynamic coupon was matched
The following fields are copied on the fly from the coupon template:
Affiliate Coupon Tracking
All dynamic coupons support affiliate coupon tracking so a referral will be created for the affiliate anytime their dynamic coupon code is used by a customer.
A use case of the dynamic coupon feature is when you want to create a 5% off discount code for every affiliate when they create an account and two weeks later you decide you want all the affiliate coupons to offer a 10% discount off each order instead.
With the old manual coupons option, you would need to modify all of the manual coupons created for all affiliate coupons to do this. Just imagine having 1,000 manual coupons created for the 1,000 affiliates on your website.
With dynamic coupons, there are two options to go about this
- Update the existing coupon template to offer a 10% off discount.
- Create a new WooCommerce coupon offering a 10% off discount and set the coupon template to this new coupon
As previously mentioned, AffiliateWP 2.6 will only support dynamic coupons when used with the WooCommerce integration. Support for other integrations will be coming in a future release.