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        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;
}

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

  • WooCommerce: Display Product Reviews @ Custom Page (Shortcode)
    WooCommerce product reviews shows by default in the “Reviews” tab in the single product page. But what if, like me, you’re using custom sales pages and need to show such reviews elsewhere – by using a shortcode? I’ve spent some time doing this for two Business Bloomer pages, the contact page (beside the request a […]
  • WooCommerce: 6 Tips to Improve User Experience
    With the right approach to user experience you can make your WooCommerce website more effective at converting visitors into customers and encouraging existing users to come back to make purchases more regularly. There are several ways to enhance UX using WooCommerce as a foundation, so here are just a few of the most impactful options […]
  • WooCommerce Blocks: Hide Images Etc. From Product Grid Block
    Business Bloomer enters the world of Gutenberg today, and we do it with a simple customization tutorial related to the “Product Grid” WooCommerce Gutenberg Blocks: currently these are “Best Selling Products“, “Newest Products“, “On Sale Products“, “Top Rated Products“, “Products by Category” and use the same base code… However, all of them use custom code […]
  • WooCommerce: Define Product Settings Programmatically e.g. Enable Reviews, Sold Individually
    In WooCommerce, everything is easy until you have a dozen products to manage. But once you start scaling, and maybe need to import hundreds of items, right then is when you go looking for shortcuts. Problem is – there are single product settings that you must enter manually for each product (or do it in […]

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 *