How to remove the state field in the WooCommerce Checkout?

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 a virtual product, you can get rid of fields like billing address or just the state field even. Here is the snippet of code which if you place in function.php will allow you to remove state field:

function remove_state_field( $fields ) {
unset( $fields[‘state’] );
return $fields;
}
add_filter( ‘woocommerce_default_address_fields’, ‘remove_state_field’ );

In-case if you want to remove all the checkout fields from WooCommerce, copy and paste the below code:

/* WooCommerce: The Code Below Removes Checkout Fields */
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;
}