Created
January 19, 2017 21:57
-
-
Save seedcms/800e4dd74cd2c1b01accb58535c8cfd9 to your computer and use it in GitHub Desktop.
Take a percentage off any products with a specific tag.
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
@percent = Decimal.new(40) / 100.0 | |
Input.cart.line_items.each do |line_item| | |
product = line_item.variant.product | |
next if product.gift_card? | |
next unless product.tags.include?('hugesale') | |
line_discount = line_item.line_price * @percent | |
line_item.change_line_price(line_item.line_price - line_discount, message: "HUGESALE! 40% off this item!") | |
end | |
Output.cart = Input.cart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment