Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fetch products by category in Woocommerce REST API

I'm using Woocomerce for my wordpress shopping cart. I'm connect my Android App to my Wordpress database through Woocommerce REST API. I need to get products by category on my App. There is no provision in the REST API to fetch product by category.

I tried by using the filter attribute:

https://example.com/wc-api/v1/products?filter[product_cat]=gedgets&consumer_key=ck_9354534x&consumer_secret=cs_dx7345345

This is return me all the products.

like image 819
batMask Avatar asked Sep 12 '14 07:09

batMask


People also ask

How do I set up REST API in WooCommerce?

Go to: WooCommerce > Settings > Advanced > REST API. Note: Keys/Apps was found at WooCommerce > Settings > API > Key/Apps prior to WooCommerce 3.4. Select Add Key. You are taken to the Key Details screen. Add a Description.

How do I fetch all products in a specific category?

To fetch all products in a certain category, you will want to use the products API with the category parameter: Replace ID with the ID of your category. This is in the documentation here:

How to get all products by category in REST API?

There is no provision in the REST API to fetch product by category. I tried by using the filter attribute: This is return me all the products. Show activity on this post. In this case you should use the filters... however, It worked for me : the 16 is a sample of category id... Show activity on this post.


1 Answers

In this case you should use the filters...

however, It worked for me :

http://www.example.com/wp-json/wc/v1/products?category=16

the 16 is a sample of category id...

like image 190
ultra.deep Avatar answered Oct 06 '22 00:10

ultra.deep