How to Make Phone Number Required WooCommerce

woocommerce make phone number requiredAre you looking for a quick and easy way to make phone number required in WooCommerce? In this post, I will share with you an excellent solution that will quickly help you make phone number required.

I run into the same problem when I was customizing the WooCommerce checkout page, I came up with a ‘ WooCommerce make phone number required ‘ code snippet that you too can use to make the phone number required in your WooCommerce store checkout page.

WooCommerce Make Phone Number Required

To make the WooCommerce phone number at checkout required, as you can see in the image below, you need to use the code snippet below. You can add this code snippet to the functions.php file or your plugin development.

[php] /**
* Make phone number required WooCommerce
*/

add_filter( ‘woocommerce_billing_fields’, ‘njengah_make_phone_number_required’, 10, 1 );

function njengah_make_phone_number_required( $address_fields ) {
$address_fields[‘billing_phone’][‘required’] = true;
return $address_fields;
}

[/php]

woocommerce make phone number required

WooCommerce Make Phone Number Not Required

If you wish to make the phone number not required you can reverse this by changing the boolean value in the callback function and the code should be as follows:

[php] /**
* Make phone number not required WooCommerce
*/

add_filter( ‘woocommerce_billing_fields’, ‘njengah_make_phone_number_required’, 10, 1 );

function njengah_make_phone_number_required( $address_fields ) {
$address_fields[‘billing_phone’][‘required’] = false;
return $address_fields;
}
[/php]

Conclusion

In this post, we have looked at how make phone number required in WooCommerce, as you can see there are two steps involved in making phone number required in WooCommerce checkout.

You can easily and quickly use this solution in your WooCommerce theme or plugin development. Just in case you are stuck, I am always ready to help you implement this solution and also to further customize it to fit your specific needs.

Similar Articles

  1. How to Add Checkout Phone Number Validation WooCommerce