From 654f405571e63bc27bb4e7f5a8107e6467268882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alba=20Rinc=C3=B3n?= Date: Wed, 2 Aug 2023 08:49:58 +0200 Subject: [PATCH] Show only products with rating (#10434) --- src/BlockTypes/ProductTopRated.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/BlockTypes/ProductTopRated.php b/src/BlockTypes/ProductTopRated.php index db3cfbc7b39..88503d0a49a 100644 --- a/src/BlockTypes/ProductTopRated.php +++ b/src/BlockTypes/ProductTopRated.php @@ -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' => '>', + ); } }