Skip Navigation

[Resolved] How to show product rating as numbers?

This support ticket is created 5 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+01:00)

This topic contains 2 replies, has 2 voices.

Last updated by Himanshu Agarwal 5 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#1197175

I am showing product rating in product listing page.

Product rating is appearing as Stars, but i want to show rating as number like this-

4.6 (105) -> rating (no. of comments)

Please help me to achieve this.

#1197273

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

The wpv-woo-single-products-rating shortcode which reproduces the standard WC rating UI in custom templates you create with Toolset is built on the standard WC functions.

You can see how the current star rating plus comment count is generated by checking this PHP template which generates it:

/wp-content/plugins/woocommerce/templates/single-product/rating.php

Note that you can get the comment count and average rating like so:

global $product;
$review_count = $product->get_review_count();
$average      = $product->get_average_rating();

So you could create a custom shortcode that uses this and then returns the markup you want with the values from $average and $review_count, and then insert the shortcode into your single product template where you want it.

#1199099

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.