Code Snippet to Rearrange WooCommerce Shipping Methods in the Cart

This article will help you re-arrange different shipping methods on your website’s cart page. If you are using any of the following plugins on your WooCommerce store, this article will surely help you.

All you need to do is paste this Custom Code into your Appearance >> Editor >> functions.php file.


No more code snippets and struggling with PHP code to configure your business case!

To maintain compatibility with the latest WordPress version(s) & ease of use we no longer recommend & support usage of the code snippets.

This features is available to as a Customizable Addon with one-time fee.

To get the paid addon, please reach out to our customer support team.


As you can see in the code snippet, the arrangement of shipping methods are in the order:
1. UPS
2. USPS
3. Free Shipping
4. Local Pickup
5. Flat Rate
So the cart page should display prices in the above order. This can be verified from the screenshot below :

calculated WooCommerce shipping rates

6 thoughts on “Code Snippet to Rearrange WooCommerce Shipping Methods in the Cart

  1. admin223
    admin223 says:

    Hi. I am using the above code to sort the shipping methods used on a pet supplier e-commerce site.

    One shipping option we offer is “cage kit shipping” for larger cage orders, and this is a shipping method we have through the plugin Advanced WooCommerce Shipping.

    As you can see from this screenshot (https://i.imgur.com/CZOal1s.jpg) I have done what you have indicated, and found the value of the custom shipping option to be “315”. So I have altered the code to show as follows:

    ‘315’ => array(),
    ‘wf_shipping_ups’ => array(),
    ‘wf_shipping_usps’ => array(),
    ‘free_shipping’ => array(),
    ‘local_pickup’ => array(),
    ‘legacy_flat_rate’ => array(),

    The order now displays correctly…however if I go to select that shipping method, it does NOT stay selected and does NOT add the the cage kit shipping cost to the order.

    I know the problem is coming from this code snippet for when I comment it out, the shipping method is able to be selected and adds the shipping cost to the total amount.

    Do you have any idea what the issue might be? If you want to see the issue first hand, visit my site, add a cage kit to your order and then go to the checkout page and input a fake address and try to choose the cage kit shipping method.

    Thank you in advance for your help!

  2. Donald
    Donald says:

    I’m going to enter a ticket on this, but how does one find the name of other shipping methods used to be able to put them in order? I’m using the very popular Table Rate Shipping plugin, but it’s not clear to me how to be able to use the snippet to arrange that amongst the other shipping options.

    All of this would be unnecessary if this were just a shipping option that could be assigned to zones, as is standard.

    • PluginHive Editorial Team
      PluginHive Editorial Team says:

      Hi Donald,

      To know the shipping method, kindly go to the cart page, right click on the option and then click on inspect. You will get the “value” field in developer tools which you can then put in the snippet. Regarding shipping zones compatibility, we understand your point.

      However, Shipping Zone is very help full when you configure Shipping options like Free or Flat rate shipping for different zones.
      Using Shipping zone is overkill for a complete shipping solution provided by us. As you will end up configuring the same settings under multiple zones.
      It will be great if you can let us know your business requirement we will help you find an apt solution.

    • PluginHive Editorial Team
      PluginHive Editorial Team says:

      Hi Marc,

      We do have a code snippet available for this. Here it is.

      If you face any problem with that snippet, you can approach our support team so that they will be able to fix your problem. Let us know if you have any queries.

Leave a Reply