Skip to content

Snippet: WooCommerce Click to Toggle Review Form

/* Add this CSS to the site to hide the form and make the comment title look more like a button */
.woocommerce #review_form #commentform {
    display: none;
}

.woocommerce #review_form .comment-reply-title {
    display: inline-block;
    background: #000;
    color: #fff;
    padding: 10px 20px;
    font-size: 12px;
    cursor: pointer;
}

/* Add this to your functions.php file for the javascript needed for the toggle affect */
add_action( 'wp_footer', function() { ?>
	
		( function( $ ) {
			'use strict';
			$( '.woocommerce #review_form .comment-reply-title' ).click( function() {
				$( '.woocommerce #review_form #commentform' ).toggle();
			} );
		} ( jQuery ) );
	
<?php } );
All PHP snippets should be added via child theme's functions.php file or via a plugin. We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top