There are a lot of people asking for more information on how to discount returning customers, so I wrote this script to give a discount based on the number of orders the customer has placed. This script is for people who have placed over 2 orders, and a platinum discount if you've placed over 5, but can be modified for any amount.
customer = Input.cart.customer
discount = 0
message = ""
if customer
if customer.orders_count > 2
discount = 1000
message = "VIP Customer - $10 off"
end
if customer.orders_count > 5
discount = 2000
message = "Platinum Customer - $20 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
If you have any other scripts you're wondering about just ask in the comments.
