【问题标题】:GET/UPDATE custom field in products which is from custom post type by using REST API in WooCommerce在 WooCommerce 中使用 REST API 获取/更新来自自定义帖子类型的产品中的自定义字段
【发布时间】:2022-07-21 04:48:39
【问题描述】:

我在 WooCommerce 中使用自定义插件。在该自定义插件中,创建了一个自定义帖子类型库存。我将该自定义帖子类型映射到产品元字段。但是通过 REST API 元字段更新以映射帖子类型并没有更新。自定义产品类型也不会通过 REST API 更新。如何通过 REST API 更新这些字段。

自定义帖子类型映射到产品屏幕:

自定义帖子类型创建屏幕:

以下是我通过 API 更新产品类型时得到的响应:

  {
      "code": "rest_invalid_param",
      "message": "Invalid parameter(s): type",
      "data": {
      "status": 400,
      "params": {
                   "type": "type is not one of simple, grouped, external, and variable."
                 },
      "details": {
             "type": {
             "code": "rest_not_in_enum",
             "message": "type is not one of simple, grouped, external, and variable.",
             "data": null
            }
           }
         }
        }

如果有人遇到过这个问题,请告诉我解决方案。提前致谢。

【问题讨论】:

    标签: woocommerce endpoint wordpress-rest-api woocommerce-rest-api


    【解决方案1】:

    我认为您使用的插件不支持 API,建议您向他们询问。默认 WC API 仅支持简单、分组、外部和可变产品类型。

    如果您在更新时从请求中删除“类型”字段,它应该可以工作。

    【讨论】:

      猜你喜欢
      • 2016-09-28
      • 2015-07-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多