If you are using WooCommerce for digital products then you obviously do not need all of the checkout fields (billing details) that are on the checkout page by default.
Seeing as multiple people have contacted me to fix their websites after following various guides on “How to remove the WooCommerce checkout fields”, I have decided to write a post on how to safely but very easily do this.
The thing is, all of these guides advise you to directly modify your functions.php file which I am highly against.
If you are not familiar with coding and you cluelessly follow their instructions there is a high chance that you will break your website.
Don’t believe me? Take a look at the user comments from these guides, I guarantee that there is at least one person that is upset because their website broke.
Below I’m going to show you the safest and quickest way to remove the checkout fields from WooCommerce and if you do make a mistake you can very easily undo the changes, unlike if you were to modify functions.php directly.
WooCommerce: How To Remove The Checkout Fields
1. Install the plugin My Custom Functions.
This plugin allows you to easily and safely add functions, snippets or any custom code without directly editing your functions.php file.
The code entered in the plugin will run safely and will not generate any fatal errors, this means your website will not break if there is an error in your code.
Also, the custom code you add into the plugin will continue working, no matter how many times you update or switch your theme.
2. Once you have installed the plugin go to Appearances and then click on Custom Functions.
You will see a white text area where you can enter code.
3. To remove all of the checkout fields from WooCommerce, copy and paste the below code into the Custom Functions plugin.
/* WooCommerce: The Code Below Removes Checkout Fields */
add_filter( ‘woocommerce_checkout_fields’ , ‘custom_override_checkout_fields’ );
function custom_override_checkout_fields( $fields ) {
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[‘order’][‘order_comments’]);
unset($fields[‘billing’][‘billing_email’]);
unset($fields[‘account’][‘account_username’]);
unset($fields[‘account’][‘account_password’]);
unset($fields[‘account’][‘account_password-2’]);
return $fields;
}
4. If you take a look at the code, you will notice that it is fairly easy to understand which checkout field each line represents
For example, the below code hides the fields:
– First Name
– Last Name
– Company
unset($fields[‘billing’][‘billing_first_name’]);
unset($fields[‘billing’][‘billing_last_name’]);
unset($fields[‘billing’][‘billing_company’]);
If you would like to display any checkout fields that have been removed, you can simply delete the line of code that represents the specific field.
That’s all there is to it! Simple, Fast and Safe!
If you encounter any errors you can simply remove the code from the Custom Functions plugin and your site will go back to how it was.