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_namebilling_last_namebilling_companybilling_address_1billing_address_2billing_citybilling_postcodebilling_countrybilling_statebilling_emailbilling_phone
- Shipping
shipping_first_nameshipping_last_nameshipping_companyshipping_address_1shipping_address_2shipping_cityshipping_postcodeshipping_countryshipping_state
- Account
account_usernameaccount_passwordaccount_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.




