Viewing 5 posts - 1 through 5 (of 5 total)
-
AuthorPosts
-
March 7, 2015 at 3:52 pm #407502
ElmiGone™ (120 Kapseln) https://www.santegra-international.com/produkt/elmigone-120/
was rated once with 5 stars
howto show the stars in categorie view?
https://www.santegra-international.com/shop/?product_cat=antiparasitaere-pflanzen&orderby=rating&post_type=product
product on the left bottom.March 9, 2015 at 5:29 pm #408279Hey Tobias-B-Conrad!
I tried this code out and it’s working fine on my XAMPP setup, http://stackoverflow.com/questions/14227121/how-do-you-add-the-star-ratings-for-products-in-woocommerce.
Best regards,
ElliottMarch 9, 2015 at 6:33 pm #408332which line of code do you like me to insert?
which one did you test?add_action('woocommerce_after_shop_loop_item', 'my_print_stars' ); function my_print_stars(){ global $wpdb; global $post; $count = $wpdb->get_var(" SELECT COUNT(meta_value) FROM $wpdb->commentmeta LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID WHERE meta_key = 'rating' AND comment_post_ID = $post->ID AND comment_approved = '1' AND meta_value > 0 "); $rating = $wpdb->get_var(" SELECT SUM(meta_value) FROM $wpdb->commentmeta LEFT JOIN $wpdb->comments ON $wpdb->commentmeta.comment_id = $wpdb->comments.comment_ID WHERE meta_key = 'rating' AND comment_post_ID = $post->ID AND comment_approved = '1' "); if ( $count > 0 ) { $average = number_format($rating / $count, 2); echo '<div class="starwrapper" itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">'; echo '<span class="star-rating" title="'.sprintf(__('Rated %s out of 5', 'woocommerce'), $average).'"><span style="width:'.($average*16).'px"><span itemprop="ratingValue" class="rating">'.$average.'</span> </span></span>'; echo '</div>'; } }
March 9, 2015 at 10:37 pm #408518ok only working when more than 1 review is rated with stars.
thanks for your helpMarch 10, 2015 at 6:51 am #408647 -
AuthorPosts
Viewing 5 posts - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.