2

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.

rating system

2
  • this is the standard Woocommerce rating ? or something else ? Nov 20, 2017 at 18:31
  • I'm using standard woocommerce rating, however the image is from a plugin.
    – ed_mdk
    Nov 20, 2017 at 19:03

1 Answer 1

3

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

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.