Você está visualizando atualmente WooCommerce: Show Rating @ WooCommerce Product Review Admin Email

WooCommerce: Show Rating @ WooCommerce Product Review Admin Email

  • Autor do post:
  • Categoria do post:Woocommerce
  • Tempo de leitura:4 minutos de leitura

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 .= “rn” . sprintf( ‘Product review rating: %s / 5’, $rating ) . “rn”; } return $notify_message; }

Where to add custom code?

You should place PHP snippets at the bottom of your child theme functions.php file and CSS at the bottom of its style.css file. Make sure you know what you are doing when editing such files – if you need more guidance, please take a look at my guide “Should I Add Custom Code Via WP Editor, FTP or Code Snippets?” and my video tutorial “Where to Place WooCommerce Customization?”

Does this snippet (still) work?

Please let me know in the comments if everything went as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting.

If you think this code saved you time & money, feel free to join 17,000+ WooCommerce Weekly subscribers for blog post updates and 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance!

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

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