Last active
March 13, 2020 10:22
-
-
Save xadapter/b02265fdf807e0d81f74fe9dccf7de0d to your computer and use it in GitHub Desktop.
Snippet to change the default country and state on the WooCommerce checkout page. 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
// Change the default country and state on checkout page. | |
// This works for a new session. | |
add_filter( 'default_checkout_country', 'xa_set_default_checkout_country' ); | |
add_filter( 'default_checkout_state', 'xa_set_default_checkout_state' ); | |
function xa_set_default_checkout_country() { | |
// Returns empty country by default. | |
// return null; | |
// Returns US as default country. | |
return 'US'; | |
} | |
function xa_set_default_checkout_state() { | |
// Returns empty state by default. | |
// return null; | |
// Returns California as default state. | |
return 'CA'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment