How to remove checkout fields in WooCommerce

Default WooCommerce checkout form comes with several fields for customers to enter their billing details. But in some cases, you might want to hide some of these fields. For example, if you are selling only virtual products, you can get rid of fields like billing address.

In order to remove checkout fields, you need to perform the following.

  1. Open up the wp-content/themes/themeXXXXX/includes/custom-function.php file. You may need to download it to your local system if you are using FTP, or you can access the file directly through your hosting file manager.
  2. Scroll down to the very end of the file and add the following code there.
    <?php
     
    add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
      
    function custom_override_checkout_fields( $fields ) {
     
        return $fields;
    }
     
    ?>
  3. Choose the fields to be removed from the list below and insert the corresponding code inside the custom_override_checkout_fields function before the return statement.
    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']);
    
    

    WooCommerce._How_to_remove_checkout_fields-2

  4. Save the changes in the wp-content/themes/themeXXXXX/includes/custom-function.php file and upload it to the server. Reload the page. The fields chosen to be unset are removed from the page.