Skip to main content
← blog / drupal-commerce
Nov 10, 2013  ·  #drupal-commerce  ·  1 min read

Sort Drupal Commerce Shipping Services

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.

 

Thanks for reading

I write about Drupal, PHP, and the quiet infrastructure behind large sites — caching, config, and testing. New posts land every week or two.