Adjust OR logic

#10568
This commit is contained in:
Mike Jolley 2016-03-17 17:54:09 +00:00
parent 77d9ced394
commit c25ef5e55a
1 changed files with 4 additions and 5 deletions

View File

@ -1624,14 +1624,13 @@ class WC_Product {
if ( $relate_by_category ) {
$query['where'] .= " ( tt.taxonomy = 'product_cat' AND t.term_id IN ( " . implode( ',', $cats_array ) . " ) ) ";
$andor = 'OR';
} else {
$andor = 'AND';
if ( $relate_by_tag ) {
$query['where'] .= ' OR ';
}
}
if ( $relate_by_tag ) {
$query['where'] .= " {$andor} ( tt.taxonomy = 'product_tag' AND t.term_id IN ( " . implode( ',', $tags_array ) . " ) ) ";
$query['where'] .= " ( tt.taxonomy = 'product_tag' AND t.term_id IN ( " . implode( ',', $tags_array ) . " ) ) ";
}
$query['where'] .= ')';