WooCommerce REST API - 获取订单的自定义字段
我正在使用 WooCommerce REST API(http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction) 并且能够成功下载客户、订单等.
I'm using the WooCommerce REST API (http://woocommerce.github.io/woocommerce-rest-api-docs/#introduction) and are able to download Customers, Orders etc successfully.
我的客户在结账页面添加了一些自定义字段,例如:
My customer has added some custom fields to the checkout page, e.g.:
po_number
accounts_email
我希望能够在请求订单时获取这些自定义字段,例如:
I would like to be able to GET these custom fields when requesting an ORDER, e.g.:
/wp-json/wc/v1/orders/4568
目前,当我收到订单时,没有返回任何自定义字段.我试过添加
At the moment none of the custom fields are returned when I GET an Order. I've tried adding
?filter[meta]=true
到请求 URL,但这没有任何区别.有没有办法修改 GET URL 以包含所有自定义字段?在 REST API 文档中找不到任何对自定义字段的引用.
to the request URL but that doesn't make any difference. Is there a way I can modify the GET URL to include all custom fields? Couldn't find any reference in the REST API docs to custom fields.
我和你一样挣扎过,但结果证明使用较新的 v2 REST API 为我解决了这个问题.所以,而不是:
I have struggled like you did, but then it turns out using the newer v2 REST API solves the issue for me. So instead of:
/wp-json/wc/v1/orders/4568
我现在使用:
/wp-json/wc/v2/orders/4568
并且自定义字段将包含在带有键 meta_data
的响应中,即使是那些以 _
开头的隐藏字段.
And custom fields will be included in the response with the key meta_data
, even with those hidden fields starting with _
.