Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dylanjhunt/fd5b648d298d1b9dc225b39d3138a548 to your computer and use it in GitHub Desktop.
Save dylanjhunt/fd5b648d298d1b9dc225b39d3138a548 to your computer and use it in GitHub Desktop.
More scripts available at https://dylanjh.com
customer = Input.cart.customer
discount = 0
message = ""
if customer
if customer.orders_count > 2
discount = 1000
message = "VIP Customer - $10 off"
end
if customer.orders_count > 5
discount = 2000
message = "Platinum Customer - $20 off"
end
end
puts discount
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
next if product.gift_card?
line_item.change_line_price(line_item.line_price - Money.new(cents: discount), message: message) unless discount == 0
end
Output.cart = Input.cart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment