Move a country to the top of WooCommerce checkout shipping list

If you’re using WooCommerce and selling primarily to a single country, it’s nice to set a default country on the checkout page shipping drop-down. We recently had a customer ask how to move the United States to the top of the dropdown list. Here’s how you do that.

In either functions.php, or a functionality plugin, add this code:

/**
 * Change the default country on the checkout page
 */

add_filter( 'default_checkout_billing_country', 'change_default_checkout_country' );

function change_default_checkout_country() {
  return 'US'; // Put Country code here
}

Which country?

Which country?

In this case, USA!

This country!

What about a default state?

We’ve got you covered there too:

/**
 * Change the default state on the checkout page
 */

add_filter( 'default_checkout_billing_country', 'change_default_checkout_country' );
add_filter( 'default_checkout_billing_state', 'change_default_checkout_state' );
function change_default_checkout_state() {
  return 'XX'; // state code
}

Related posts

3 comments

Leave your comment