I have Visited The official WooCommerce Rest API documentation "Create an Order" section. I am trying to create an order via the API, but when I want to create the order with the apply coupon, I don't know how to make it.
How I will pass the coupon code as a discount when I create the order through the REST API?
In the related official documentation I don't find any request parameter to pass a coupon code or a discount.
Please suggest how to pass the coupon code when creating order via rest API in WooCommerce.
You should need to add in your data array 'coupon_lines'
, something like:
'coupon_lines' => [
[
'code' => 'mycouponcode',
'discount' => '5',
'discount_tax' => '0.75',
'meta_data' => [
[
'key' => 'coupon_data',
'value' => [
'id' => '1234',
'code' => 'mycouponcode',
'amount' => '10',
/* ... and so on ... */
]
]
]
]
]
The meta_data
array is all the woocommerce coupon meta data. This should work…
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With