Accepting credit cards, warehouses, and shipping and fulfilling orders
To continue receiving payouts, you need to secure your account by turning on two-step authentication. If two-step authentication is not turned on your payouts will be paused. Learn more
Hello friends,
Just started playing with Shopify+ Scripts and loving it so far!
Re-ordered our shipping options so they are logically grouped together, instead of ordered via price.
However, we work with multiple shipping zones, and from my understanding, the provided script only allows to re-order one of them at a time.
Is there a certain code we can add to the beginning of our Script or something so that we can order multiple shipping zones independently?
# ================================ Customizable Settings ================================
# ================================================================
# The order in which you would like your rates to display
# ================================================================
DESIRED_RATE_ORDER = [
"Shipping option 1", "Shipping option 2", "Shipping option 3", "Shipping option 4",
]
# ================================ Script Code (do not edit) ================================
# ================================================================
# ReorderRatesCampaign
#
# Reorders rates into the entered order
# ================================================================
class ReorderRatesCampaign
def initialize(desired_order)
@desired_order = desired_order.map { |item| item.downcase.strip }
end
def run(cart, shipping_rates)
shipping_rates.sort_by! { |rate| @desired_order.index(rate.name.downcase.strip) || Float::INFINITY }
end
end
CAMPAIGNS = [
ReorderRatesCampaign.new(DESIRED_RATE_ORDER),
]
CAMPAIGNS.each do |campaign|
campaign.run(Input.cart, Input.shipping_rates)
end
Output.shipping_rates = Input.shipping_rates
Suggestions welcome!
Anyone?
User | RANK |
---|---|
6 | |
5 | |
4 | |
4 | |
3 |
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022