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:
commit
204a990976
|
@ -518,7 +518,7 @@ class WC_Query {
|
||||||
} else {
|
} 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['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;
|
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['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;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue