New in 2.6: Dynamic Coupons

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.

Base Criteria

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:

  1. The WooCommerce integration is enabled
  2. 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:

  1. We check to see if the coupon supplied at checkout matches a dynamic coupon code stored in the affiliate_wp_coupons table.
  2. If there is a match and the baseline requirements above are met, the process is allowed to proceed
  3. A manual coupon is then generated on the fly via the woocommerce_get_shop_coupon_data filter using attributes from the coupon template
  4. 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:

  • amount
  • discount_type
  • excluded_product_ids
  • excluded_product_categories
  • product_ids
  • individual_use
  • free_shipping
  • exclude_sale_items
  • date_expires

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.

Use Case

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.

Leave a Reply

Your email address will not be published. Required fields are marked *