【发布时间】:2020-01-31 10:30:21
【问题描述】:
我想使用 Woocommerce API 更新产品的库存。 我设法通过查询 产品 ID 并使用以下代码来做到这一点:
curl -X PUT \
https://www.kilikili.be/wp-json/wc/v3/products/10340 \
-H ...
-b ...
-d '{
"manage_stock": true,
"stock_quantity": "1"
}'
但是,我现在想使用 sku 来做同样的事情。
我试过这个:
curl -X PUT \
'https://www.kilikili.be/wp-json/wc/v3/products?sku=test' \
-H ...
-b ...
-d '{
"manage_stock": true,
"stock_quantity": "2"
}'
但是,我收到了以下回复:
{
"code": "rest_no_route",
"message": "No route was found matching the URL and the request method",
"data": {
"status": 404
}
}
关于如何实现这一点或是否有可能的任何想法?
【问题讨论】:
-
显然,这可以通过创建自定义端点来实现,我目前正在尝试使用此文档:developer.wordpress.org/rest-api/extending-the-rest-api/…
-
嗨@BarrieO,你找到解决方法了吗?您可以与我们分享任何解决方案吗?谢谢!
标签: wordpress api rest woocommerce sku