Forums › Forums › Search & Filter Pro › Hide UI Taxonomies that are empty
- This topic has 3 replies, 2 voices, and was last updated 9 years ago by
Trevor.
-
Anonymous(Private) August 10, 2017 at 2:20 pm #125464
I am using S&F Pro 2.3.4 with WooCommerce. I have filtering in the shop which is working great, however I want to hide filters that are empty.
So for example, if I’m in the T-Shirts category, the filtering taxonomy type “Flavour” wouldn’t return any products. At the moment it displays the filter in the li, with a h4 title.
Is it possible to add a class to the filter li, such as “empty” so I can target with CSS? Because at the moment there are titles appearing with no filter options below as they’re not applicable.
Kind regards
LiamAnonymous(Private) August 11, 2017 at 5:05 pm #125661I’ve just achieved what I want using JS. For anybody else that might want it:
$('#product_list .product_filters form ul li ul').each(function() { if(!$(this).has('li').length) { $(this).parent().addClass('empty'); } });The li of each filter, checks whether it has any li’s within it’s child li and if not (shows it’s empty) adds a class of “empty” to the filter li, which you can then target with CSS to display:none;
-
AuthorPosts