Skip to content

Commit

Permalink
disable ratings option. Closes woocommerce#1503.
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Sep 21, 2012
1 parent 5fcfe94 commit e61c152
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 36 deletions.
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Localization - Romanian update by silviu-bucsa.
* Localization - Dutch updates by Ramoonus.
* Localization - Localized shortcode button.
* Many other minor fixes and tweaks!

= 1.6.5.2 - 12/09/2012 =
* Tweak - Extra validation for PayPal IPN.
Expand Down
74 changes: 41 additions & 33 deletions templates/single-product-reviews.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,41 +11,49 @@
<?php if ( comments_open() ) : ?><div id="reviews"><?php

echo '<div id="comments">';

if ( get_option('woocommerce_enable_review_rating') == 'yes' ) {

$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 itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';

echo '<div 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> '.__('out of 5', 'woocommerce').'</span></div>';

echo '<h2>'.sprintf( _n('%s review for %s', '%s reviews for %s', $count, 'woocommerce'), '<span itemprop="ratingCount" class="count">'.$count.'</span>', wptexturize($post->post_title) ).'</h2>';

echo '</div>';

else :

$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 itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">';

echo '<div 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> '.__('out of 5', 'woocommerce').'</span></div>';

echo '<h2>'.sprintf( _n('%s review for %s', '%s reviews for %s', $count, 'woocommerce'), '<span itemprop="ratingCount" class="count">'.$count.'</span>', wptexturize($post->post_title) ).'</h2>';

echo '</div>';

} else {

echo '<h2>'.__('Reviews', 'woocommerce').'</h2>';

}

} else {

echo '<h2>'.__('Reviews', 'woocommerce').'</h2>';

endif;
}

$title_reply = '';

Expand Down
10 changes: 7 additions & 3 deletions templates/single-product/review.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,14 @@
<?php echo get_avatar( $GLOBALS['comment'], $size='60' ); ?>

<div class="comment-text">

<?php if ( get_option('woocommerce_enable_review_rating') == 'yes' ) : ?>

<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo esc_attr( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?>">
<span style="width:<?php echo get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true )*16; ?>px"><span itemprop="ratingValue"><?php echo get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ); ?></span> <?php _e('out of 5', 'woocommerce'); ?></span>
</div>
<div itemprop="reviewRating" itemscope itemtype="http://schema.org/Rating" class="star-rating" title="<?php echo esc_attr( get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ) ); ?>">
<span style="width:<?php echo get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true )*16; ?>px"><span itemprop="ratingValue"><?php echo get_comment_meta( $GLOBALS['comment']->comment_ID, 'rating', true ); ?></span> <?php _e('out of 5', 'woocommerce'); ?></span>
</div>

<?php endif; ?>

<?php if ($GLOBALS['comment']->comment_approved == '0') : ?>
<p class="meta"><em><?php _e('Your comment is awaiting approval', 'woocommerce'); ?></em></p>
Expand Down

0 comments on commit e61c152

Please sign in to comment.