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?
We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023