Created
January 22, 2017 01:57
-
-
Save seedcms/9a017df7307fb69a72e339d2551160c6 to your computer and use it in GitHub Desktop.
10% off 3 items / 15% off 7 items via product type
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
item = 0 | |
Input.cart.line_items.each do |line_item| | |
product = line_item.variant.product | |
if product.product_type == "Underwear" | |
item+=line_item.quantity | |
elsif product.product_type == "Socks" | |
item+=line_item.quantity | |
end | |
end | |
Input.cart.line_items.each do |line_item| | |
product = line_item.variant.product | |
if product.product_type == "Underwear" || product.product_type == "Socks" | |
if item > 2 && item < 7 | |
line_item.change_line_price(line_item.line_price * 0.90, message: "Customers with 3+ pairs of shoes or socks receive 10% off each pair") | |
elsif item > 6 | |
line_item.change_line_price(line_item.line_price * 0.85, message: "Customers with 7+ pairs of shoes or socks receive 15% off each pair.") | |
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