I’m trying to display a list of all product categories and the price range of the products within those categories.
E.g
Headwear – £30-£150
Shoes – £35-£300
Where "Headwear" is the Product Category Name, "£30" is the lowest price of a product within that category and "£150" is the highest.
So far I have used the following code to list the categories, but not sure how to check for products within each and get the prices etc.
$order = 'asc';
$hide_empty = false ;
$cat_args = array(
'orderby' => $orderby,
'order' => $order,
'hide_empty' => $hide_empty,
);
$product_categories = get_terms( 'product_cat', $cat_args );
if( !empty($product_categories) ){
echo '
<ul>';
foreach ($product_categories as $key => $category) {
echo '
<li>';
echo '<a href="'.get_term_link($category).'" >';
echo $category->name;
echo '</a>';
echo '</li>';
}
echo '</ul>
';
}
Any help would be greatly appreciated. I’ve asked this on the woocommerce support forum but no responses.