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
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024