Personalized checkout and custom promotions with Shopify Scripts
Hi,
This is what I want to achieve:
The problem I'm finding:
This is my code:
discount_applies = Input.cart.discount_code && Input.cart.discount_code.code == "FREEDOM"
# Create array of shipping methods
desired_order = ["Next Working Day"]
if discount_applies
# Reorder the payment gateway methods to the order of desired_order.
Output.shipping_rates = Input.shipping_rates.sort_by do |shipping_rate|
desired_order.index(shipping_rate.name) || desired_order.length
end
else
Output.shipping_rates = Input.shipping_rates
end
See attached image to see the results when adding the discount code
Thanks,
N
User | RANK |
---|---|
4 | |
3 | |
2 | |
1 | |
1 |
On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023The year-end shopping season is just around the corner. Is a flash sale on your radar? Are...
By Jasonh Nov 6, 2023