Created
February 4, 2017 06:16
-
-
Save seedcms/399cf42e90194e9a1d37bbcf2f5daa93 to your computer and use it in GitHub Desktop.
XYZ Script
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
money = Money.zero | |
Input.cart.line_items.each do |line_item| | |
cart = Input.cart | |
product = line_item.variant.product | |
money+=line_item.line_price | |
if cart.discount_code.code == "XYZ" | |
if product.tags.include?('shoes') | |
money-=line_item.line_price | |
end | |
end | |
end | |
Input.cart.line_items.each do |line_item| | |
puts money | |
cart = Input.cart | |
product = line_item.variant.product | |
if cart.discount_code.code == "XYZ" | |
unless product.tags.include?('shoes') | |
if money >= Money.new(cents: 3000) | |
line_item.change_line_price(line_item.line_price * 0.90, message: "XYZ") | |
end | |
end | |
end | |
end | |
Output.cart = Input.cart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment