Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce REST API : query products by multiple attributes

According to the API : http://woocommerce.github.io/woocommerce-rest-api-docs/#list-all-products we can filter products by a single attribute. But Is it impossible to search by multiple attributes through API ?

Example : "I want red shirts". Here attribute is color and attribute term is red. To accomplish the search, the query string goes like this : products?category=17&attribute=pa_color&attribute_term=22&

And we get the red shirts only.

But for "I want red medium shirts" , here an additional size attribute with value medium is encountered. And according to the API there is no way to associate both the color and the size attributes in the query string. So the query -

products?category=17&attribute=pa_color&attribute_term=22&attribute=pa_size&attribute_term=24& 

returns all products from the store

Is there any workaround ?

like image 306
Md. Arafat Al Mahmud Avatar asked Nov 02 '25 07:11

Md. Arafat Al Mahmud


1 Answers

Try to request like this:

products?attribute=pa_color&attribute_term=51,50&per_page=100

Its worked for me. Latest woocommerce-api wc/v2!

like image 144
Ruslan Jackson Avatar answered Nov 04 '25 04:11

Ruslan Jackson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!