Hide WooCommerce Checkout Button Until Terms and Conditions Accepted

Often times stores need to require terms and conditions to be accepted for anyone placing an order. WooCommerce can do this out of the box, but the checkout button will still be present. You can hide it until the “terms and conditions” have been accepted with a bit of JavaScript though.

Add this snippet to your theme’s functions.php file or via the Code Snippets plugin.

add_action( 'wp_footer', function () { ?>

<script>
jQuery(document).ready(function(){
	function showCheckout() {
		jQuery('#place_order').hide();
		jQuery('#terms').change(function(){
			if(this.checked)
				jQuery('#place_order').fadeIn('slow');
			else
				jQuery('#place_order').fadeOut('slow');
		});
	}
	setTimeout(showCheckout, 500)
});
</script>
<?php } );

This will hide the payment button once the page has finished loading. Then the user will have to check the box to accept terms and conditions to have the button appear again.


Leave a Reply

Discover more from Just A Bill

Subscribe now to keep reading and get access to the full archive.

Continue reading