Tagged: x
-
AuthorPosts
-
March 27, 2016 at 8:38 am #854165
Hi Guys
Absolutely Love X Theme!
Just one issue I can’t seem to work out and that is how to add woocommerce stars under the product title on a single page.
If I activate another theme they are showing but not on X Theme, I have looked at previous forum posts but none seem to help.
March 27, 2016 at 9:04 am #854172Hi There,
Please add the following code under functions.php file under child theme:
add_action( 'woocommerce_single_product_summary', 'x_print_rating', 6 ); function x_print_rating(){ global $woocommerce, $product; $average = $product->get_average_rating(); echo '<div class="star-rating x-star-rating"><span style="width:'.( ( $average / 5 ) * 100 ) . '%"><strong itemprop="ratingValue" class="rating">'.$average.'</strong> '.__( 'out of 5', '__x__' ).'</span></div>'; }
Hope it helps 🙂
March 27, 2016 at 10:50 am #854227Fantastic that worked perfectly!
How would I add the the link next to the stars saying how many customers reviewed?
March 27, 2016 at 11:36 am #854260Hi There,
Please update the previous code a bit:
add_action( 'woocommerce_single_product_summary', 'x_print_rating', 6 ); function x_print_rating(){ global $woocommerce, $product; $average = $product->get_average_rating(); $count = $product->get_review_count() ? $product->get_review_count() : 0; echo '<div style="display: inline-block;" class="star-rating x-star-rating"><span style="width:'.( ( $average / 5 ) * 100 ) . '%"><strong itemprop="ratingValue" class="rating">'.$average.'</strong> '.__( 'out of 5', 'woocommerce' ).'</span></div>'; echo '<div style="display: inline-block;" class="x-review-count">'. $count . __(' Reviews', '__x__') .'</div>'; }
Hope it helps 🙂
March 27, 2016 at 12:21 pm #854306Few Tweaks but again perfect… exactly what I needed!
Thank you very much for that!
March 27, 2016 at 12:34 pm #854316You’re very welcome 🙂
If you need anything else, please let us know.
-
AuthorPosts