Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Reviews: fix reviews without rating not appearing when sorting by rat…
Browse files Browse the repository at this point in the history
…ing (#863)
  • Loading branch information
Aljullu authored Aug 15, 2019
1 parent cdb9d26 commit 7f6de2d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/RestApi/Controllers/ProductReviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,17 @@ public function get_items( $request ) {

if ( isset( $registered['orderby'] ) ) {
if ( 'rating' === $request['orderby'] ) {
$prepared_args['meta_key'] = 'rating'; // phpcs:ignore
$prepared_args['meta_query'] = array( // phpcs:ignore
'relation' => 'OR',
array(
'key' => 'rating',
'compare' => 'EXISTS',
),
array(
'key' => 'rating',
'compare' => 'NOT EXISTS',
),
);
}
$prepared_args['orderby'] = $this->normalize_query_param( $request['orderby'] );
}
Expand Down

0 comments on commit 7f6de2d

Please sign in to comment.