WooCommerce – Hide third level categories

This topic has 5 replies, 2 voices, and was last updated 8 years, 10 months ago ago by Eva Kemp

  • Avatar: digitalhoopoe
    digitalhoopoe
    Participant
    May 25, 2015 at 09:18

    Hello,

    I currently work on website with many sub-categories (third level) in woocommerce.

    For example, when I load the “bois” category page, all the categories and sub-categories of “bois” are display.

    How could I hide the third level sub-categories ? (for example fagott and fagottino in bois > bassons)

    Thank you !

    Please, contact administrator
    for this information.
    4 Answers
    Avatar: Eva
    Eva Kemp
    Support staff
    May 25, 2015 at 09:59

    Hello,

    You can close the first category by editing wp-content/themes/royal/js/etheme.js file. Find and comment out line 1652
    $this.find('>li').first().find('.open-this').html(minusIcon).parent().addClass('opened').find('ul.children').show();

    Thank you,
    Regards,
    Eva Kemp.

    Avatar: digitalhoopoe
    digitalhoopoe
    Participant
    May 25, 2015 at 10:18

    Thank you for your answer,

    But it won’t work for me, here’s what the accordion categories code currently look like when the line is comment out :


    // **********************************************************************//
    // ! Categories Accordion
    // **********************************************************************//

    jQuery.fn.etAccordionMenu = function ( options ) {
    //var settings = $.extend({
    // type: "default"
    //}, options );

    var $this = jQuery(this);

    var plusIcon = '+';
    var minusIcon = '–';

    var etCats = $('.product-categories');
    $this.addClass('with-accordion')
    var openerHTML = '<div class="open-this">'+plusIcon+'</div>';

    $this.find('li').has('.children, .nav-sublist-dropdown').has('li').addClass('parent-level0').prepend(openerHTML);

    if($this.find('.current-cat.parent-level0, .current-cat, .current-cat-parent').length > 0) {
    $this.find('.current-cat.parent-level0, .current-cat-parent').find('.open-this').html(minusIcon).parent().addClass('opened').find('ul.children').show();
    } else {
    //$this.find('>li').first().find('.open-this').html(minusIcon).parent().addClass('opened').find('ul.children').show();
    }

    $this.find('.open-this').click(function() {
    if($(this).parent().hasClass('opened')) {
    $(this).html(plusIcon).parent().removeClass('opened').find('> ul, > div.nav-sublist-dropdown').slideUp(200);
    }else {
    $(this).html(minusIcon).parent().addClass('opened').find('> ul, > div.nav-sublist-dropdown').slideDown(200);
    }
    });

    return this;
    }

    if(catsAccordion) {
    $('.product-categories').etAccordionMenu();
    }

    Hope you can help me,

    Thank you

    Please, contact administrator
    for this information.
    Avatar: digitalhoopoe
    digitalhoopoe
    Participant
    May 25, 2015 at 10:42

    I comment ou all those lines :

    if($this.find('.current-cat.parent-level0, .current-cat, .current-cat-parent').length > 0) {
    $this.find('.current-cat.parent-level0, .current-cat-parent').find('.open-this').html(minusIcon).parent().addClass('opened').find('ul.children').show();
    } else {
    //$this.find('>li').first().find('.open-this').html(minusIcon).parent().addClass('opened').find('ul.children').show();
    }

    It only show first level category, is there a way to show the second level category and not the third ?

    Thank you !

    Avatar: Eva
    Eva Kemp
    Support staff
    May 25, 2015 at 12:11

    Hello,

    Unfortunately there is no such possibility. Sorry.

    Regards,
    Eva Kemp.

  • Viewing 5 results - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.Log in/Sign up

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.