向WooCommerce订单添加额外数据API(WP-JSON)
当我消耗WP-JSON/WC/V2/订单端点时,我得到的结果类似于以下结果,
[{
"id": 744276,
"parent_id": 0,
"status": "on-hold",
"currency": "BRL",
"version": "6.4.0",
"prices_include_tax": false,
"date_created": "2022-04-14T11:46:29",
"date_modified": "2022-04-14T11:46:31",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"cart_tax": "0.00",
"total": "45.59",
"total_tax": "0.00",
"customer_id": 1,
"order_key": "wc_order_iDHRxaUAWKKMS",
"billing": {
"first_name": "Name",
"last_name": "Last",
"company": "",
"address_1": "",
"address_2": "",
"city": "",
"state": "",
"postcode": "",
"country": "BR",
"email": "[email protected]",
"phone": ""
},
..........
我需要在“ billing ”部分中添加一个字段,在此结果中,此字段将仅针对此API生成。 WooCommerce是否提供了这样做的过滤器?
When I consume the wp-json/wc/v2/orders endpoint, I get a result similar to the following
[{
"id": 744276,
"parent_id": 0,
"status": "on-hold",
"currency": "BRL",
"version": "6.4.0",
"prices_include_tax": false,
"date_created": "2022-04-14T11:46:29",
"date_modified": "2022-04-14T11:46:31",
"discount_total": "0.00",
"discount_tax": "0.00",
"shipping_total": "0.00",
"shipping_tax": "0.00",
"cart_tax": "0.00",
"total": "45.59",
"total_tax": "0.00",
"customer_id": 1,
"order_key": "wc_order_iDHRxaUAWKKMS",
"billing": {
"first_name": "Name",
"last_name": "Last",
"company": "",
"address_1": "",
"address_2": "",
"city": "",
"state": "",
"postcode": "",
"country": "BR",
"email": "[email protected]",
"phone": ""
},
..........
I need to add one more field in the "billing" part in this result, this field would be generated only for this API. Does Woocommerce provide a filter to do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)