Sorting Shipping Rates Low To High On WooCommerce

For any websites that need/request shipping rates to display from lowest to highest, just add this snippet of code below.

After that, you should be good to go!

add_filter( 'woocommerce_package_rates' , 'businessbloomer_sort_shipping_methods', 10, 2 );
function businessbloomer_sort_shipping_methods( $rates, $package ) {
    if ( !$rates ) return;
    $tmp = Array();
    foreach( $rates as $ma ) {
        $tmp[] = $ma->cost;
    array_multisort( $tmp, $rates );
    return $rates;

Need help?

Tell us about your project!

This field is for validation purposes and should be left unchanged.

Related articles