Create Topic

WP Tavern Forums Create Topic

Create New Topic

Michael

Here’s the one I have to arrange rates in order of lowest to highest price:

/*SORT SHIPPING COSTS LO TO HI*/
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;
}






Newsletter

Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.