1

I want to show the number of reviews and average star ratings of a product in Shop/ Product Archive pages. Currently this is shown in single product pages. But I want it in all-products page. How can I achieve that? Please help. Thank you very much.

1 Answer 1

11

You can put this into your theme functions.php file:

To show the average star ratings of a product in Shop/ Product Archive pages -

add_action('woocommerce_after_shop_loop_item', 'add_star_rating' );
function add_star_rating()
{
global $woocommerce, $product;
$average = $product->get_average_rating();

echo '<div class="star-rating"><span style="width:'.( ( $average / 5 ) * 100 ) . '%"><strong itemprop="ratingValue" class="rating">'.$average.'</strong> '.__( 'out of 5', 'woocommerce' ).'</span></div>';
}
2
  • thanks Swapnali, i tried in child theme, but nothing worked. I tried already this method. It not worked at all any shop loop page. Aug 25, 2016 at 15:04
  • 1
    Thanks, now it showing. I thought earlier history or cache issue. Thanks Aug 26, 2016 at 16:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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