Created
February 17, 2017 19:25
-
-
Save anonymous/25affb23a39a845a21ed7a9c2fe26f0d to your computer and use it in GitHub Desktop.
OnlyGrowth.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MINIMUM_ORDER_AMOUNT = 50 #dollars required in cart to get discount | |
MESSAGE = "Minimum Order $50 Promotion" #promotional message | |
if !Input.cart.shipping_address.province.include?("Hawaii") && !Input.cart.shipping_address.province.include?("Alaska") | |
if Input.cart.subtotal_price_was > (Money.new(cents:100) * MINIMUM_ORDER_AMOUNT) | |
Input.shipping_rates.each do |shipping_rate| | |
if shipping_rate.name.include?("2 Day Ground") | |
shipping_rate.change_name("Free 2 Day Ground", { message: "" }) | |
shipping_rate.apply_discount(shipping_rate.price, message: MESSAGE) | |
end | |
end | |
end | |
end | |
Output.shipping_rates = Input.shipping_rates |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have the following errors when I copy-paste this script in the Shopify Script Editor:
How can I improve this script to have no errors?