Created
February 15, 2017 15:09
-
-
Save dylanjhunt/d0de3441aed9b5e05d83abbd23fdd16a to your computer and use it in GitHub Desktop.
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
min_discount_order_amount = Money.new(cents:100) * 50 | |
total = Input.cart.subtotal_price_was | |
discount = if total > min_discount_order_amount | |
0.1 | |
else | |
0 | |
end | |
message = "10% off shipping if order is over $50" | |
Input.shipping_rates.each do |shipping_rate| | |
next unless shipping_rate.source == "shopify" | |
shipping_rate.apply_discount(shipping_rate.price * discount, message: message) | |
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