Forums Forums Search & Filter Pro Hide UI Taxonomies that are empty

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #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
    Liam

    Trevor
    #125514

    At this time, that is not possible from within the plugin. I do not know whether this would be possible with javascript.

    Anonymous
    #125661

    I’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;

    Trevor
    #125675

    Cool. I have edited the post top that in a code block, and then closed the thread for now. Thanks for sharing.

Viewing 4 posts - 1 through 4 (of 4 total)