1

https://example.com/wp-json/wc/v3/products/10 product type=variable and it is working fine

https://example.com/wp-json/wc/v3/products/11 product type=variation and it is working fine

But it fetch only one product (with id 10) using include parameter like

https://example.com/wp-json/wc/v3/products?include=10,11

I need help so that i can fetch 2 or more products (any type) in one API call

Mohit
  • 19
  • 3

2 Answers2

1

A bit late but maybe someone has the same problem still

The include parameter should be array and as this thread explains How to pass an array within a query string?

you should send your parameters as this

https://example.com/wp-json/wc/v3/products?include[]=10&include[]=11
Bozabit
  • 23
  • 6
0

Do you need to retrieve all the products in woo commerce. If try with this call " /wp-json/wc/v3/products"

  • No, i don't want to retrieve all the products. Actually i have a cart with simple product ids and variation ids and i want to retrieve all those products with one API call using include parameter. But include parameter is fetching only products and not variations – Mohit Dec 03 '19 at 15:12
  • I think Woo commerce API doesn't support that because variations can only retrieved with their parent ID's. You can check this API calls for retrieving variations "/wp-json/wc/v3/products//variations". We can't retrieve simple and variations in one call. – Kalyan Sangartula Dec 03 '19 at 17:09
  • 1
    No, variation can also be retrieved using "/wp-json/wc/v3/products/ – Mohit Dec 08 '19 at 14:23