Create a coupon
wp_wc_create_couponWooCommerce: create a published coupon with a new, unused code, an amount, a discount type and an optional expiry date. Everything is checked before the coupon exists: a code already in use, an unknown discount type or an impossible date is refused. Returns created, id and the code as WooCommerce stores it (normally lower-cased). A repeated call with the same code after the first has finished is refused, since the code is then in use; two calls that overlap (a retry while the first still runs) are not guarded against and can create two coupons. wp_wc_list_coupons lists the existing coupons; changing or deleting one is done in WooCommerce. Needs manage_woocommerce. Requires WooCommerce. Forwarded by AlphaBridge Connect to the one site this connection reaches.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Coupon code customers enter. WooCommerce normalises it (sanitised, lower-cased); a backslash is refused. | |
| amount | Yes | A number of at least 0: a percentage or an amount in shop currency, depending on discount_type. WooCommerce refuses a percentage over 100. | |
| expires | No | Expiry date, YYYY-MM-DD. Omitted: the coupon does not expire. | |
| discount_type | No | percent, fixed_cart or fixed_product. Default percent. |