Skip to content

Instantly share code, notes, and snippets.

@xadapter
Last active March 13, 2020 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xadapter/e446508c1bcefa2cbd1e6a0a7f5a36a2 to your computer and use it in GitHub Desktop.
Save xadapter/e446508c1bcefa2cbd1e6a0a7f5a36a2 to your computer and use it in GitHub Desktop.
Snippet to enable the shipping state field for specific countries during WooCommerce checkout process. Supports PluginHive Shipping Plugins: https://www.pluginhive.com/product-category/woocommerce-plugin/woocommerce-shipping/
function xa_filter_woocommerce_states( $states ) {
unset( $states['AF'] );
var_dump( $states ) ;
return $states;
};
add_filter( 'woocommerce_states', 'xa_filter_woocommerce_states', 10, 1 );
function xa_filter_woocommerce_get_country_locale( $locale ) {
$locale['AF']['state']['required'] = true;
return $locale;
};
add_filter( 'woocommerce_get_country_locale', 'xa_filter_woocommerce_get_country_locale', 10, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment