Skip to content

Instantly share code, notes, and snippets.

@seedcms
Created February 4, 2017 05:45
Show Gist options
  • Save seedcms/f32baf732d32d58ed19a0018fa196c8d to your computer and use it in GitHub Desktop.
Save seedcms/f32baf732d32d58ed19a0018fa196c8d to your computer and use it in GitHub Desktop.
Coupon "Over"
money = Money.zero
Input.cart.line_items.each do |line_item|
money+=line_item.line_price
end
Input.cart.line_items.each do |line_item|
puts money
cart = Input.cart
product = line_item.variant.product
if cart.discount_code.code == "OVER"
if product.id == 9284928268 && money >= Money.new(cents: 5000)
line_item.change_line_price(line_item.line_price - Money.new(cents: 1000), message: "OVER")
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