Hi,
I am using “summar on hover” product layout for my shop pages.
I am satisfied with it, but I want the rating to be shown by default, without hover. I’ve been able to achieve that with a zero rating through an additional code, however, it doesn’t work for rated products.
Code is:
// 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 = ‘No rating’;
$rating = 0;
}
$rating_html = ‘<div class=”star-rating” title=”‘ . $title . ‘”>’;
$rating_html .= ‘<span style=”width:’ . ( ( $rating / 5 ) * 100 ) . ‘%”><strong class=”rating”>’ . $rating . ‘ ‘ . __( ‘out of 5’, ‘woocommerce’ ) . ‘</span>’;
$rating_html .= ‘</div>’;
return $rating_html;
}