In WooCommerce, I created a coupon like this.
$coupon_data = [
'code' => $code,
'amount' => '15',
];
$wooCommerceMRLiveV2 = WooCommerceConnection::wooCommerceMRLiveV2();
$retval2 = $wooCommerceMRLiveV2->post('coupons', $coupon_data);
And when the coupon code is used, I need to delete it manually.
But according to API documentation, I can only delete coupons using id. But at the moment when the coupon code is used, I don’t know the id.
So, is there any method to delete the coupon using coupon code? Or can I retrieve id from code?
3
Answers
I could delete the coupon like this. I found it here.
Try this
This is my working code about remove coupon.
Thanks