ElasticPress icon indicating copy to clipboard operation
ElasticPress copied to clipboard

Exclude facet options if there they are unavailable

Open Zyles opened this issue 3 years ago • 1 comments

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.

Zyles avatar May 12 '22 22:05 Zyles

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.

felipeelia avatar Jun 02 '22 13:06 felipeelia