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
2m ago Learn the essential skills to navigate the Shopify admin with confidence. T...
By Shopify Feb 12, 2025Learn how to expand your operations internationally with Shopify Academy’s learning path...
By Shopify Feb 4, 2025Hey Community, happy February! Looking back to January, we kicked off the year with 8....
By JasonH Feb 3, 2025