How To Add Woocommerce Reviews On Listing Page
Using the below bunch of code you will be able to add woocommerce reviews for every single product. The reviews will appear on category page, shop page and on all places where you have products listed using woocommerce query. Adding the reviews on the listing page will increase the customer confidence in order to buy from your website, because social proof is very important nowadays. Just copy paste the code in your functions.php and the new structure should appear on your website. You can make the stars as you want to meet your needs, at first look it will have the default woocommerce style.
Add Woocommerce Reviews On Listing Page
Open your functions.php file and add the following code:
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; }
Now refresh the category page or shop page and check if the stars are there. You can change the html structure and any labels you want. Let me know if you need any help in comments section.