You are here

function commerce_shipping_sort_rates in Commerce Shipping 7.2

Sorts shipping rates.

Sort shipping rates based on the weight property added to shipping line items in an order's data array.

1 string reference to 'commerce_shipping_sort_rates'
commerce_shipping_collect_rates in ./commerce_shipping.module
Collects available shipping rates for an order.

File

./commerce_shipping.module, line 517
Defines a system for calculating shipping costs associated with an order.

Code

function commerce_shipping_sort_rates($a, $b) {
  $a_weight = isset($a->weight) ? $a->weight : 0;
  $b_weight = isset($b->weight) ? $b->weight : 0;
  if ($a_weight == $b_weight) {
    return 0;
  }
  return $a_weight < $b_weight ? -1 : 1;
}