Sign inBlogSupportContact
WooCommerce

Create WooCommerce coupons from a macro step

Every coupon field in a single command: discount type, amount, expiry, usage limits, product restrictions. Generate unique codes programmatically, trigger them on events.

5 min read May 2026 create coupon

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

Manually create each couponHand-type 80 different codes. Humans make typos. Coupons often expire unnoticed.
Write custom WC_Coupon PHPRequires developer. One-shot snippets that don't integrate with WordPress events.
Install a bulk-coupon pluginAnother subscription. Its own admin page. Clunky at automating based on events.

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.

TrueCommander
Coupon created
Active immediately
Code: VIP-GOLD-42percent
Discount: 15% off
Expires: Jun 18, 202630 days
Usage: 1 per customer, no site limit

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.

1
Set name and discountCoupon code and discount type (fixed_cart, fixed_product, percent)
2
Add restrictions (optional)Expiry, usage limits, product/category restrictions, email restrictions
3
Coupon is active immediatelyAppears on the WooCommerce Coupons page. Customers can redeem at checkout.
ParameterValue
-coupon_name(required)Unique coupon code (e.g., VIP-GOLD-42)
-discount_typefixed_cart, fixed_product, or percent
-amountDiscount amount (e.g., 15)
-expiryAbsolute date or phrase like "30 days", "end of month"
-usage_limitTotal times the coupon can be used site-wide
-usage_limit_per_userPer-customer usage cap
-minimum_amountMinimum cart spend to apply
-product_idsComma-separated product IDs the coupon applies to
-email_restrictionsComma-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

Ready?

Automate WooCommerce promotions.

This is one of 91 commands. All included with every license.

Cookies. The short version.

Essential cookies keep the cart and theme working. Analytics only fire if you say yes. Read our policy.