To hide state/country field in the checkout form in WooCommerce, you can use the following steps:
- Install and activate the “Code Snippets” plugin. This plugin allows you to add custom code snippets to your site without modifying the theme files.
- Go to Snippets > Add New in your WordPress dashboard.
- Add a title for your snippet, such as “Hide state field in checkout form”.
- In the “Code” field, add the following code snippet:
Snippets to Hide state/country field in the checkout form in Woocommerce
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_state']);
return $fields;
}
Click the “Save Changes and Activate” button to add the snippet to your site.
Note that these code snippets will only work if the “Code Snippets” plugin is installed and activated. If you’re facing error with this script then, feel free to contact us.