Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WooCommerce REST API: Only returns 10 categories

I'm working with WooCommerce api v3, and when I call

$woocommerce->get('products/categories');

It returns only 10 results. I read the documentation and there is no specification about how to list all categories from api, but I have more than 40 categories on wordpress.

Someone already had this problem before?

Thanks!

like image 445
Fernando Aureliano Avatar asked Oct 24 '25 21:10

Fernando Aureliano


1 Answers

you can pass more parameters to the function as you can see in the documentation. This should work: $woocommerce->get('products/categories', array( 'per_page' => -1 ) );

Looks like -1 doesn't work to display all the categories, so a positive integer needs to be in place instead.

$woocommerce->get('products/categories', array( 'per_page' => 99 ) );

like image 163
Alberto Marin Avatar answered Oct 26 '25 11:10

Alberto Marin