WooCommerce: Show Rating @ WooCommerce Product Review Admin Email

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!

If the admin email is for moderating a new WooCommerce product review, the rating will now show at the very bottom of it, so that the admin is able to (1) know this is a product review and (2) the tone or statements they should make based on the review stars!

PHP Snippet: Display Rating (“2 out of 5”) @ WooCommerce Product Review Admin Emails

/**
 * @snippet       See Rating @ WooCommerce New Product Review Admin Email
 * @how-to        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @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;
}

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *