Q:

How to get total count for each star rating?

I'm using Woocommerce and I'm trying to get the total for each star rating using the post id (just like in the image below). Each rating is stored on my database as a number from 1 - 5 I just don't know how to go about retrieving the total count for each rating.
Any help will be greatly appreciated.

A:

You can use the function get_rating_count() by specifying on each call the value needed. For example :
global $product;

$rating_1 = $product->get_rating_count(1);
$rating_2 = $product->get_rating_count(2);
$rating_3 = $product->get_rating_count(3);
$rating_4 = $product->get_rating_count(4);
$rating_5 = $product->get_rating_count(5);

You can read more about the function

