Shopify Carrier Service reorder shipping options

If you use the Shopify API Carrier Service to populate your shipping by realtime to add pickup-points and other custom shipping options, you might want to re-order your shipping options in a certain way.

I wanted to have ‘normal’ shipping options up top, and pickup points below, ordered by distance, but at this point shopify does not have a sort_order property that you can send with your response to give a certain order to your shipping options.

Luckily with shopify scripts we are able to get the right sorting, in your API code you will need to prefix a number to all your shipping names, the shopify script will sort by the first character in the name, and remove the first character before the option gets displayed.
I have a free shipping option within shopify too, which I added a 0 for in it’s name(e.g. 0Free Shipping) so it wil be always displayed on top.


The shopify script (you need to add the shopify script editor from the app store):


 Now I can display the rates in the order I like.