• Resolved ehmarketing

    (@ehmarketing)


    We ship to a number of countries but 95% of time it is to the UK. How can I make the UK appear at the top, or otherwise set the order of my countries list?

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hello @ehmarketing ,

    You can also achieve this by set default billing country as UK.

    You can achieve that by using this snippet,

    
    add_filter( 'default_checkout_billing_country', 'ced_change_default_checkout_country' );
    
    function ced_change_default_checkout_country() {
      return 'GB'; // country code for United Kingdom (UK)
    }

    Thanks,

    Thread Starter ehmarketing

    (@ehmarketing)

    That’s fantastic, thank you! Is there a way to also apply this to the shipping calculator in the cart page too?

    Hello,

    Yes you can try this,

    function ced_default_shipping_method( $method, $available_methods ) {
        $default_method = 'wf_fedex_woocommerce_shipping:FEDEX_GROUND'; //provide here the service name which will selected default
        if( array_key_exists($method, $available_methods ) )
            return $default_method;
        else
            return $method;
    }
    
    add_filter('woocommerce_shipping_chosen_method', 'ced_default_shipping_method', 10, 2);

    I am taking FEDEX_GROUND as example.

    Thanks ,

    Thread Starter ehmarketing

    (@ehmarketing)

    Thanks for that! I also found the below, if it helps anyone

    
    add_action('woocommerce_add_to_cart' , 'set_country_befor_cart_page'); 
    
    function set_country_befor_cart_page(){
        //WC()->customer->set_country('US'); //set country code of default country
        //WC()->customer->set_shipping_country('US');
    
        WC()->customer->set_country(''); //reset default country
        WC()->customer->set_shipping_country('');
    }
    
    Plugin Support Yuki K a11n.

    (@yukikatayama)

    Automattic Happiness Engineer

    Thanks @cedcommerce for providing that code, and to @ehmarketing for finding alternative as well! I’ll close this thread.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Reorder countries in checkout’ is closed to new replies.