Last active
November 9, 2018 18:31
-
-
Save kmeister2000/3137ebbe6a12c9eb535b0ba23c8bc6e4 to your computer and use it in GitHub Desktop.
Apply free shipping if the address is in the US and the cart total is over $100
This file contains hidden or 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
# Free US shipping when cart total exceeds $100 | |
free_shipping_threshold = 100 | |
if Input.cart.total >= Money.new(cents: (100 * free_shipping_threshold)) && Input.cart.shipping_address.country.include?("United States") | |
Input.shipping_rates.each do |shipping_rate| | |
next unless shipping_rate.source == "shopify" | |
shipping_rate.apply_discount(shipping_rate.price, message: "Free shipping") | |
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