Website Building » WooCommerce » How Do I Delete a Field in WooCommerce Checkout?

How Do I Delete a Field in WooCommerce Checkout?

Last updated on January 12, 2023 @ 1:45 pm

If you’re running a WooCommerce store, there may come a time when you need to remove a field from the checkout page. Maybe you’re no longer collecting a certain piece of information, or you want to streamline the checkout process by removing unnecessary fields.

Whatever the reason, removing a field from WooCommerce checkout is relatively easy to do.

The first thing you’ll need to do is edit your functions.php file. You can access this file via FTP or through your WordPress hosting control panel (cPanel, Plesk, etc. ).

PRO TIP: If you are considering deleting a field in WooCommerce Checkout, please be aware that this may cause unexpected errors and could break your checkout process. If you are unsure about how to delete a field, please contact a WooCommerce expert for assistance.

Once you have functions.php open, look for the following code:

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

This code will remove all of the default billing fields from WooCommerce checkout. If you only want to remove certain fields, simply delete the lines of code for the fields you want to keep. For example, if you only wanted to remove the last name and company fields, your code would look like this:

function WooCommerce_checkout_fields( $fields ) {
//Remove Billing Fields
unset( $fields['billing']['billing_first_name'] );
unset( $fields['billing']['billing Shipping Address Fields'] );

unset( $fields['shipping']['shipping_first'] );
Drew Clemente

Drew Clemente

Devops & Sysadmin engineer. I basically build infrastructure online.