WP Rocket - WordPress Caching Plugin

In a previous post, I showed you how to remove billing fields in WooCommerce, without using a plugin.

In this post, I’ll show you have to make billing and shipping fields optional in WooCommerce’s checkout page since it doesn’t have this feature by default.

And again, I’m not going to use a plugin. There’s no need of using a plugin if you can do it manually, at least not for this.

The fewer plugins you have, the better! That’s what I always say.

Make billing and shipping fields optional

First, you’ll have to access your WordPress website’s files.

Then, you’ll have to find and edit the functions.php file in your child theme. It’s usually in /public_html/wp-content/themes/YOURTHEMENAME-child/functions.php.

I strongly recommend having a child theme in place, otherwise, your changes will be lost with the next theme update.

I also recommend backing up the file or the whole website, just to be extra safe.

Now, let’s say that you want to make the “Company” and “Postcode” fields optional.

Once you’re in the functions.php file, add this code at the very bottom:

add_filter( 'woocommerce_default_address_fields' , 'optional_default_address_fields' );
function optional_default_address_fields( $address_fields ) {
$address_fields['company']['required'] = false;
$address_fields['postcode']['required'] = false;
return $address_fields;

Save the file.

Here’s how the code looks on our theme’s file:

functions.php WooCommerce code

Those checkout billing and shipping fields should be optional now.

If the changes don’t take place after you refresh the page, please clear your page (or entire website) and/or browser cache.

If you want to make more checkout fields optional, then add more $address_fields into the code.

Here are all the billing and shipping default fields:

  • country
  • first_name
  • last_name
  • company
  • address_1
  • address_2
  • city
  • state
  • postcode

Let’s say you want to add a couple more fields and make them optional: “City” and “State”.

Your code should look like this:

add_filter( 'woocommerce_default_address_fields' , 'optional_default_address_fields' );
function optional_default_address_fields( $address_fields ) {
$address_fields['company']['required'] = false;
$address_fields['postcode']['required'] = false;
$address_fields['city']['required'] = false;
$address_fields['state']['required'] = false;
return $address_fields;

WooCommerce checkout fields optional

As you can see, the “Company”, “ZIP” (Postcode), “City” and “State” fields are missing the required mark * (asterisk), which means they are now optional.

It wasn’t that hard, right?

Now you know how to make billing and shipping fields optional in WooCommerce, without adding yet another WordPress plugin!

You might also want to read:

That’s a wrap

Hope you liked the post and found it comprehensive.

Don’t forget to share it to help out others!

You can also follow us on Twitter and subscribe to our YouTube channel.

If you want to start your own WordPress blog, or need a website for your business, our WordPress services are at your disposal!