WooCommerce allows anyone to sort their shipping rates through the Shipping Zones settings. Unfortunately its not always possible to all the shipping rates as some may not be available directly from within the shipping zones. For example, multiple shipping rates from live carrier quotes can be retrieved through an API, and usually are setup with only one shipping rate.
In this post I’ll show how you can easily sort the shipping rates by their cost from low to high and high to low with a small code snippet.
When deciding how you want to sort your shipping rates, keep in mind that WooCommerce uses the shipping option at the top as the default selected shipping rate.
Sorting Shipping Rates from Low to High
The following code snippet will automatically sort all the shipping rates from low to high.
With this small variation on that script it will only sort the shipping rates from a specific shipping method (say UPS). This way you can keep your custom sorting of the available rates in the shipping zones section, but still sort the shipping carrier rates.
Sorting Shipping Rates from High to Low
This snippet sorts all the shipping rates from high to low cost.
Lastly same as the low to high option this will sort only the shipping rates of the UPS shipping method from high to low.