Skip to main content

Sort Drupal Commerce Shipping Services

Published on

If you are using Drupal Commerce and are allowing customer's two or more shipping services you'll notice that the order may not make sense. By default the shipping services are displayed by how they're output in grouping of shipping provider then some other sorting that isn't cost based. There is a hook within Commerce Shipping that allows reordering of all shipping services.

 

We can call hook_commerce_shipping_service_rate_options_alter(), which is a doozy of a hook name. Utilizing this hook, however, we can manipulate the order of all shipping services. I've provided a Gist which has two files, incase you wanted to utilize it as a module versus dropping it into template.php of your theme.