【发布时间】:2019-05-24 23:20:48
【问题描述】:
我正在使用 REST API V3 并通过关注和发布变体创建订单。尽管我在订单对象的行项目中正确发送了variation_id。这是我发送的请求对象 -
URL: http://mywebsite.com/wc-api/v3/orders?.............
Request Method: POST
Status Code: 201 Created
订单对象-
{"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": "hdj@bsb.bsn",
"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": "hdj@bsb.bsn",
"phone": "54646"
},
"line_items": [
{
"product_id": 420,
**"variation_id": 429,**
"quantity": 1
},
{
"product_id": 420,
**"variation_id": 425,**
"quantity": 1
}
]}}
很遗憾,201 之后返回的 RESPONSE 在 line_items 对象中没有variation_id -
"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": [
]
}
],
注意:WooCommerce 方面已成功收到订单,但这是针对主要产品而非变体的。
请帮忙,如果有人看到我在这里做错了什么。 谢谢!
【问题讨论】:
-
任何人请回答我的问题。
-
我会仔细检查这些变体是否已启用并且可以购买。文档说应该返回一个variation_id:woocommerce.github.io/woocommerce-rest-api-docs/…
标签: android post ionic-framework hybrid-mobile-app woocommerce-rest-api