Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
842 views
in Technique[技术] by (71.8m points)

wordpress - Create order with coupon lines using WooCommerce Rest API

We are trying to create an order and apply a coupon code using woo commerce API as explained in the woo commerce documentation. following is the JSON we are trying to send with the API request.

{
"order":{
"payment_details":{"method_id":"cash","method_title":"cash","paid":false},
"billing_address":{"first_name":"kamran","last_name":"masud","company":null,"address_1":"Dubai Dubai - United Arab Emirates",
    "address_2":null,"city":null,"state":null,"postcode":null,"country":null,"email":null,"phone":"541234566"},
"shipping_address":{"first_name":"kamran","last_name":"masud","company":null,"address_1":"Dubai Dubai - United Arab Emirates",
"address_2":null,"city":null,"state":null,"postcode":null,"country":null},
"customer_id":116,
"line_items":[
    {"product_id":11734,"variation_id":0,"quantity":108,"total":"3834"},
    {"product_id":10893,"variation_id":0,"quantity":1,"total":"206.56"},
    {"product_id":11872,"variation_id":0,"quantity":1,"total":"41.49"},
    {"product_id":11866,"variation_id":0,"quantity":1,"total":"53.17"},
    {"product_id":11865,"variation_id":0,"quantity":1,"total":"53.17"},
    {"product_id":11965,"variation_id":0,"quantity":1,"total":"47.81"},
    {"product_id":11626,"variation_id":0,"quantity":1,"total":"323.73"},
    {"product_id":11927,"variation_id":0,"quantity":1,"total":"144.3"}],
"shipping_lines":[],
"fee_lines":[
    {"id":0,"title":"Shipping :","tax_class":null,"total":"0","total_tax":null}
    ],
"coupon_lines":[
    {
    "code":"fixedcart10",
    "discount":"80",
    "meta_data":[
        {
            "key":"coupon_data",
            "value":[
            {
                "id":"168026",
                "code":"fixedcart10",
                "amount":"10"
            }
            ]
        }
    ]
    }
],
"discount_total":null,
"shipping_total":null,
"total":null,"status":"processing"}}

coupon goes through with the order it doesn't get applied in the created order. following is the screenshot of the order created. enter image description here

Any help would be appreciated. thanks

question from:https://stackoverflow.com/questions/65935258/create-order-with-coupon-lines-using-woocommerce-rest-api

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...