From e61c152a7c83fa9af7ce11314eb9cacdc9e7e2aa Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Fri, 21 Sep 2012 21:21:50 +0100 Subject: [PATCH] disable ratings option. Closes #1503. --- readme.txt | 1 + templates/single-product-reviews.php | 74 +++++++++++++++------------- templates/single-product/review.php | 10 ++-- 3 files changed, 49 insertions(+), 36 deletions(-) diff --git a/readme.txt b/readme.txt index 5f5c14bac31..3ada0a7f356 100644 --- a/readme.txt +++ b/readme.txt @@ -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. diff --git a/templates/single-product-reviews.php b/templates/single-product-reviews.php index a42c06818ce..a03d38bc00f 100644 --- a/templates/single-product-reviews.php +++ b/templates/single-product-reviews.php @@ -11,41 +11,49 @@ global $woocommerce;
'; + + 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 '
'; - - echo '
'.$average.' '.__('out of 5', 'woocommerce').'
'; - - echo '

'.sprintf( _n('%s review for %s', '%s reviews for %s', $count, 'woocommerce'), ''.$count.'', wptexturize($post->post_title) ).'

'; - - echo '
'; - - 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 '
'; + + echo '
'.$average.' '.__('out of 5', 'woocommerce').'
'; + + echo '

'.sprintf( _n('%s review for %s', '%s reviews for %s', $count, 'woocommerce'), ''.$count.'', wptexturize($post->post_title) ).'

'; + + echo '
'; + + } else { + + echo '

'.__('Reviews', 'woocommerce').'

'; + + } + + } else { + echo '

'.__('Reviews', 'woocommerce').'

'; - - endif; + + } $title_reply = ''; diff --git a/templates/single-product/review.php b/templates/single-product/review.php index 85f1a0de711..eb623b29867 100644 --- a/templates/single-product/review.php +++ b/templates/single-product/review.php @@ -17,10 +17,14 @@ global $post;
+ + -
- comment_ID, 'rating', true ); ?> -
+
+ comment_ID, 'rating', true ); ?> +
+ + comment_approved == '0') : ?>