Skip to content

Instantly share code, notes, and snippets.

@tom-it
Created December 11, 2018 22:24
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tom-it/51f63f2937faed808f69985ec742bdac to your computer and use it in GitHub Desktop.
Save tom-it/51f63f2937faed808f69985ec742bdac to your computer and use it in GitHub Desktop.
Shopify Reorder Shipping rates

This shopify script is used on shopify+ Stores to reorder the shippingrates. (Great for using in combination with your custom shipping carrier service) (the first character of the shipping name should be a number (0..9)) then the script will reorder accordingly, and remove the first character

Input.shipping_rates.each do |shipping_rate|
next unless shipping_rate.source != "Postnl Pakjegemak afhaalpunten"
shipping_rate.change_name("0" + shipping_rate.name, message: "")
end
Input.shipping_rates.sort_by!(&:name)
Input.shipping_rates.each do |shipping_rate|
shipping_rate.change_name(shipping_rate.name[1..-1], message: "")
end
Output.shipping_rates = Input.shipping_rates
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment