How to remove checkout fields in Woocommerce

A two step guide on how to remove checkout fields in Woocommerce programatically. Below I’m going to show you a safe and quick way to remove the checkout fields. Don’t worry if you make a mistake, you can easily undo the changes.

Step 1 – prerequisites

In case you have access to your themes functions.php file, create a backup of it as the first step. Please never use the theme editor in your WordPress dashboard, it will give you a lot of headaches.

If you don’t have access to the functions.php file, download a plugin like the My Custom Functions which gives you the ability to add custom PHP code to your website. For the beginners I recommend this option.

The default Woocommerce checkout fields are:

  • billing first name (the Woocommerce system name is billing_first_name)
  • billing last name (billing_last_name)
  • billing company name (billing_company)
  • billing country (billing_country)
  • billing county/state (billing_state)
  • billing postcode (billing_postcode)
  • billing city (billing_city)
  • billing street address -> 2 input fields (billing_address_1, billing_address_2)
  • billing phone (billing_phone)
  • billing email (billing_email)
  • shipping first name (shipping_first_name)
  • shipping last name (shipping_last_name)
  • shipping company (shipping_company)
  • shipping country (shipping_country)
  • shipping county/state (shipping_state)
  • shipping postcode (shipping_postcode)
  • shipping city (shipping_city)
  • shipping street address -> 2 input fields (shipping_address_1, shipping_address_2)
  • order notes (order_comments)

Step 2 – removing the fields

To remove a field you will have to add a few lines of PHP code to the end of your functions.php file, or to the custom code editor of the plugin (for the My Custom Functions it will be Settings -> PHP Inserter from your dashboard). You can remove or change your checkout fields with the “woocommerce_checkout_fields” hook. For example you can remove the shipping company field like this:

The method which removes every default checkout field from Woocommerce:

Change this method above according to your needs. For example if you would like to hide billing company, shipping company, billing state and shipping state from the Woocommerce checkout, leave the lines belonging to these fields and delete everything else:

In case you encounter any errors, just delete the code from your functions.php file (alternatively replace functions.php with your backup file), or remove the code from the Custom Functions plugin. Happy coding!

 

5 1 vote
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments