Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save dylanjhunt/6046d7f20dc262a01a9c7b663e641765 to your computer and use it in GitHub Desktop.
Save dylanjhunt/6046d7f20dc262a01a9c7b663e641765 to your computer and use it in GitHub Desktop.
This will give a $5 discount on any product that has the tag identified in this Gist with MyTag
Input.cart.line_items.each do |line_item|
product = line_item.variant.product
next if product.gift_card?
next unless product.tags.include?('MyTag')
line_item.change_line_price(line_item.line_price - Money.new(cents: 500), message: "$5 Off")
end
Output.cart = Input.cart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment