I'm looking for an app or a way to do this:
Every time a customer purchases, it creates a code or you can manually upload codes, and then a customer will receive the code to enter for a chance to win a free gift. It would be set at a specific % for a chance to win
Also I'm looking for an app that can create a stamp style loyalty program, so if they login and enter the code, it will register as one stamp and if they get 5 stamps (5 orders), they get a free gift as well.
So they can use the code to hopefully win a gift right away, but then also will add to their 5 stamps they need to get a free gift.
Does anyone know an app that can do this? or how else I could go about it?
Take a look at Raffle app: https://apps.shopify.com/raffle
I think it relatively closely matches your requirements. For anything specific you probably looking for a custom app.