I found a way on GitHub to remove the state/province field 'state' in woocommerce's checkout page. https://gist.github.com/jeherve/a07ccf469025d722ad7016f6953146fd (Thanks Jeremy Herve!)
function jeherve_remove_state_field( $fields ) { unset( $fields['state'] ); return $fields; } add_filter( 'woocommerce_default_address_fields', 'jeherve_remove_state_field' );
My question is: Is it safe to remove the state/province field, or is it already set in woocommerce that certain countries require that field?
Do I need to first set the state/province field for each country to 'optional'?
I'm concerned that by removing the state/province field, the checkout page won't work properly for certain countries because they require that field.
I don't need to set the state/province field to $address_fields['state'][required]=false like I do with the zip code field, right?
add_filter( 'woocommerce_default_address_fields' , 'override_postcode_validation' ); function override_postcode_validation( $address_fields ) { $address_fields['postcode']['required'] = false; return $address_fields; }
Thank you very much for your help. Thanks.
You can use the same code to remove the state/province field from the checkout form.
This will not cause any problems with the checkout process. You don't need to set this for all countries.
1 - Postal code still needs to be filled in to continue.
2 - Payment gateways that require a state/province field cannot be used for checkout.