Woocommerce REST API not considering discounts and coupons

admin2025-01-07  3

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.

  1. I send a 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.
  2. Then I decided to calculate the 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.

  1. I send a 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.
  2. Then I decided to calculate the 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.

Share Improve this question edited Aug 1, 2018 at 14:10 Samarth Agarwal asked Aug 1, 2018 at 13:47 Samarth AgarwalSamarth Agarwal 1032 silver badges8 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736258685a532.html

最新回复(0)