I am using REST API V3 and creating an order via following and posting variation. Although I am sending variation_id correctly in line items of order object. Here is the request object I am sending -
URL: http://mywebsite.com/wc-api/v3/orders?.............
Request Method: POST
Status Code: 201 Created
ORDER OBJECT-
{"order": {
"payment_method": "cod",
"payment_method_title": "Cash On Delivery",
"set_paid": false,
"billing_address": {
"first_name": "I ey",
"last_name": "Xhh",
"address_1": "Gdb",
"address_2": "Dvhs",
"city": "Gsg",
"state": "New Delhi",
"postcode": "54619",
"country": "India",
"email": "[email protected]",
"phone": "54646"
},
"shipping_address": {
"first_name": "I ey",
"last_name": "Xhh",
"address_1": "Gdb",
"address_2": "Dvhs",
"city": "Gsg",
"state": "New Delhi",
"postcode": "54619",
"country": "India",
"email": "[email protected]",
"phone": "54646"
},
"line_items": [
{
"product_id": 420,
**"variation_id": 429,**
"quantity": 1
},
{
"product_id": 420,
**"variation_id": 425,**
"quantity": 1
}
]}}
Unfortunately, RESPONSE returned after 201 does not have variation_id in line_items object -
"line_items": [
{
"id": 101,
"subtotal": "5100.00",
"subtotal_tax": "0.00",
"total": "5100.00",
"total_tax": "0.00",
"price": "5100.00",
"quantity": 1,
"tax_class": "",
"name": "Alpha Cement",
"product_id": 95,
"sku": "",
"meta":[]
},
{
"id": 102,
"subtotal": "20000000.00",
"subtotal_tax": "0.00",
"total": "20000000.00",
"total_tax": "0.00",
"price": "20000000.00",
"quantity": 1,
"tax_class": "",
"name": "Apple MacBook Core i5 7th Gen",
"product_id": 94,
"sku": "",
"meta": [
]
},
{
"id": 103,
"subtotal": "82000.00",
"subtotal_tax": "0.00",
"total": "82000.00",
"total_tax": "0.00",
"price": "82000.00",
"quantity": 1,
"tax_class": "",
"name": "CR SHEET",
"product_id": 420,//correct product id
"sku": "",
"meta": [
]
},
{
"id": 104,
"subtotal": "82000.00",
"subtotal_tax": "0.00",
"total": "82000.00",
"total_tax": "0.00",
"price": "82000.00",
"quantity": 1,
"tax_class": "",
"name": "CR SHEET",
"product_id": 420, //correct product id
"sku": "",
"meta": [
]
}
],
NOTE: An order is successfully received on WooCommerce side but that's for the main Product and not the variation.
Please help, if anyone seeing I am doing anything wrong here. Thanks!