Do you know what’s really misleading? When you are comparing two products on the archive page and you’re weighing up the reviews. You notice Product A is rated 5 stars and Product B is only rated 4 stars…the decision is easy right? Well, what if Product A only had 2 reviews and Product B had 100 reviews? The review rating count is likely to sway the customer’s decision. This snippet will out the number of reviews a product has on the product archive loop items.
/**
* Snippet Name: WooCommerce Show Review Rating Count On Product Archive
* Snippet Author: ecommercehints.com
*/
add_filter( 'woocommerce_product_get_rating_html', 'ecommercehints_show_rating_count_on_product_archive', 20, 3 );
function ecommercehints_show_rating_count_on_product_archive( $html, $rating, $count ) {
global $product;
$rating_count = $product->get_rating_count();
if (is_product_category() || is_shop()) {
if ($rating_count == 1) {
$html .= "(" . $product->get_rating_count() . " Review)";
} else {
$html .= "(" . $product->get_rating_count() . " Reviews)";
}
}
return $html;
}