WooCommerce Get Store Rating

Today, we will be talking about how to get store ratings by products in WooCommerce or wordpress. This tutorial will guide you to get your store rating based on the product rating. Once you get the ratings on your products in store, the total average rating of these products achieved will be the average rating of your store.

Below is an example:

$products = wc_get_products( array( 'status' => 'publish', 'limit' => -1 ) );

if($products){

          foreach($products as $product){

            if($product->get_review_count())

          $total = $total+ $product->get_review_count();

          $j = $j+1;

          $totalRating = $totalRating + $product->get_average_rating();

            }
}
echo 'Average Rating: '.round($totalRating/$j,1);
echo 'Total Review: '.$total;

Here is an available free extension WooCommerce Store Rating extension.

Qaisar Satti

Hi, I'm Qaisar Satti! I've been a developer for over 20 years, and now I love sharing what I've learned through tutorials and guides. Whether you're working with Magento, PrestaShop, or WooCommerce, my goal is to make your development journey a bit easier and more fun. When I'm not coding or writing, you can find me exploring new tech trends and hanging out with the amazing developer community. Thanks for stopping by, and happy coding!