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,
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 ,
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.