【发布时间】:2018-12-28 16:34:26
【问题描述】:
我正在开发 React Native 项目,该项目使用 woocommerce rest api 在应用程序上显示产品。
有没有办法通过userwoocommerce rest api根据用户输入搜索产品??
提前致谢
【问题讨论】:
标签: rest react-native woocommerce woocommerce-rest-api
我正在开发 React Native 项目,该项目使用 woocommerce rest api 在应用程序上显示产品。
有没有办法通过userwoocommerce rest api根据用户输入搜索产品??
提前致谢
【问题讨论】:
标签: rest react-native woocommerce woocommerce-rest-api
是的。我正在使用 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
【讨论】:
_fields[]="sku" 添加到 URL:跨度>