Support » Plugins and Hacks » How to make Product Categories widget expandable/collapsable

How to make Product Categories widget expandable/collapsable

  • I know this is quite simple and have done it easily in places where I am controlling the structure of the lists but unsure how to do it in this instance.

    The list seems to be being created in the class-product-cat-dropdown-walker.php file but I am not comfortable enough with PHP to go to deep into this code.

    One error I haven’t been able to work around is to have a +/- symbol next to the links to have the links to that category parent still work and not interfere with opening and closing its children.

    Any word on how to fix this or if it can be added in an update. I can imagine this being something very useful and at high demand for those who will have a great deal of categories as I am soon to have.

    Here is the page where it’s visible on the test site:

    I will greatly appreciate any and all help!



Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author James Koster



    We won’t be adding this to WooCommerce. But you should be able to do it easily enough yourself with some jQuery.

    I would just add your +/- as a background the the h4 in the widget (or use an icon font) then use that h4 as the trigger to toggle the categories.

    Something like;

    jQuery( '.widget_product_categories > h4' ).click(function() {
      jQuery( '. widget_product_categories .product-categories' ).slideToggle();

    Bolivares, I’ve been searching for something like this as well, and I was a little surprised WC wouldn’t add this on their own.

    Like you, I wanted to display, on my sidebar widget, the categories and subcategories in an accordion (collapsable/expandable) fashion.

    So after some digging, I found a way. Here’s what you can do.

    Get jQuery Accordion Menu;
    Create a menu with all Woocommerce categories and sub categories;
    Go to Widgets, drag the jQuery Accordion Meny into a sidebar;
    Choose the menu you created earlier

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to make Product Categories widget expandable/collapsable’ is closed to new replies.