Merge pull request #18173 from woocommerce/fix/18168

Add ID orderby fallback for when prices are the same across multiple products.
This commit is contained in:
Claudiu Lodromanean 2017-12-14 09:16:37 -08:00 committed by GitHub
commit 204a990976
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -518,7 +518,7 @@ class WC_Query {
} else {
$args['join'] .= " INNER JOIN ( SELECT post_id, min( meta_value+0 ) price FROM $wpdb->postmeta WHERE meta_key='_price' GROUP BY post_id ) as price_query ON $wpdb->posts.ID = price_query.post_id ";
}
$args['orderby'] = ' price_query.price ASC ';
$args['orderby'] = " price_query.price ASC, $wpdb->posts.ID ASC ";
return $args;
}
@ -548,7 +548,7 @@ class WC_Query {
$args['join'] .= " INNER JOIN ( SELECT post_id, max( meta_value+0 ) price FROM $wpdb->postmeta WHERE meta_key='_price' GROUP BY post_id ) as price_query ON $wpdb->posts.ID = price_query.post_id ";
}
$args['orderby'] = ' price_query.price DESC ';
$args['orderby'] = " price_query.price DESC, $wpdb->posts.ID DESC ";
return $args;
}