I’m trying to create a coupon via the woocommerce rest api:
https://woocommerce.github.io/woocommerce-rest-api-docs/#create-a-coupon
I can create coupons fine, but it seems the expiration date is always unset.
e.g. posting
{
"code": "IGNME",
"description": "IGNORE ME",
"discount_type": "percent",
"amount": 5,
"date_expires": "2024-03-21T19:23:00",
"date_expires_gmt": "2024-03-21T18:23:00"
}
Would return;
...
"date_expires": null,
"date_expires_gmt": null,
...
Checking on the site and there is no expiration date aswell. I tried date/time different formats but could not get a valid one.
How can I create woocommerce coupon with an expiration date using the rest api?
2
Answers
I'm not sure why, but apparently setting
date_expires
in a meta field works, like in this sample:This format also worked for me, and the
date_expires
anddate_expires_gmt
is not null any more: