How to remove fields from checkout & ordering form in WooCommerce

WooCommerce has become a great e-commerce platform that comes packed with lots of features. However, sometimes you might need to remove or edit some of the form items on the checkout page, cart page, and ordering page. This might require a custom code workaround.😉

Remove or unset a field in WooCommerce

As the official documentation states,  billing and shipping fields for checkout as pulling from the countries class (class-wc-countries.php) and the get_address_fields function. So, WooCommerce allows us to filter and enable/disable any form.

Before WooCommerce returns the value of these form fields, it puts the fields through a filter.

And, this is where our code comes into play. 😉

To remove desired fields from the form, open the functions.php of your child theme and add the code below.

add_filter( 'woocommerce_checkout_fields' , 'worda_override_checkout_fields' );

function worda_override_checkout_fields( $fields ) {
     unset($fields['billing']['billing_city']);
     unset($fields['billing']['billing_postcode']);
     unset($fields['billing']['billing_company']);
     unset($fields['shipping']['shipping_city']);
     unset($fields['shipping']['shipping_postcode']);
     unset($fields['shipping']['shipping_address_2']);
     unset($fields['shipping']['shipping_company']);
     
     return $fields;
}

You should notice that we use the “unset” to remove and deregister the fields from the pages with the ordering form.

Basically, there are 4 groups of form fields used in WooCommerce checkout and order pages. Those are Billing, Shipping, Account, and Order.

As for our example code above, the first 3 options are assigned as the “billing” group. It will remove the field from the billing part of the form. The second 4 lines demonstrate options to unset the form field, are under the “shipping” group.

Now, just replace the example code with unset options values to some of the form values you really want to remove. You can refer to the list of all form field values below.

List of fields in WooCommerce checkout & order forms

You can see the entire list of fields in the array passed to “woocommerce_checkout_fields”:

  • Billing
    • billing_first_name
    • billing_last_name
    • billing_company
    • billing_address_1
    • billing_address_2
    • billing_city
    • billing_postcode
    • billing_country
    • billing_state
    • billing_email
    • billing_phone
  • Shipping
    • shipping_first_name
    • shipping_last_name
    • shipping_company
    • shipping_address_1
    • shipping_address_2
    • shipping_city
    • shipping_postcode
    • shipping_country
    • shipping_state
  • Account
    • account_username
    • account_password
    • account_password-2
  • Order
    • order_comments

You can use any of the form elements’ names and remove them from the forms in the desired locations from the above list.

Also, if you need to limit your order to a certain city and delivery zones, check out this great article on How to add city and Districts for shipping zones in WooCommerce.

Conclusion

It should be easy to figure out which field from the list you want to remove. If you have any issues, feel free to drop me a line in the comments.

Davor Veselinovic
Davor Veselinovic

Website owner and IT Professional writing on all kind of web development topics. Considering my developer background I usually write snippets, tutorials and how-to guides.

Leave a Reply

Your email address will not be published. Required fields are marked *