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?
Are you ready to take your business to the next level? Look no further than the latest ...
By SarahF_Shopify Apr 15, 2024We’re keeping the ball rolling to make sure you’re always ahead of the game. So buckle ...
By JasonH Apr 8, 2024Portrait of Stephen positioned next to an image of planet Earth, with the Stephen's World ...
By JasonH Mar 18, 2024