Menu Close

WooCommerce: Show Rating @ WooCommerce Product Review Admin Email

default

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
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

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;
}
View Source
Posted in WooCommerce Tips