Accepting credit cards, warehouses, and shipping and fulfilling orders
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?
Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024Digital marketers and app developers have tracked activity in apps and websites for yea...
By Ollie Mar 13, 2024February was an exciting month with Shopify Editions, informative webinars, and more! F...
By JasonH Mar 7, 2024