WooCommerce PHP Beginner Requires WooCommerce

Make the Phone Field Optional at Checkout

Stop requiring a phone number on the classic checkout, so customers who don't want to share it can still order.

Tested on WordPress 7.1 PHP 8.3 Updated
functions.php 6 lines
add_filter( 'woocommerce_billing_fields', function ( array $fields ): array {
	if ( isset( $fields['billing_phone'] ) ) {
		$fields['billing_phone']['required'] = false;
	}
	return $fields;
} );

Where to add this

Recommended A code snippets plugin Survives theme changes and is easy to switch off.
Child theme At the end of your child theme's functions.php file.
Must-use plugin As a .php file in wp-content/mu-plugins, starting with <?php.

Always add PHP to a staging site first, or have FTP or file manager access ready, so you can undo it if something goes wrong.

Some customers abandon checkout rather than hand over a phone number. If you don’t call customers, there’s no reason to require it.

How it works

The woocommerce_billing_fields filter holds the settings for each billing field. Setting 'required' => false removes the asterisk and the validation error, but keeps the field so customers can still fill it in.

Things to watch

  • WooCommerce also has a setting for this. In the Customizer, go to WooCommerce → Checkout and set “Phone field” to Optional or Hidden. If that setting is available on your site, use it instead.
  • For the block-based Checkout, select the Checkout block in the editor and set the phone field to Optional there.
  • Some couriers need a phone number for delivery. Check with your shipping provider first.

How to test it

Place a test order with the phone field empty. It should go through without a “Phone is a required field” error.

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only