This commit is contained in:
Alba Rincón 2023-08-02 08:49:58 +02:00 committed by GitHub
parent 62268b7017
commit 76e68dddfd
1 changed files with 7 additions and 1 deletions

View File

@ -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' => '>',
);
}
}