Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Make WooCommerce Checkout Fields Required or Optional?

Making WooCommerce Checkout Fields Required or Optional in WooCommerce is a common customization store owners need when the default checkout setup doesn’t match their business requirements.

For example, you may want to:

  • Make the phone number optional to reduce checkout friction
  • Force the company name as required for B2B orders
  • Adjust required fields based on your audience or region

By default, WooCommerce decides which checkout fields are mandatory. But with a small code change, you can easily make any billing or shipping field required or optional—without editing core files. This post explains how you can modify the fields & make fields required or optional on the WooCommerce Checkout page.

Where to Add This Code Safely

The recommended ways to add checkout field customization code are:

  • Your child theme’s functions.php file
  • The Code Snippets plugin (safer for non-developers)

Avoid editing WooCommerce core files, as updates will overwrite your changes.

Example 1: Making the Phone field optional

In the latest versions of WooCommerce, the Phone field (under Billing Details) is a required field by default when you are on the Checkout page.

Make fields required or optional on the WooCommerce Checkout page

What if you want to make this field optional for cases where it isn’t necessary and where customers too do not wish to disclose this information?

The code snippet below enables you to do the same:

add_filter( 'woocommerce_billing_fields', 'ts_unrequire_wc_phone_field');
function ts_unrequire_wc_phone_field( $fields ) {
$fields['billing_phone']['required'] = false;
return $fields;
}

The first line here declares a function named as “ts_unrequire_wc_phone_field”. You can name your function anything you want.

‘billing_phone’ refers to the name of the Phone field that we want to make optional.

Inside the function,  $fields[‘billing_phone’][‘required’] is assigned a “false” value implying that the field is not required or is optional.

Adding the lines above to your child theme‘s function.php file will make the Phone field optional on the Checkout page, as depicted in the image below.

Make WooCommerce Checkout Fields Required or Optional

There you go! The Phone field is now optional.

flexi bogo cta banner image


This to the shop owners who are running or planning to run BOGO offers on their WooCommerce store…

BOGO deals are great for increasing your sales, but have you thought about which offers are bringing you more revenue and which offers are not performing that great?

Don’t just set a BOGO deal, track the revenue generated by your deals in real-time with the Flexi BOGO for WooCommerce plugin.

Example 2: Making the Company Name field required

On the Checkout page, we see that the company name field is optional by default:

Make WooCommerce Checkout Fields Required or Optional

There are many cases where you may want the Company Name to be a compulsory field. For example, sale of tickets to a corporate conference or seminar, or the purchase of a corporate license for a product. In this case, the same code snippet may be used with a few modifications to make the Company Name field a required field.

add_filter( 'woocommerce_billing_fields', 'ts_require_wc_company_field');
function ts_require_wc_company_field( $fields ) {
$fields['billing_company']['required'] = true;
return $fields;
}

Here, assigning a value of “true” to $fields[‘billing_company’][‘required’] does the job.

The result is that the company name field becomes a required field:

Make WooCommerce checkout Fields Required or Optional

Below are the HTML names of all the fields on the Checkout page. The names are indicative of which field they correspond to. You can refer to the snippets above to change any of these fields into an optional or a required field, depending on the use case.

Billing Fields

  • billing_first_name
  • billing_last_name
  • billing_company
  • billing_country
  • billing_address_1
  • billing_address_2
  • billing_city
  • billing_state
  • billing_postcode
  • billing_phone
  • billing_email

Shipping Fields

  • shipping_first_name
  • shipping_last_name
  • shipping_company
  • shipping_country
  • shipping_address_1
  • shipping_address_2
  • shipping_city
  • shipping_state
  • shipping_postcode

Order Fields

  • order_comments

With just a few lines of code, you can change any field on your Checkout page into an optional or a mandatory field.

If your requirements go beyond simply toggling field validation and you’d like to reorder fields, add new checkout fields, or apply conditional logic, WooCommerce checkout hooks are the right tool for the job. We’ve put together a visual, developer-friendly guide that explains where and how each WooCommerce checkout hook fires, along with practical code examples.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
11 Comments
Newest
Oldest
Inline Feedbacks
View all comments
Laurent
3 years ago

Hi, how can you change when you just want to select specific country selected to change it to be mandatory. Like if selected country and state is not mandatory.
Thanks

Chethiya Kusal
4 years ago

Really helpful

Carolina
5 years ago

Where do I add this code to? I’m a total beginner.

Anonymous
3 years ago
Reply to  Carolina

the functions.php file, if you don’t have one, make it inside the root of your theme directory

5 years ago

Hi, thank you very much it’s working and I don’t have to use another plugins to do so …

6 years ago

Hi,

Really helpful article. I added a couple extensions to WordPress and suddenly all my checkout fields are showing as option.

Is it necessary to add the snipets through a child theme though? Can it be done through one of the other means you mentioned: Using a Plugin, oe Creating a Custom Plugin? I’m out of my depth creating child themes.

Thanks

Valentine’s Day Big Hearts, Better Savings Sale: 20% Off on All Plugins. 25% Off on All Plugin Bundles.
11
0
Would love your thoughts, please comment.x
()
x
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible.

Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

By using our site, you acknowledge that you have read and understood our Privacy Policy and Terms & Conditions.