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

Commit

Permalink
Show only products with rating (#10434)
Browse files Browse the repository at this point in the history
  • Loading branch information
albarin authored Aug 2, 2023
1 parent 7498229 commit 654f405
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/BlockTypes/ProductTopRated.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,17 @@ class ProductTopRated extends AbstractProductGrid {
protected $block_name = 'product-top-rated';

/**
* Force orderby to rating.
* Show only products with ratings and order by rating.
*
* @param array $query_args Query args.
*/
protected function set_block_query_args( &$query_args ) {
$query_args['orderby'] = 'rating';

$this->meta_query[] = array(
'key' => '_wc_average_rating',
'value' => 0,
'compare' => '>',
);
}
}

0 comments on commit 654f405

Please sign in to comment.