Get WooCommerce customer reviews from all products, display average and all ratings in a histogram without a plugin

I have just completed developing a new customer review feature for Uniqcube light cubes. The idea was to display customer reviews from all products under each product since all products are basically the same product just with a unique design.

I thought that developing this is going to be a walk in the park and I will be done in no time, but as it turned out, WooCommerce does not allow you to do this that easily and you will have to come up with a custom solution.

In this post I would like to share my experience and show you how it can be done without using any plugins.

Why customer reviews matter?

Before we get to the development, let’s dive a little bit into the reviews themselves. User generated content is a force that should not be underestimated. As a study by Brightlocal has shown – 93% of consumers, prior to making a decision of purchase, read online reviews to find out if the product, business is good or bad.

Displaying other customer reviews will not only increase your sales, but also get you higher SEO rankings.

Google uses reviews as one of the components to determine if the website is real or fake therefore if you have this beautiful user generated content under your belt, search engines will reward you with extra traffic over those who do not have them – how cool is that!

Why would anyone want to display all product reviews under a single product?

If you have a store that sells a variety of different products that are hardly related to one another then displaying all product reviews under each product might be confusing. But if you have a series of products that are basically the same with some slight design or material variations then displaying all reviews on one page could be quite useful.

Also you might like to display information about all reviews on your homepage where your visitors will see average rating of all products thus informing them about the overall quality of the store or products it sells.

How to get customer reviews from all products and display them? Update: Pagination included

I will repeat myself, but WooCommerce is the best and most popular e-commerce solution. It is an amazing product for starting your online business. All the functions, hooks and filters it provides to customize your shop is spectacular, but there are some things that you will have to create yourself. So let’s get our hands dirty and dive into the development. Here is an example where I have used these functions to output all reviews.

Update: According to numerous requests I have received after posting this article, I have included review pagination option. It should reduce stress on your servers and decrease page load times. Make sure to change the amount of reviews per page you want to showcase.

Go ahead and open up your functions.php (located in your current themes folder) and add this function to it.

Now we have a function that allows us to display all product reviews on any page of our theme. You can copy this function and paste it in your single product page for example.

If you are going to replace the default WooCommerce customer review output, you also might want to disable review product tab by adding this peace of code to functions.php file.

How to get all approved review count from across all products?

After displaying all reviews on a single page, I had to output a number of total reviews I have on my shop. Here is a quick function that will allow you to get this number. Add this to your functions.php file.

Now ad this peace of code to the template where you would like to display it.

How to get and display average customer rating of all products?

After that I wanted to display average rating and rating in the form of stars. For this we are going to use multiple functions that have to be added to your functions.php file.

After that add this line where you would like to output the average rating of all products with stars.

How to display all ratings in a histogram in WooCommerce without a plugin?

And the last thing that was missing for me was a histogram of total customer reviews as one that can be seen on Amazon. This is the function that should go into your functions.php file.

And now you can add this function where you would like to showcase the histogram of all customer reviews.

Adding a pinch of CSS

You have now the ability to output all reviews, average review and customer review histogram but in order to make it all look right you will need some bits of CSS code as well. Add these next lines of CSS to your themes style.css file.

The CSS is going to require some additional work on your part to make it aligned with your theme but this will get you going.


Today I have showed you how to get all customer reviews on a single product page. Hopefully it does save you some time and help you get those review improvements ready much faster. Let me know if this helps you or share your code improvements with others below in the comments section.

In categories: Tutorials, Website development, Woocommerce, Wordpress

Nauris Kolāts

Nauris is a freelance designer / developer who loves to dig into the UX as much as in the ground for fishing worms. And fishing is just one amongst the long list of his active lifestyle hobbies.

Other posts

Your thoughts

Join the discussion

  1. Monirul Islam

    Awesome design!

  2. chris

    Hi, this is what i need to achive however it doesnt function with Woocommerce variable subscription products, how can i make it work with these products?

    • Hi Chris,

      Thanks for your comment.
      This tutorial was intended to help others in the same position to display review histogram. To my understanding a variation is basically the same product so it doesn’t really make a lot of sense to display separate reviews for different variations.
      I’m guessing you are still selling one subscription product with some slight variations – to your customers that might look like the same product after all.

  3. asghar


    How can I use slides instead of stars?
    I want to use slide when reviewing reviews

    Thank you so much for your help

    • Hi Asghar, could you please show an example of what you mean when referring to “slides instead of stars”?

  4. tamakichi

    great customize!
    I want to add pagenation of customer reviews from all products. any ideas?

    • Hi Tamakichi, I have updated the tutorial so that now reviews can be also split into pages.

  5. zan

    Hello. Great article. I would just like to ask you how can I display comments from other product in the same category. So If I have 3 product in category shirts the product rewiev for all 3 product would be displayed for all products in the same category.

    Thanks for your help.

    • Hi Zan,

      You will have to add additional args to the WP_Comment_Query function.
      So you would have to call it something like this:

      $args = array(
      'status' => 'approve',
      'type' => 'review',
      'post_id' => 123 //Here you must replace 123 with the product's ID.

      // The Query
      $comments_query = new WP_Comment_Query;
      $comments = $comments_query->query( $args );

      This way you have added a specific post_id value in the WP_Comment_Query making it ask for just one specific product.
      If you would like to include a group of products, you would be replacing “post_id” with “post__in => array( 123, 234, 456 );” where you replace the numbers with your product ID values.
      This WP_Comment_Query function is quite flexible and offers a lot of different options, you can also restrict reviews by review author, you can use database queries and meta queries.

      You can read more about the WP_Comment_Query here:

  6. yomo

    Hi team,

    how to create pagination?

    • Hey Yomo, I have updated the tutorial so that it uses pagination and allows to paginate reviews.

  7. seven

    Hello, how are you? thanks for sharing. I am a newbie for woocommerce, can you tell me how to use PHP code in a page? like

  8. Marcos

    Hi Nauris! You can’t imagine for how long I have looked for this solution! I have similar products and I wanted to display ALL reviews on each single product.

    I only encountered a problem: I cannot seem to display the customer name and comment BUT only my name and my reply.

    Also, after adding the CSS code I can see that stars from 1 to 9 are greyed out and only review number 10 shows 5 stars in black AND also customer comment! Why is this happening?

    Screenshot of problem:

    Thanks a lot! Stay safe.

    • Hey Marcos, glad to hear this :)
      Not really sure why you are not able to display the name and comment besides each review.

      I would suggest you to go one step at a time and try debugging using PHP var_dump() function to see what output you are getting from different variables. Start by trying to see what you are getting with this e.g. var_dump($comment->comment_author)

      And the issue with grayed out stars – most probably it is just a CSS conflict with some other CSS classes. I would suggest you to switch briefly to a default WordPress template and see if that changes anything both in the way stars look and how comment related data is outputted.

      Best wishes and you too stay healthy and safe! <3

  9. Pedro

    Hey Nauris,
    really great article, thank you!
    I want to show the reviews/ratings of all my products in the woocommerce shop on each product single page.
    Do you think, Google will penalty this or lock the rich snippets?
    Background: Since some time Google does no longer show the reviews/rating stars of the shop on the single product pages. Only the reviews/ratings of the single product are shown in Google SERP Rich Snippet.
    Greets – Pedro

    • Hi Pedro, thanks for your question however it’s a tricky one since Google doesn’t really give out a lot about their search algorithms and how they rank the websites. I do not believe they should be penalizing website for outputting all reviews on all single product pages since your reviews might symbolize and sum up the overall experience and quality of service you provide.

  10. Bas

    Hi Nauris, is it possible to use your code in combination with the standard woocommerce reviews tab (the one which is regular used at WooCommerce product pages? So that all products have all reviews under this standard tab and there’s no need to place the reviews at another spot on the product page? Thanks!

    • Hi Bas, I haven’t tested if it is possible to display them instead of default WooCommerce reviews.
      I guess it should be possible with some hooks or filters however it would take a bit of additional custom development :)

Latest work