简体   繁体   English

通过REST API设置WooCommerce产品密码

[英]Set WooCommerce product password via REST API

I am having some difficulty finding out whether it is possible to set the password-protected status of a product via the WooCommerce REST API. 我很难确定是否可以通过WooCommerce REST API设置产品的密码保护状态。 In the documentation, it allows you to set product 'status', but does not list a protected option. 在文档中,它允许您设置产品的“状态”,但未列出受保护的选项。

This is the field I am trying to set: 这是我要设置的字段:

I thought perhaps this could be done by the Wordpress API (rather than the WooCommerce one), but would appreciate a bit of help as to how I would access the right product. 我以为这可以通过Wordpress API(而不是WooCommerce)来完成,但是对于我如何访问正确的产品会有所帮助。

If you edit your product the URL looks like this "/wp-admin/post.php?post=[id]&action=edit" where [id] is your product id. 如果您编辑产品,则URL看起来像这样的“ /wp-admin/post.php?post=[id]&action=edit”,其中[id]是您的产品ID。

The Wordpress REST API endpoint for this product is "/wp-json/wp/v2/product/[id]". 该产品的Wordpress REST API端点为“ / wp-json / wp / v2 / product / [id]”。 With this endpoint you can change the password the same way as for Wordpress posts or pages. 使用此端点,您可以像使用Wordpress帖子或页面一样更改密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM