Skip to content

Instantly share code, notes, and snippets.

@seedcms
Created February 4, 2017 06:16
Show Gist options
  • Save seedcms/399cf42e90194e9a1d37bbcf2f5daa93 to your computer and use it in GitHub Desktop.
Save seedcms/399cf42e90194e9a1d37bbcf2f5daa93 to your computer and use it in GitHub Desktop.
XYZ Script
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