【问题标题】:problum to get woocommerce product by category in REST API在 REST API 中按类别获取 woocommerce 产品的问题
【发布时间】:2016-11-19 09:18:20
【问题描述】:

你好,我正在使用 woocommerce REST API 的 REST API, 我想按类别获取产品。当我通过这个网址时,我得到了所有产品。

  https://www.ezdarshan.com/wc-api/v2/products/?consumer_key=ck_dbf0f35e37dc0xxxxxxxxxxxb31d2&consumer_secret=cs_ea299e9b86xxxxxxxxxxxxxxf785a9f77ec7

但是当我使用这样的过滤器时:?category=56,37

我再次获得了所有产品,但我只想要与这些类别相关的产品

我关注这个文档:https://woothemes.github.io/woocommerce-rest-api-docs/?php#list-all-products

有人帮帮我

【问题讨论】:

  • 请注意:WooCommerce Rest API 的版本是什么?...有 4 个可能的版本...请尽可能详细地更新您的问题,以便有机会获得帮助。

标签: wordpress rest woocommerce woocommerce-rest-api


【解决方案1】:

这可能有点晚回答,但可能对其他人有帮助

根据新的 wordpress REST API 版本,这对我有用

https://www.xxxx.com/wp-json/wc/v3/products?category=categoryid

【讨论】:

    【解决方案2】:

    我刚刚解决了类似的问题。使用 slug 代替 id / name。它对我有用。

    https://yourwebsite.com/api/user/proxy/products/?filter[category]=<SLUG OF CATAGORY>
    

    正确:(注意尾部斜杠已删除)

     https://yourwebsite.com/api/user/proxy/products?filter[category]=<SLUG OF CATAGORY>
    

    【讨论】:

    • 你确定这是 woocommerce api 吗?您可以参考文档吗?
    猜你喜欢
    • 2014-11-06
    • 2018-10-22
    • 2019-03-03
    • 2018-02-07
    • 1970-01-01
    • 2019-08-09
    • 1970-01-01
    • 2016-01-09
    • 2014-06-27
    相关资源
    最近更新 更多