Skip to content

Instantly share code, notes, and snippets.

@conschneider
Last active October 23, 2018 08:34
Show Gist options
  • Save conschneider/366bbe4508715894b3d5e1f16200d917 to your computer and use it in GitHub Desktop.
Save conschneider/366bbe4508715894b3d5e1f16200d917 to your computer and use it in GitHub Desktop.
Makes the state field in WooCommerce checkout always required.
/* https://www.mootpoint.org/blog/woocommerce-make-uk-county-field-required/ for an excellent description on why this filter. */
add_filter( 'woocommerce_get_country_locale', 'mp_change_locale_field_defaults');
function mp_change_locale_field_defaults($countries) {
//swap 'RO' for your country ID.
$countries['RO']['state']['required'] = true;
//set custom field label
$countries['RO']['state']['label'] = '';
return $countries;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment