Last active
March 13, 2020 10:33
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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