Widget - show all product categories via product types (2 posts)

  1. mumf83
    Posted 2 years ago #

    I'm currently developing a widget that will display all the product categories from a list of product types.

    I have a menu which displays all the product types. Lets say a user selects 'Amplifiers' which will add 'product-type/amplifiers' to the URL. This will display all the products that have a product type of amplifiers. Each product has a Product Category which could either be Sony, JVC, Yamaha, etc. What I'd like the widget to show is all the product categories that are currently showing under the 'Amplifiers' product type. So this could be 'Sony' and 'JVC'. When clicking on one of these it will filter the products list even further to only show 'Sony' for example.

    I've noticed wp_list_categories and get_terms functions but I'm just not really sure how to implement the above. Any help / pointers would be much appreciated.

  2. bcworkz
    Posted 2 years ago #

    I would look into hierarchical Taxonomies. It's fairly simple to populate a form element with all child terms of any particular term at any particular level. It's also fairly simple to stack each level's selection into a query that will return all products that fit the selected terms.

    If implemented well, the functions involved will be recursive so one function will work for all terms and levels of the taxonomy, similar to how the Walker class operates. You might even find a way to use the Walker class.

Topic Closed

This topic has been closed to new replies.

About this Topic