【问题标题】:Product Search in woocommerce rest apiwoocommerce rest api中的产品搜索
【发布时间】:2018-12-28 16:34:26
【问题描述】:

我正在开发 React Native 项目,该项目使用 woocommerce rest api 在应用程序上显示产品。

有没有办法通过userwoocommerce rest api根据用户输入搜索产品??

提前致谢

【问题讨论】:

    标签: rest react-native woocommerce woocommerce-rest-api


    【解决方案1】:

    是的。我正在使用 WooCommerce 的 Rest API V3 并使用过滤器在我的应用程序中进行搜索。代码看起来像这样 -

    WooCommerce.getAsync("products?filter[q]=" + this.searchQuery + "&page=" + this.page)
    

    API 语法为:GET /products?filter[q]=search-keyword

    因此,当用户在搜索栏中搜索红色时 - 它会将红色作为查询并返回使用“红色”关键字过滤的结果。

    希望对你有帮助。

    编辑:这是我在搜索中输入红色并创建请求时的样子 -

     http://myweb.com/wc-api/v3/products?filter%5Bq%5D=red&oauth_consumer_key=xxxxxxxxx&oauth_nonce=eupq1i8MlyxGsnAYq2bL6wg9UJALsdaX&oauth_signature_method=HMAC-SHA256&oauth_timestamp=1545985748&oauth_version=1.0&filter%5Bq%5D=red&oauth_signature=xxxxxxxx%2B0O4hyxfA%3D
    

    【讨论】:

    • @Parth - 看起来过滤器在 Kanak 的示例中被引用了两次 - 可能是您的问题...此外,如果您只需要特定字段,您可以将 _fields[]="sku" 添加到 URL:跨度>
    猜你喜欢
    • 1970-01-01
    • 2016-01-06
    • 1970-01-01
    • 2021-09-21
    • 1970-01-01
    • 1970-01-01
    • 2017-11-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多