Product Page

WooCommerce Review Form Visual Hooks Guide

WooCommerce review form showing available hooks

Pre-Requisites

There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

The WooCommerce review form uses the default WordPress comment form and adds a few sprinkles of meta data, the star rating being one of these meta fields. This guide gives you a visual insight into where the hooks are in the WooCommerce review form. You’ll notice in each of the hook callbacks, we’ve wrapped the echo output in an if statement to check if the review form is on the product page using the function is_product(). This allows us to leave the blog post form untouched, meaning edits are only made to the review form.

Show Content Before The WooCommerce Review Form

/**
 * Snippet Name:	WooCommerce Review Form Hooks - comment_form_before
 * Snippet Author:	ecommercehints.com
 */

add_action( 'comment_form_before', 'ecommercehints_comment_form_before', 10, 1 );
function ecommercehints_comment_form_before($array) {
	if (is_product()) {
		echo 'comment_form_before';
	}
}

Show Content At The Top Of The WooCommerce Review Form

/**
 * Snippet Name:	WooCommerce Review Form Hooks - comment_form_top
 * Snippet Author:	ecommercehints.com
 */

add_action( 'comment_form_top', 'ecommercehints_comment_form_top', 10 );
function ecommercehints_comment_form_top() {
	if (is_product()) {
		echo 'comment_form_top';
	}
}

Show Content Between The Review Text And First Name And Email Address Fields On The WooCommerce Review Form

/**
 * Snippet Name:	WooCommerce Review Form Hooks - comment_form_before_fields
 * Snippet Author:	ecommercehints.com
 */

add_action( 'comment_form_before_fields', 'ecommercehints_comment_form_before_fields', 10 );
function ecommercehints_comment_form_before_fields() {
	if (is_product()) {
		echo 'comment_form_before_fields';
	}
}

Show Content Between The First Name And Email Address Fields And The Submit Button On The WooCommerce Review Form

/**
 * Snippet Name:	WooCommerce Review Form Hooks - comment_form_after_fields
 * Snippet Author:	ecommercehints.com
 */

add_action( 'comment_form_after_fields', 'ecommercehints_comment_form_after_fields', 10, 1 );
function ecommercehints_comment_form_after_fields( $array ) {
	if (is_product()) {
		echo 'comment_form_after_fields';
	}
}

Show Content After The Submit Button On The WooCommerce Review Form

/**
 * Snippet Name:	WooCommerce Review Form Hooks - comment_form
 * Snippet Author:	ecommercehints.com
 */

add_action( 'comment_form', 'ecommercehints_comment_form', 10, 1 );
function ecommercehints_comment_form( $array ) {
	if (is_product()) {
		echo 'comment_form';
	}
}

Show Content After The WooCommerce Review Form

/**
 * Snippet Name:	WooCommerce Review Form Hooks - comment_form_after
 * Snippet Author:	ecommercehints.com
 */

add_action( 'comment_form_after', 'ecommercehints_comment_form_after', 10, 1 );
function ecommercehints_comment_form_after( $array ) {
	if (is_product()) {
		echo 'comment_form_after';
	}
}

Show Content If The Customer Is Logged Out And Most Log In To Leave A Review

/**
 * Snippet Name:	WooCommerce Review Form Hooks - comment_form_must_log_in_after
 * Snippet Author:	ecommercehints.com
 */

add_action( 'comment_form_must_log_in_after', 'ecommercehints_comment_form_must_log_in_after', 10 );
function ecommercehints_comment_form_must_log_in_after() {
	if (is_product()) {
		echo 'comment_form_must_log_in_after';
	}
}

Show In Place Of The WooCommerce Review Form If Comments Are Closed

/**
 * Snippet Name:	WooCommerce Review Form Hooks - comment_form_closed
 * Snippet Author:	ecommercehints.com
 */

add_action( 'comment_form_closed', 'ecommercehints_comment_form_must_log_in_after', 10 );
function ecommercehints_comment_form_closed() {
	if (is_product()) {
		echo 'comment_form_closed';
	}
}

Snippet Benefits

  • Edit parts of the review form using hooks without editing the blog post comment form.
  • You can go more in-depth and change the “Verified Owner” text using this guide.

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 10% off on your first month with us.

26027
WELCOME OFFER