Sandesh

April 11, 2020

WooCommerce: How To Remove Checkout Fields @ Checkout Page

WooCommerce is a very powerful eCommerce plugin. No Doubt WooCommerce’s default checkout page is great. But there are times when you need to customize the checkout fields. Imagine you have a digital product store, then you probably need only the First Name, Last Name, and Email. Unfortunately, WooCommerce doesn’t provide the option to remove these fields.

But, they can be removed using custom code. This post will help you to understand how to remove unwanted fields with custom code safely. I have also incorporated a tutorial to make the task easy.

Just for the records, I am using Astra Theme ( The Fastest, Flexible and Free theme for WordPress ) in my tutorial.

How to safely add custom code?

You can add custom code to the site in several ways. Eg. Using child theme’s functions.php, Using a custom plugin, using FTP to edit files, etc. You can pick any method you are familiar with.

I will show how to add custom code without directly editing a functions.php file. I will suggest a plugin Code Snippets. It will allow adding custom code quickly and, most importantly, safely. This plugin will run your code without a fatal error, that means your website will not break even if you have an error in your code. The custom code will work even after you switch the theme.

Let’s get started:

How to remove Billing Fields?

Available Billing Fields:

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

Available Additional Field:

  • order_comments

The code from below gist will remove all billing and additional fields form the checkout page.

/**
 * @snippet       WooCommerce How To Remove Checkout Fields @ Checkout Page
 * @author        Sandesh Jangam
 * @donate $7     https://www.paypal.me/SandeshJangam/7
 */

add_filter( 'woocommerce_checkout_fields' , 'ts_custom_remove_checkout_fields' );

function ts_custom_remove_checkout_fields( $fields ) {
  
  /* Billing Field */
  unset( $fields['billing']['billing_first_name'] );
  unset( $fields['billing']['billing_last_name'] );
  unset( $fields['billing']['billing_company'] );
  unset( $fields['billing']['billing_address_1'] );
  unset( $fields['billing']['billing_address_2'] );
  unset( $fields['billing']['billing_city'] );
  unset( $fields['billing']['billing_postcode'] );
  unset( $fields['billing']['billing_country'] );
  unset( $fields['billing']['billing_state'] );
  unset( $fields['billing']['billing_phone'] );
  unset( $fields['billing']['billing_email'] );
  
  /* Additional Filed */
  unset( $fields['order']['order_comments'] );
  
  return $fields;
}

Just take a look at a code. You will easily understand the name of each field.

For example, if you want to remove company, address 1, and address 2 fields then just keep this below field in code ( keep lines 10, 11, 12 and remove other field lines )

  • billing_company
  • billing_address_1
  • billing_address_2

Refer this example for details.

/**
 * @snippet       WooCommerce How To Remove Checkout Fields @ Checkout Page
 * @author        Sandesh Jangam
 * @donate $7     https://www.paypal.me/SandeshJangam/7
 */

add_filter( 'woocommerce_checkout_fields' , 'ts_custom_remove_checkout_fields' );

function ts_custom_remove_checkout_fields( $fields ) {
  
  /* Billing Field */
  unset( $fields['billing']['billing_company'] );
  unset( $fields['billing']['billing_address_1'] );
  unset( $fields['billing']['billing_address_2'] );
   
  return $fields;
}

If you would like to display any checkout fields that have been removed, you can simply delete that line from code which represents that specific field.

That’s it!

If you find any difficulty while using the custom code, please feel free to add your thought in the comments below. I Will love to hear back 🙂

Where to add custom PHP code?

Add the above PHP code at the end of to your child theme’s functions.php. There are many ways to add custom PHP code ( custom functionality ) to WordPress / WooCommerce website. Read this article for more information

Why this code is not working?

If you face any issue with the above code, then please let me know in the comment. I will be happy to review the code, and If it is working for you, then show me some love in the comment section.

Thank you in advance…!

Sharing is Caring!
Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on telegram
Share on whatsapp

About the Author

Sandesh Jangam is Developer, WooCommerce Expert, and Podcaster. He is working as a WordPress developer since 2014 and helping people with this blog. He loves to travel ancient temples, chilling at the beach and reading books

Join 1,000+ Subscribers

Get exclusive access to WordPress, WooCommerce tips, articles, tutorials right in your inbox.​

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest
Share on telegram
Share on whatsapp

Leave a Comment

Your email address will not be published.

Become a WooCommerce Customization Expert and Earn More​

Get an early access notification right in your inbox.

Learn More or Register Now >>>