Created
November 9, 2018 18:46
-
-
Save kmeister2000/28634969b530c728f253af0503e1c2cb to your computer and use it in GitHub Desktop.
Add a 10% discount if the customer is tagged as 'vip'
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
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