Add coupon to order using WooCommerce API v3

24 views Asked by At

I'm trying to apply a discount coupon when creating an order via WooCommerce v3 API. I'm testing this using Postman.

Without the coupon_lines, I am able to create the order. enter image description here

But with coupon_lines, I get error 500. enter image description here

Here's the JSON that I'm using:

{
    "payment_method": "payment_method_sb_test",
    "payment_method_title": "Test/Paymentless gateway ",
    "set_paid": true,
    "billing": {
        "first_name": "Test",
        "last_name": "Customer",
        "address_1": "1 Macquarie Street",
        "address_2": "",
        "city": "Parramatta",
        "state": "NSW",
        "postcode": "2150",
        "country": "AU",
        "email": "[email protected]",
        "phone": "1234567"
    },
    "shipping": {
        "first_name": "Test",
        "last_name": "Customer",
        "address_1": "1 Macquarie Street",
        "address_2": "",
        "city": "Parramatta",
        "state": "NSW",
        "postcode": "2150",
        "country": "AU"
    },
    "line_items": [
        {
            "product_id": "96153",
            "quantity": 1
        }
    ],
    "shiprate": {
        "method_id": "flat_rate",
        "method_title": "Standard Flat Rate",
        "total": "9.86"
    },
    "customer_note": "Test order",
    "coupon_lines": [
        {
            "code": "417AF65F7D07186FDB",
            "amount": "5"
        }
    ]
}

What am I missing? Please help.

0

There are 0 answers