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 8A page load for URL destinations.
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.
Shown in advanced mode, where commands start with tp. In easy mode you type the same command without the tp prefix.
Relative expiry phrases just work. Pass -expires="7 days" or -expires="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) | The 1–200 byte code customers enter at checkout; must not require storage rewriting (required) |
-discount_type | Type of discount |
-amount | Non-negative discount amount; percentage discounts must be from 0 to 100 |
-expires | Future site-calendar expiry within 100 years. YYYY-MM-DD or relative like '7 days', '1 month' |
-usage_limit | Max total number of times this coupon can be used |
-usage_limit_per_user | Max times a single customer can use this coupon |
-minimum_amount | Minimum cart subtotal required for this coupon |
-product_ids | Comma-separated existing WooCommerce product IDs the coupon applies to |
-email_restrictions | Comma-separated customer emails allowed to use this coupon; every address must be valid |
| 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.Frequently asked questions
tp create coupon -coupon_name=SUMMER25 -discount_type=percent -amount=25.-discount_type: percent for a percentage off, fixed_cart for a flat amount off the cart, and fixed_product for a flat amount per item.-expires accepts an absolute date or a relative phrase like -expires="7 days", so a flash-sale code can expire itself without you remembering to disable it.-usage_limit to cap total redemptions, -minimum_amount to require a minimum spend, and -individual_use=true to stop it stacking with other coupons.