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 pleaseIf 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.
Quote from Ravi on November 26, 2019, 09:58Hi 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
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
Quote from Pablo Borysenco on November 26, 2019, 12:20Hello 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/
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/
Quote from Ravi on November 27, 2019, 14:34Thanks 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'
);
}Thanks!
Quote from Ravi on November 27, 2019, 15:12Thanks 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
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!
Quote from Pablo Borysenco on November 28, 2019, 12:19Hello 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
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