[2.5] If an attribute meta key is not set, technically its 'any', so should match. Prevents issues when meta data is missing after renaming attributes

@claudiosmweb please test :)

#10272
This commit is contained in:
Mike Jolley 2016-02-04 18:25:06 +00:00
parent 628d791343
commit a78edb2af2
1 changed files with 11 additions and 3 deletions

View File

@ -510,10 +510,18 @@ class WC_Product_Variable extends WC_Product {
$value = wc_clean( $match_attributes[ $attribute_field_name ] );
$query_args['meta_query'][] = array(
'key' => $attribute_field_name,
'value' => array( '', $value ),
'compare' => 'IN'
'relation' => 'OR',
array(
'key' => $attribute_field_name,
'value' => array( '', $value ),
'compare' => 'IN'
),
array(
'key' => $attribute_field_name,
'compare' => 'NOT EXISTS'
)
);
}
$matches = get_posts( $query_args );