How To Add Guest Badge To WooCommerce Reviews

Add Guest Badge To WooCommerce

Guest Shopper badge and Verified Shopper badge for WooCommerce stores.

One of the hardest things to do nowadays is to get reviews for your products. Not to mention legit ones at that. When we created Hush + Dotti we struggled with getting reviews. Nobody wanted to sign in and jump thru hoops to do it. It’s simply a hassle.

And as many of you know, WordPress & WooCommerce have a major bullseye on their backs when it comes to spam bots taking over our websites.

So what I did was open up the commenting to everybody, even “Guest” shoppers and added filters to WordPress’ new discussion blocker. So now guest shoppers can write a review. No having to register and login or give their personal information. Now more shoppers are apt to write a review and this Guest Buyer label gets applied to their review.

I recommend you only add this to your child theme. Adding custom code to a premium paid theme can cause issues down the road and you might end up overwriting yourself if you update the parent theme some day.

Ok, so let’s get started. Head over to your review-meta.php file and look for this line. If you don’t know where the file is located look here first. Some premium eCommerce themes have a folder called woocommerce. The file path would be woocommerce > single-product > review-meta. If it’s not in there you’re going to need to make a copy of this file to your child theme from WooCommerce plugin folder. Do not edit in the plugin and don’t add this to your parent theme.

if ( 'yes' === get_option( 'woocommerce_review_rating_verification_label' ) && $verified ) {
			echo '(' . esc_attr__( 'verified owner', 'woocommerce' ) . ') ';

Now here’s where we’re going to rewrite and add guest badge for WooCommerce. Right here in this¬† section like so.

if ( 'yes' === get_option( 'woocommerce_review_rating_verification_label' ) && $verified ) {
	   echo ' ' . esc_attr__( 'verified buyer', 'woocommerce' ) . ' ';
		} else {
             //simply add copy the woocommerce-review__verified from above and change the last part to guest
           echo ' ' . esc_attr__( 'guest buyer', 'woocommerce' ) . ' '; //Change the phrase Verified Buyer to Guest Buyer

In the end you’re going to want your review-meta file to look like this. You’ll notice I use FontAwesome with my theme so the verified checkmark shows for each person’s review. I feel it gives the review a bit more authenticity.

 * The template to display the reviewers meta data (name, verified owner, review date)
 * This template can be overridden by copying it to yourtheme/woocommerce/single-product/review-meta.php.
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 * @see
 * @author  WooThemes
 * @package WooCommerce/Templates
 * @version 3.7.0

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
global $comment;
       $verified = wc_review_is_from_verified_owner( $comment->comment_ID );
if ( '0' === $comment->comment_approved ) { ?>
	<p class="meta"><em class="woocommerce-review__awaiting-approval"><?php esc_attr_e( 'Your review is awaiting approval', 'woocommerce' ); ?></em></p>
<?php } else { ?>
	<p class="meta">
		<strong class="woocommerce-review__author"><?php comment_author(); ?></strong> <?php
		if ( 'yes' === get_option( 'woocommerce_review_rating_verification_label' ) && $verified ) {
		   echo '<i class="fa fa-check-circle-o" aria-hidden="true"></i> ';
		      echo '<em class="woocommerce-review__verified verified"> ' . esc_attr__( 'verified buyer', 'woocommerce' ) . '</em> ';
		           } else {
                      echo '<i class="fa fa-check-circle-o" aria-hidden="true"></i> '; 
                   echo '<em class="woocommerce-review__guest verified"> ' . esc_attr__( 'guest buyer', 'woocommerce' ) . '</em> ';
            <span class="woocommerce-review__dash"></span> 
         <time class="woocommerce-review__published-date" datetime="
      <?php echo get_comment_date( 'c' ); ?>"><?php echo get_comment_date( wc_date_format() ); ?></time>
<?php }

For More Information On How To Write Hooks For WooCommerce

Leave a Reply