gpt4 book ai didi

WooCommerce API 在媒体中创建图像,即使它们存在

转载 作者:行者123 更新时间:2023-12-04 01:36:14 27 4
gpt4 key购买 nike

可能是什么原因?尝试通过 REST API 在 WooCommerce 中批量更新产品图片(和价格)。图像已存在于 wordpress 媒体库中,并且链接已正确复制。但是,它不是使用图像,而是创建新图像。

请求:POST。网址:https://SiteURL/wp-json/wc/v2/products/xxxx?consumer_key=c______&consumer_secret=_____

主体:

 {"update":[
{"regular_price":"448",
"images":[
{"src":"https://urlToImage.jpg",
"position":0, "name": "test"}
],"id":"xxxx"}]}

作为响应,我可以看到它使用相同的 url 创建图像,但由于库中已经有一个图像,它会将 -1 添加到 url。

谢谢转发:)

最佳答案

由于这是图像已存在的更新,因此您需要设置图像元素的 id 成员。否则,WooCommerce 将此解释为向产品库添加新图像的请求。

关于WooCommerce API 在媒体中创建图像,即使它们存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49640046/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com