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!
2
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 ) );
The below code will help you to get all categories at once