WooCommerce - excelling eCommerce
How to make Product Categories widget expandable/collapsable (3 posts)

  1. Corey
    Posted 2 years ago #

    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!



  2. jameskoster
    Plugin Author

    Posted 2 years ago #


    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();
  3. John Alexander
    Posted 1 year ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WooCommerce - excelling eCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.