WooCommerce: Set country by default in checkout page

Update (Since WooCommerce 3)

This are the woocommerce hooks and code to be used for this purpose for country (and optionally state):

add_filter( 'default_checkout_billing_country', 'change_default_checkout_country_and_state' );
add_filter( 'default_checkout_shipping_country', 'change_default_checkout_country_and_state' );
add_filter( 'default_checkout_billing_state', 'change_default_checkout_country_and_state' );
add_filter( 'default_checkout_shipping_state', 'change_default_checkout_country_and_state' );
function change_default_checkout_country_and_state( $default ) {
    return null;
}

Or even shorter:

add_filter( 'default_checkout_billing_country', '__return_null' );
add_filter( 'default_checkout_shipping_country', '__return_null' );
add_filter( 'default_checkout_billing_state', '__return_null' );
add_filter( 'default_checkout_shipping_state', '__return_null' );

Code goes in functions.php file of the active child theme (or active theme). Tested and works.

Note: default_checkout_country and default_checkout_state hooks are deprecated and replaced since WooCommerce 3

Related: WooCommerce: Set country by default in checkout page for unlogged users

Leave a Comment