Also, I updated the code by swapping the title to show “Not Rated Yet” when a Review hasn’t been left yet on a Product. Again I would like to move this to my child theme functions.php but thats where I get lost a bit.
/**
* Returns the product rating in html format.
*
* @param string $rating (default: '')
*
* @return string
*/
public function get_rating_html( $rating = null ) {
$rating_html = '';
if ( ! is_numeric( $rating ) ) {
$rating = $this->get_average_rating();
}
if ( $rating > 0 ) {
$title = sprintf( __( 'Rated %s out of 5', 'woocommerce' ), $rating );
} else {
$title = 'Not yet rated';
}
if ( $rating > -1 ) {
$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 apply_filters( 'woocommerce_product_get_rating_html', $rating_html, $rating );
}
Thanks