Woocommerce Orders Rest API:添加优惠券代码 [英] Woocommerce Orders Rest API: Add a coupon code
问题描述
我访问了 官方 WooCommerce Rest API 文档创建订单"部分.我正在尝试通过 API 创建订单,但是当我想使用应用优惠券创建订单时,我不知道如何制作.
I have Visited The official WooCommerce Rest API documentation "Create an Order" section. I am trying to create an order via the API, but when I want to create the order with the apply coupon, I don't know how to make it.
当我通过 REST API 创建订单时,如何将优惠券代码作为折扣传递?
How I will pass the coupon code as a discount when I create the order through the REST API?
在相关官方文档中我没有找到任何传递优惠券代码或折扣的请求参数.
In the related official documentation I don't find any request parameter to pass a coupon code or a discount.
在WooCommerce中通过rest API创建订单时,请建议如何传递优惠券代码.
Please suggest how to pass the coupon code when creating order via rest API in WooCommerce.
推荐答案
你应该需要在你的数据数组中添加'coupon_lines'
,比如:
You should need to add in your data array 'coupon_lines'
, something like:
'coupon_lines' => [
[
'code' => 'mycouponcode',
'discount' => '5',
'discount_tax' => '0.75',
'meta_data' => [
[
'key' => 'coupon_data',
'value' => [
'id' => '1234',
'code' => 'mycouponcode',
'amount' => '10',
/* ... and so on ... */
]
]
]
]
]
meta_data
数组是所有 woocommerce 优惠券元数据.这应该有效......
The meta_data
array is all the woocommerce coupon meta data. This should work…
这篇关于Woocommerce Orders Rest API:添加优惠券代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!