Creating coupons by hand doesn't scale
You want to email every VIP customer a personalized coupon code. WooCommerce's Add Coupon page is single-purpose — you fill out the form, hit save, one coupon. For 80 VIPs, that's 80 page loads.
The programmatic alternative — calling WooCommerce's WC_Coupon class in PHP — works but requires writing code. Every time you change the rules (different expiry, different product restrictions), you rewrite the snippet.
What most people do instead
A better way: one command, every coupon field
Run create coupon with the coupon name and whatever fields you need — discount type, amount, expiry (absolute date or relative phrase), usage limits, product restrictions, email restrictions. The command calls WooCommerce's coupon API internally, so everything stays in sync.
Relative expiry phrases just work. Pass -expiry="7 days" or -expiry="end of month". Perfect for macros that run in the future — no manual date math, no computing expiry in PHP.
How it works
The command wraps WC_Coupon with validation and sensible defaults. Discount types: fixed cart, fixed product, percent. Expiry accepts dates or phrases. Usage limits default to no site cap and no per-customer cap unless you set them. Re-running with the same name updates the existing coupon.
| Parameter | Value |
|---|---|
-coupon_name(required) | Unique coupon code (e.g., VIP-GOLD-42) |
-discount_type | fixed_cart, fixed_product, or percent |
-amount | Discount amount (e.g., 15) |
-expiry | Absolute date or phrase like "30 days", "end of month" |
-usage_limit | Total times the coupon can be used site-wide |
-usage_limit_per_user | Per-customer usage cap |
-minimum_amount | Minimum cart spend to apply |
-product_ids | Comma-separated product IDs the coupon applies to |
-email_restrictions | Comma-separated emails — only these customers can redeem |
| Can be used in |
Real example
You run a monthly VIP loyalty program. The rule: every customer who spent over $500 last month gets a personalized 15% coupon valid for 30 days, with their name in the code.
The macro: filter users with spend over $500 last month → for each user, generate a unique coupon code like VIP-{{step1.username}}-{{step1.user_id}} with create coupon, restricted to their email, 15% off, 30-day expiry → send them a template email with the code. Monthly schedule triggers the macro. Zero manual work.
Result: 47 unique coupons created, 47 personalized emails sent, in under five minutes of macro execution.
Goes further with TrueCommander
{{step1.coupon_code}} from the prior step.