PluginUs.Net - Business Tools for WooCommerce and WordPress

[realize your idea - make your dreams come true]

Support Forum

You need to log-in to create request (topic) to the support

Filter by variants using AND condition

This support system is for all types of the plugins as for premium versions, so for free ones! If you have premium version do not forget in the private data of the request (!!not in the text of the support request!!) after its publishing insert purchase code please (see blue-green button on the right side) and press Save button.
If you not got email within 24~36 business hours, firstly check your spam box, and if no any email from the support there - back to the forum and read answer here. DO NOT ANSWER ON EMAILS [] FROM THE FORUM!! Emails are just for your info, all answers should be published only here.
The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday.

We have a use case where we'd like the filtering to provide variant level filtering using the AND condition. Right now, when we select multiple attribute filters, it seems like some filters are still available for selection when they should not be. Here's a screenshot to demonstrate the issue:


Filter does not work with variants.  Your shop displays parent products and the database query is only for parent products

And if this parent product has these attributes, the filter will display it

I may have found a solution by modifying the counts query. The issue is that I really need the current term fed into woof_dynamic_count_attr. Would it be possible to have line 1694 of wp-content/plugins/woocommerce-products-filter/index.php from:

$args = apply_filters('woof_dynamic_count_attr', $args, $custom_type);


$args = apply_filters('woof_dynamic_count_attr', $args, $custom_type, $curr_term);


Did I understand you correctly about variable products? The parent product has all of these taxonomies

I need to know the feasibility of this code change. Then I will pass this on to the developers.

We actually are using the plugin to filter by variable product attributes. It seems to be working fine for that. For example, from my screenshot above, Program, Course Dates, and Season are all attributes assigned to the variable product, and it appears to be filtering the correct products which contain those attributes and values. It's fine that only the parent product shows in the results.


I consulted with the developer

Unfortunately, we will not implement this code change.

This code change only works for the taxonomy filter and does not take into account other filters. And it is a private customization for one user.

sorry and thanks for your understanding

Thanks for looking into this. The change actually gives us context though for which taxonomy is currently being counted which allows us to accomplish our goal. I think this would be valuable for anyone trying to hook into the woof_dynamic_count_attr filter. From what I can see currently, there's no way for a developer to know which term is currently being counted when hooking into woof_dynamic_count_attr.


I understand you, but I have already described it above -

It is possible to change this parameter to

apply_filters('woof_dynamic_count_attr', $args, $custom_type, array('tax'=>$curr_term, 'meta'=>$meta_term));

Hi Pablo,

I understand what you are saying now. Your proposed fix would also work just fine for our needs. Anything that would five us context for the current term being counted.


As a side note though, aren't all the other filters already available in the $args variable? That is what we are using to loop through all the other filters. The only context that seems to be missing is the term you are currently doing a count for.


aren't all the other filters already available in the $args variable?  - As well as the current term;)

Your proposed fix would also work just fine for our needs. - Unfortunately this will not be included in this new version of the plugin, because this version is already in final testing.

The current term is in the $args array, but it doesn't seem to distinguish which one is the current term. It's just lumped into the other taxonomies so it's hard to determine which one is the current term:


That's what I wanted to tell you.