Search

Generic selectors
Exact matches only
Search in title
Search in content

WooCommerce default country on the Checkout page

  • Share this:

    Looking to set a WooCommerce default country on the Checkout page? I’ve got the same question while working on WooCommerce driven website which primarily provides shipping locally, I was questioning how to make a predefined selection for the country, so that customers won’t need to annoyingly scroll down to the right country or even predefined the country selection and hide the country selection on the checkout page at all. This basically can be considered as WooCommerce checkout field remove.

    So basically there are two major options to do this.

    Option #1 Predefine the country in selection on the WooCommerce Checkout page

    If you’d like to offer a predefined selection to the customer and fill it with some particular country, refer to the code below, which you should insert into fucntions.php of your active theme.

    Here is the code:

    function change_default_checkout_country() {
        return 'UA'; // country code
    }
    
    add_filter( 'default_checkout_billing_country', 'change_default_checkout_country' );

    In the above example, I wanted to predefined Ukraine as the default shipping destination, so I’ve placed a country code of Ukraine that is “UA”. If you need the United States, just place “US”, for the United Kingdom the code is “UK” etc.

    Option #2 Remove the country selector from the WooCommerce Checkout page

    If you’d like the country selector on the checkout page at all, consider using the following code:

    function remove_country_fields( $fields ) {
    unset($fields['billing']['billing_country']);
    return $fields;
    } 
    
    add_filter('woocommerce_checkout_fields','remove_country_fields');
    

    Basically, that’s it. If you know other options or have better ideas on how to get this implemented, please share your thought in the comments.

    Tags: Checkout
    Leave a Reply

    Alex Kostritsa

    About author
    My name is Alex. For more than 10 last years I've been worked in the role of Project Manager in an Agile environment. I have experience working with different business domains including e-commerce, social networks, and gambling. As a Software Manager, I try to keep myself tuned and continue self-development.
    View all posts (16)
    • Odessa, Ukraine