Show Ratings even if Product Hadn't Been Reviewed Yet
-
Hello –
I want to be able to show the Product Ratings in column view even if a Product hadn’t been reviewed yet. Currently I am able to do this by changing the default to “-1” in the abstract-wc-product.php file but I want to move this to my child themes functions.php file to keep it from getting overwritten every time WC updates.
Here is the code:
/** * 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 > -1 ) { $rating_html = '<div class="star-rating" title="' . sprintf( __( 'Rated %s out of 5', 'woocommerce' ), $rating ) . '">'; $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 ); }
Any suggestions or advice would be much appreciated. Thanks.
Viewing 11 replies - 1 through 11 (of 11 total)
Viewing 11 replies - 1 through 11 (of 11 total)
- The topic ‘Show Ratings even if Product Hadn't Been Reviewed Yet’ is closed to new replies.