I'm using WooCommerce on my Wordpress site, and have a widget in the sidebar showing all product categories. It's setup to hide empty categories, and that works well. However, it still shows categories that contain only products that are out of stock - that I would like to change.
Technical explanation: WooCommerce products are a custom post type (
product), the product categories are a custom taxonomy (
product_cat), and the stock count is a custom field on the products (
_stock). The WooCommerce Product Categories widget shows them using
wp_list_categories(). I have tried digging into a code to look for some filter call that I could hook onto, but failed to find one.
Is there a good way of doing this without modifying core or WooCommerce code? Maybe a hook/filter somewhere that I missed that would allow to check the custom field value?