WooCommerce API – I can’t get the ‘search’ parameter to work for products
-
Hi there, I’m hoping this is the right forum to be posting this in!
I am new to WordPress and WooCommerce, and I’ve just started making use of the REST API with my NodeJS web app. This had been going smoothly, until I hit an issue that I can’t seem to get past.
I want to use the API to retrieve a list of products from WooCommerce, that match a given search term (preferably a partial match on the product name).
The API docs lists a ‘search’ parameter, which should “Limit results to those matching a string”, but I can’t get it to work, nor can I find any use examples of it.
api.get('products', { 'per_page': '50' })
or
api.get('products?per_page=50')
Will successfully return 50 products.
api.get('products', { 'per_page': '50', 'search': 'test' })
or
api.get('products?per_page=50&search=test')
Does NOT return any products. I would expect any products with ‘test’ in their name to be returned. I can only assume that I must be using the search parameter incorrectly, but I can’t find any examples of its use.
It would be greatly appreciated if somebody could point me in the right direction, or maybe suggest a different method to achieve what I’m trying to do.
Many thanks!
- The topic ‘WooCommerce API – I can’t get the ‘search’ parameter to work for products’ is closed to new replies.