When a WooCommerce customer posts a product review on the single product page, and “Comment must be manually approved” is enabled under WordPress dashboard > Settings > Discussion, the store owner gets an email notification so that they can approve / trash / spam such a review.
What you probably knew, is that the “WooCommerce product review” is – actually – a “WordPress post comment“, which means the email that the admin gets is the default “Please moderate: _____” notification that is also generated when a comment is submitted on a blog post.
Which… is really bad! And that’s because the email does not contain any sort of information regarding the WooCommerce product review, and especially the rating (“2 stars out of 5”). As a store owner, I definitely want to know whether the comment I’m about to moderate is (1) a product review and if (2) I need to reply to unfair feedback, so, let’s change that.
Here’s how to display the review rating in the “Please moderate: ____” admin email notification, when the comment is – of course – a WooCommerce product review. Enjoy!
PHP Snippet: Display Rating (“2 out of 5”) @ WooCommerce Product Review Admin Emails
/**
* @snippet See Rating @ WooCommerce New Product Review Admin Email
* @how-to Get CustomizeWoo.com FREE
* @author Rodolfo Melogli
* @compatible WooCommerce 8
* @community https://businessbloomer.com/club/
*/
add_filter( 'comment_moderation_text', 'bbloomer_add_stars_woocommerce_moderate_comment_email', 9999, 2 );
function bbloomer_add_stars_woocommerce_moderate_comment_email( $notify_message, $comment_id ) {
$review = get_comment( $comment_id );
if ( $review && 'product' === get_post_type( $review->comment_post_ID ) ) {
$rating = intval( get_comment_meta( $comment_id, 'rating', true ) );
$notify_message .= "\r\n" . sprintf( 'Product review rating: %s / 5', $rating ) . "\r\n";
}
return $notify_message;
}