Additional Custom Emails & Recipients for WooCommerce can create a unique, single-use discount coupon on the fly and print its code straight into an email. Use it to reward a new customer, thank someone after purchase, or run a win-back message, each recipient getting their own personal code.
The shortcode #
[generate_coupon_code amount="10"]
Placed in a custom email’s content, this creates a coupon and outputs its code. The amount attribute is required and sets the discount value.
What the coupon looks like #
When the shortcode runs, the plugin creates a WooCommerce coupon with these properties:
| Property | Value |
|---|---|
| Discount type | Percentage discount |
| Amount | The amount you passed (for example 10 means 10%) |
| Coupon code | The recipient’s first name, made unique with a numeric suffix if that name is already taken (for example Maria, then Maria-1) |
| Usage limit | 1 use total, and 1 use per user |
| Restricted to | The recipient’s email address |
| Applies before tax | Yes |
Because the coupon is locked to the recipient’s email and limited to a single use, each generated code is personal and cannot be shared.
It needs a user context #
The coupon is built from the recipient’s user account: the code comes from their first name and the restriction comes from their email. So the shortcode only produces a coupon when the email runs with a user in context. If there is no user, the shortcode outputs nothing.
User context is present for the account-related triggers, which pass a user to the email:
- Created customer notification
- Reset password notification
- Customer address saved
- Customer address changed
Order triggers put the order in context, not a user object, so [generate_coupon_code] returns empty in a purely order-based email. To send a coupon after purchase, trigger the email on a customer account event, or on a custom trigger whose first argument is a user ID.
Example #
A welcome email that greets a new customer and hands them a 15% coupon:
Welcome aboard, [user_prop key="first_name"]!
Here is 15% off your first order. Use code:
[generate_coupon_code amount="15"]
This code is yours alone and can be used once.
Set this email’s trigger to Created customer notification so a user is in context and the code generates.
Notes and cautions #
- The shortcode creates a real coupon each time the email is sent. Re-sending the same email generates another coupon (with a new suffixed code), so avoid placing it in an email that fires repeatedly for the same person.
- The discount is always a percentage in this version; the
amountis the percent value. - The coupon is published immediately and appears under Marketing > Coupons, so you can audit or revoke generated codes there.
Reward customers automatically #
Additional Custom Emails & Recipients for WooCommerce Pro lets you run several coupon emails at once, each on its own trigger and audience. Get the plugin to turn your notifications into a loyalty channel.