';
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 {
echo '
'.__( 'Reviews', 'woocommerce' ).'
';
}
} else {
echo '
'.__( 'Reviews', 'woocommerce' ).'
';
}
$title_reply = '';
if ( have_comments() ) :
echo '';
if ( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
← Previous', 'woocommerce' ) ); ?>
→', 'woocommerce' ) ); ?>
'.__( 'Add Review', 'woocommerce' ).'';
$title_reply = __( 'Add a review', 'woocommerce' );
else :
$title_reply = __( 'Be the first to review', 'woocommerce' ).' “'.$post->post_title.'”';
echo '
'.__( 'There are no reviews yet, would you like to submit yours?', 'woocommerce' ).'
';
endif;
$commenter = wp_get_current_commenter();
echo '