Category

How to remove WooCommerce Checkout fields?

This tutorial shows you how to remove checkout fields in a WooCommerce store.

Default WooCommerce checkout form comes with several default fields. In some cases, we might want to hide some of these fields. For example, if you are selling online a virtual product, you might want to get rid of billing address fields. Here is a snippet of code that can help you remove these fields:

In your WordPress theme file, look for the function.php file. Open the file and at the very end of your file place the following code:

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;
}

You can customize the above code, let say you want to remove only the address fields then the code will become:

add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
  
function custom_override_checkout_fields( $fields ) { 
    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']);
    return $fields;
}

Was this helpful? Did I missed something? Do you have a question? Get in touch.