WooCommerce REST API GET multiple products by ID

僤鯓⒐⒋嵵緔 提交于 2021-01-27 05:39:39

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/52533166/woocommerce-rest-api-get-multiple-products-by-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!