Woocommerce always show stars – even with no reviews
-
Goal: All products should display rating stars even when there are no reviews yet.
Found this snippet and it works great in my shop loop, plugins, and customized themes.
Problem is, it does not work on single product pages – tried with Storefront, Beaver Builder Child Theme, and a few other themes.
Any help would be greatly appreciated ??
// Woocommerce rating stars always add_filter('woocommerce_product_get_rating_html', 'your_get_rating_html', 10, 2); function your_get_rating_html($rating_html, $rating) { if ( $rating > 0 ) { $title = sprintf( __( 'Rated %s out of 5', 'woocommerce' ), $rating ); } else { $title = 'Not yet rated'; $rating = 0; } $rating_html = '<div class="star-rating" title="' . $title . '">'; $rating_html .= '<span style="width:' . ( ( $rating / 5 ) * 100 ) . '%"><strong class="rating">' . $rating . '</strong> ' . __( 'out of 5', 'woocommerce' ) . '</span>'; $rating_html .= '</div>'; return $rating_html; }
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Woocommerce always show stars – even with no reviews’ is closed to new replies.