Woocommerce Product Category Widget – hide categories that have no products in stock [closed]

Use the woocommerce_product_categories_widget_args and woocommerce_get_availability filters in a custom function to filter the product categories widget for out of stock products.

See what you can come up using these filters and post the code back here if you get stuck.

Here’s some code from my site which may help you get started.

add_filter( 'woocommerce_product_categories_widget_args', 'wpsites_exclude_product_cat_widget' );

function wpsites_exclude_product_cat_widget( $args ) {

$args['exclude'] = array('16','46');

return $args;
}

Here’s all the hooks for WooCommerce

Leave a Comment