Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save peterberwind/ea041e4176c1dadc3d1e519114cd1983 to your computer and use it in GitHub Desktop.
Save peterberwind/ea041e4176c1dadc3d1e519114cd1983 to your computer and use it in GitHub Desktop.
X% off all products with Y tag
@percent = Decimal.new(25) / 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?('myTag')
line_discount = line_item.line_price * @percent
line_item.change_line_price(line_item.line_price - line_discount, message: "25% Off")
end
Output.cart = Input.cart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment