WooCommerce Shipping – Set a particular service as default in Cart

In this article, we will guide you how to set a particular shipping service as the default shipping method when using the WooCommerce FedEx Shipping Plugin with Print Label.

Often WooCommerce shop-owners want to provide a default shipping method to their customers. For example, Roger sells bicycles and use WooCommerce FedEx Shipping Plugin. He prefers “FedEx Ground” as ground services have a wider reach compared to any other shipping methods. But he cannot show only ground service as there may be customers who sometimes want other options (say a priority overnight delivery).

How to set a particular shipping service as default in WooCommerce shipping?

It is easy! Now, you can easily do that using the below code snippet.
Just copy the code and paste it in Appearance –>Editor –> functions.php.

function reset_default_shipping_method( $method, $available_methods ) {
	$default_method = 'wf_shipping_ups:03'; // Provide the Shipping Method Value which will selected by default 
	if(  array_key_exists($default_method, $available_methods ) && array_key_exists($method, $available_methods ) )
		return $default_method; 
		return $method; 
add_filter('woocommerce_shipping_chosen_method', 'reset_default_shipping_method', 10, 2);

As per the above snippet, FedEx Ground should be the default shipping method. Before implementing our solution, “FedEx First Overnight” was shown as default.

fedex overnight

After implementation of this solution, “FedEx Ground” is being shown as default!

fedex shipping

How to set the cheapest shipping method as default?

Now, what if you want to set the cheapest service as the default one? We have the perfect solution for that too! You just need to use the below snippet:

function wf_default_shipping_method( $method ) {
        $the_cheapest_cost = 1000000;
	$packages = WC()->shipping()->get_packages()[0]['rates'];

	foreach ( array_keys( $packages ) as $key ) {
        if ( ( $packages[$key]->cost > 0 ) && ( $packages[$key]->cost < $the_cheapest_cost ) ) {
            $the_cheapest_cost = $packages[$key]->cost;
            $method_id = $packages[$key]->id;

	return $method_id;
add_filter( 'woocommerce_shipping_chosen_method', 'wf_default_shipping_method', 10 );

Consider that Roger wants to introduce a flat rate for customers from Georgia as his warehouse is located at Atlanta. So it becomes easy and cheap for him to ship goods to any location in Georgia. As a consequence of this, he decides to show the default shipping method as the cheapest one (the Flat Rate service in this case).

After incorporating the above solution, the plugin simply selects the flat rate by default!

cart page
Last Updated On July 22, 2022

3 thoughts on “WooCommerce Shipping – Set a particular service as default in Cart

  1. chad4
    Chadwick says:

    How do I set UPS Ground as the default?

    Local pick-up is showing first on the list and I keep having customers accidentally choosing it.

    • Anindo
      Anindo C says:

      Hi Chadwick,

      You can automatically allow the plugin to select the shipping method which you intend to. Here is a code snippet which will by default put the selection for that shipping method. You just need to provide the value of the shipping method in the snippet and then paste it in Appearance –> Editor –> functions.php.

      Hope this helps!

    • chad4
      Chadwick says:


      I tried chaning “Fedex” to “UPS” in the code above but it did not work. Can you tell me what the specific code would be to make UPS Ground the default selection.

      Many Thanks!

Comments are closed.