Forked from dylanjhunt/Shopify Script - X$ off if customer has placed over Y orders
Created
April 11, 2017 16:45
-
-
Save CodeBrotha/161266b1370e11c1af00bd65749c98b6 to your computer and use it in GitHub Desktop.
This file contains 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
customer = Input.cart.customer | |
discount = 0 | |
message = "" | |
if customer | |
if customer.orders_count > 2 #number of orders placed to get the deal | |
discount = 1000 #discount amount in cents | |
message = "VIP Customer - $10 off" | |
end | |
end | |
puts discount | |
Input.cart.line_items.each do |line_item| | |
product = line_item.variant.product | |
next if product.gift_card? | |
line_item.change_line_price(line_item.line_price - Money.new(cents: discount), message: message) unless discount == 0 | |
end | |
Output.cart = Input.cart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment