Default woocommerce shipping method

Hi, I’d like to change default woocommerce shipping method. I’ve tried different codes form internet bu nothing works for me. Do you have any working method?

Ok. I’ve found working method. Remember to clear the cookies while testing this:

function reset_default_shipping_method( $method, $available_methods ) {
    $default_method = 'flexible_shipping_9_1'; //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', 'reset_default_shipping_method', 10, 2);
2 Likes