WooCommerce-REST-API-Client-Library
WooCommerce-REST-API-Client-Library copied to clipboard
How can I fetch only parent product categories ?
I am using $client->products->get_categories();.. It give me all categories. But I want only parent product categories.
Simply put all the values into a variable and loop through looking for parent = '0'
$categories = $client->products->get_categories();
$parentcats = array();
foreach($categories as $category) {
if($category['parent'] == 0) {
$parentcats[] = $category;
}
}
print_r($parentcats);
Yes you are correct. I know.it is possible in client end. I want filter from server end..not in client end....