WordPress Remove WooCommerce checkout billing field validation

You'll see a lot of answers that instruct you to override the checkout fields filter.

This is accurate.

But, you'll also need to disable WooCommerce's i18n address script, as it add client-side validation to the fields, regardless of whether or not you've removed it on the server-side.
add_action('wp_enqueue_scripts', 'override_woo_frontend_scripts');
function override_woo_frontend_scripts() {
	wp_deregister_script('wc-address-i18n');
}


add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields', 10, 1 );
function custom_override_checkout_fields( $fields ) {

	$fields['billing']['billing_phone']['required'] = false;
	unset($fields['billing']['billing_phone']['validate']);
		
	$fields['billing']['billing_country']['required'] = false;
	unset($fields['billing']['billing_country']['validate']);
	
	$fields['billing']['billing_address_1']['required'] = false;
	unset($fields['billing']['billing_address_1']['validate']);
	
	$fields['billing']['billing_city']['required'] = false;
	unset($fields['billing']['billing_city']['validate']);
	
	$fields['billing']['billing_state']['required'] = false;
	unset($fields['billing']['billing_state']['validate']);
	
	$fields['billing']['billing_postcode']['required'] = false;
	unset($fields['billing']['billing_postcode']['validate']);		
	
	return $fields;
}
Posted by
Snippet Viewed 869 times.

Share your WordPress code snippets:

  • Get some recognition & a link back to your site.
  • Create your own code library.
  • Help your fellow developers, as they have helped you.
Submit | Browse

Most Recent wordpress snippets

Most Viewed

The FitDesk Under Desk Elliptical