Skip to content

Instantly share code, notes, and snippets.

@kmeister2000
Created November 9, 2018 18:46
Show Gist options
  • Save kmeister2000/28634969b530c728f253af0503e1c2cb to your computer and use it in GitHub Desktop.
Save kmeister2000/28634969b530c728f253af0503e1c2cb to your computer and use it in GitHub Desktop.
Add a 10% discount if the customer is tagged as 'vip'
is_vip = false
Input.customer.tags.each {|tag| is_vip = true if tag.name == "vip"}
return unless is_vip
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.price * .9, message: "VIP Discount Applied!")
end
Output.cart = Input.cart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment