I cannot seem to set the default field for the country field for Woocommerce at checkout.

I am using this code from here, placing it into my functions.php of the child theme.

  add_filter( 'woocommerce_checkout_fields' , 'default_values_checkout_fields' );
  function default_values_checkout_fields( $fields ) {
    // You can use this for postcode, address, company, first name, last name and such. 
    $fields['billing']['billing_country']['default'] = 'GB';
    $fields['shipping']['shipping_country']['default'] = 'GB';

    return $fields;

I have tried "UK" and "United Kingdom (UK)" as values as well.


Try this code to change the default billing country on the checkout page.

add_filter( 'default_checkout_billing_country', 'change_default_checkout_country' );

function change_default_checkout_country() {
  return 'US'; // country code

To change default shipping country on the checkout page

function change_set_checkout_field_input_value_default($fields) {
$fields['shipping']['shipping_country']['default'] = 'Australia';
return $fields;

add_filter( 'woocommerce_checkout_fields', 'change_set_checkout_field_input_value_default' );

Not the answer you're looking for? Browse other questions tagged or ask your own question.