Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce REST API GET multiple products by ID

I need to display all related products by eah product I have in my list.

Eg, In my app I have 3 products with id 1, 2, 3 product id 1 has 5,6,7 as related, product id 2 with related 8 and 9 etc..

Now I have an array with all the related [5,6,7,8,9..] How can I get only this ones from REST API?

I can call by single ID like that site.com/wp-json/wc/v2/products/5/

But doesn't work with multiple IDs like ../products/5/6/ or ../products/5,6/

Is this possible?

like image 204
Adrian Avatar asked Sep 27 '18 08:09

Adrian


1 Answers

you could use parameter 'include' to achieve that like below :

site.com/wp-json/wc/v2/products/?include=5,6,7,8,9

This will limit results to specific Id's.

like image 151
raju_odi Avatar answered Nov 17 '22 02:11

raju_odi