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

Multiple 'or' with 'and' conditions

The support doesn work on Saturdays and Sundays, so some Friday requests can be answered on Monday. If you have problems with registration ask help on contact us page please
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 [noreply@pluginus.net] 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.

Hi there.

We have this plugin and we got a request from client to change the filter conditions. How we can set 2 attributes in a group with a 'or' condition? For example, (HLA-A-Primary 1 'or' HLA-A-Primary 2) 'and' (HLA-A-Secondary 1 'or' HLA-A-Secondary 2). Is it possible with below code, which seems to be not working as expected? Basically, we need to group 2 attributes with or condition with another group with a 'and' condition. Please advice

add_filter('woof_main_query_tax_relations', 'my_woof_main_query_tax_relations');

function my_woof_main_query_tax_relations()
{
return array(
'pa_hla-a-p-1' => 'OR',
'pa_hla-a-p-2' => 'AND',
'pa_hla-a-s-1' => 'OR',
'pa_hla-a-s-2' => 'AND'
);
}

With regards,

Ravi Kumar

Hello Ravi Kumar

The logic of comparison between different attributes is AND.  Unfortunately, this plugin cannot change this behavior.

You need customization of the code. You can change the comparison logic in a search query using standard hooks  OR - https://products-filter.com/hook/woof_get_tax_query/

Thanks for the reply.

However, if I use the below code, I see no changes. In this case, the filter should look into the value in all 4 attributes right?

add_filter('woof_main_query_tax_relations', 'my_woof_main_query_tax_relations');

function my_woof_main_query_tax_relations()
{
    return array(
    'pa_hla-a-p-1' => 'OR',
    'pa_hla-a-p-2' => 'OR',
    'pa_hla-a-s-1' => 'OR',
    'pa_hla-a-s-2' => 'OR'
    );
}

Thanks!

Ravi

Thanks for the reply.

However, if I use the below code, I see no changes. In this case, the filter should look into the value in all 4 attributes right?

add_filter('woof_main_query_tax_relations', 'my_woof_main_query_tax_relations');

function my_woof_main_query_tax_relations()
{
    return array(
    'pa_hla-a-p-1' => 'OR',
    'pa_hla-a-p-2' => 'OR',
    'pa_hla-a-s-1' => 'OR',
    'pa_hla-a-s-2' => 'OR'
    );
}

#Even I tried with the below code which also not working as explained above:

add_filter('woof_get_tax_query', 'my_woof_get_tax_query');

function my_woof_get_tax_query($tax_args){

    //do smth here

    $tax_args =  array(

        'pa_hla-a-p-1' => 'OR',

        'pa_hla-a-p-2' => 'OR',

        'pa_hla-a-s-1' => 'OR',

        'pa_hla-a-s-2' => 'OR'

        );

    return $tax_args;

}

Thanks!

Ravi

Hello Ravi

Yes, your code does not make sense.

You change the logic inside the attribute. But for attributes, the default logic is OR

So  you change  OR  to  OR