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

WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers