Exclude facet options if there they are unavailable
Is your enhancement related to a problem? Please describe.
When you enter a Woocommerce category or use the search and the taxonomy is not available to facet on all the options are greyed out.
I would like the option to hide them completely.
This becomes a problem when you have a "brand" attribute with 100+ brands. I rather only show the relevant brands instead of all brands in the store.
Same goes for product categories. The list can become really big with greyed out categories instead of just showing the relevant ones.
Describe the solution you'd like
Hide all greyed out facets completely from the facet.
This would be an interesting option @Zyles, thanks. In the meantime, the ep_facet_widget_term_html filter can be used to achieve a similar result:
add_filter(
'ep_facet_widget_term_html',
function( $html, $term ) {
return ( ! empty( $term->count ) ) ? $html : '';
},
10,
2
);
Note: worth pointing out the "similar" there, as the search field displayed above the list will not use the correct number of terms being displayed.