I am trying to create an order on my WooCommerce store from my mobile application using the REST API v2. The order is created successfully but I can't find any solution to the following issues.
coupon_lines
array within the order
object and when the order is viewed on the admin panel, it shows the coupon there but the order total
is not affected at all.total
and discounts based on the applied coupon manually. I tried to set discount_total
within the order
object equal to the amount which is the value of the coupon. I also update the total
manually as well. But again, all the values that I pass are ignored and the order total
is equal to the sum of the prices of all line items (ignoring discount_total
).Here is a sample JSON object that is sent to the API from my app.
What other options do I have to set an order total and discount manually? Any suggestions are welcome.
I am trying to create an order on my WooCommerce store from my mobile application using the REST API v2. The order is created successfully but I can't find any solution to the following issues.
coupon_lines
array within the order
object and when the order is viewed on the admin panel, it shows the coupon there but the order total
is not affected at all.total
and discounts based on the applied coupon manually. I tried to set discount_total
within the order
object equal to the amount which is the value of the coupon. I also update the total
manually as well. But again, all the values that I pass are ignored and the order total
is equal to the sum of the prices of all line items (ignoring discount_total
).Here is a sample JSON object that is sent to the API from my app.
What other options do I have to set an order total and discount manually? Any suggestions are welcome.
In your coupon_lines
array, each item in the array needs 2 properties: code
(the coupon code itself) and amount
, which is either a flat fee (eg 50.00 off) or a discount (eg 10% off). Your structure ends up looking like:
"coupon_lines": [
{
"code": "MYCODE1",
"amount": "10.00"
},
{
"code": "MYCODE2",
"amount": "25.00"
}
]
If you're already doing this - consider posting an example request here.