Skip to content

Instantly share code, notes, and snippets.

@seedcms
Created February 4, 2017 05:36
Show Gist options
  • Save seedcms/10e88e7667b2d78f5e061aa0f0fb7aee to your computer and use it in GitHub Desktop.
Save seedcms/10e88e7667b2d78f5e061aa0f0fb7aee to your computer and use it in GitHub Desktop.
Multiple Levels 1
Input.cart.line_items.each do |line_item|
customer = Input.cart.customer
product = line_item.variant.product
if product.tags.include?('discount')
if customer.tags.include?("Industry")
line_item.change_line_price(line_item.line_price * 0.40, message: "Industry Customer")
elsif customer.tags.include?("Pro")
line_item.change_line_price(line_item.line_price * 0.50, message: "Pro Customer")
elsif customer.tags.include?("Tier2")
line_item.change_line_price(line_item.line_price * 0.70, message: "Tier2 Customer")
elsif customer.tags.include?("Tier3")
line_item.change_line_price(line_item.line_price * 0.50, message: "Tier3 Customer")
end
end
end
Output.cart = Input.cart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment