WooCommerce

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!

  • Date Format: MM slash DD slash YYYY
  • This field is for validation purposes and should be left unchanged.
Previous Post
Senator Akshar Visits FreshySites
Next Post
WooCommerce Sidebar Category Toggles

Related Articles

Menu
Google Rating
5.0
Based on 56 reviews
×
Get a Quote