How to make coupon code

Hi I am creating a page for user to type coupon code and navigate to next screen. It would be very appreciated if anyone can help me out of this.

1 Like

Can you say more about this? It’s pretty easy to use a text input component to allow the user to enter a code and then a button to navigate to a different screen. Is that all you want?

2 Likes

Hi @tatiang thanks for reply! No I want the code to be in real-time so that I can update/add/delete code whenever I want after app is published.

Also, I want to track if this code is used so that I can delete the used ones manually.

2 Likes

Hey @solsol2004 ,

Try using airtable (simplicity in editting the table wihtout need for something like an admin panel, at least in my opinion), try making an object called “codes” with whatever value you would like this code to be then after a trigger (e.g when button1 press) the app calls the list of codes you have in the database, compares the text (e.g does list App Variable Codes contain Textinput_1), and if true, then the user is granted access.

For tracking these codes usage, you may have to add a function that then finds the row number containing this code in airtable and updates a number field to its value + 1 so that you can see how many uses they’ve gotten.

I think something like that can achieve your goal, though keep in mind it is possible with firebase or even cloud vairable(s) as well, if you would rather go that route, your blocks would just have to be modified but the same goal can be achieved. I just figured that manually doing it this way may be simpler to manage without an admin panel for yourself, save for the PESKY finding row number part.

2 Likes

Hi @kareem appreciate your answer! I tried to apply the code blocks as you explained, but I’m stuck here…Could you please help to get to the next step?.. Excuse me being too beginner…

2 Likes

Hey no worries, I would suggest a few more changes. Made a qucik demo app to make sure this works. You would need to make a j loop for the specific code, then if the code matches one you set, it will get the row number and current uses number, then when they submit, it will add +1 to the uses. Firstly you would need to add an autonumber (field type) and a uses (I suggest having it as a number field type) in airtable. Like this:

Then you create the j loop in thunkable and some triggers to get the data and update it. I tested it real quick and works and I tried to keep it as close to your goal as possible (based on my understanding). Here are what my screen and blocks look like:


Give it a look, but most importantly, try to understand how and why it works. You could even make it more amazing that way!

2 Likes

Hi @mrmoshojrkr Thank you so so much:) It was a huge help for me. Though I understood how does logic goes but my problem hasn’t been solved… I literally followed your steps to practice and here is the problem:

1/ When I type correct code and “unfocus”, I get wrong code alert
2/ And this alert window continuously pops up, there are 5 alert windows and I need to click “confirm” 5 times to close it.
3/ After closing first 5 alerts, alert doesn’t show up anymore. Even the code is incorrect.

**Luckily if I type correct code and “hit button” I can navigate to next step, and wrong code no. So this feature perfectly works! I think it’s all about “Unfocus”.

So main issue here is 1/After tying code and “unfocus”, it keep shows error message (whether or not code is correct) 2/Alert error. Below are the pictures of Airtable and code blocks plus my setting for Alert.

Sorry for asking too many questions… Appreciate so much with your kind help!

2 Likes

Thanks for pointing it out, after I had some rest and looked back at the blocks I see the problem. I made a few modifications and tested it right now. The error message when the code is correct should not be an isseu and all should work well. Though since one of the triggers is when unfocus, if they dont put nothing it will still bring the alert unless you add a conditinoal statement to account for that.

Also the blocks got longer so it’s a bit slower than ideal (could also just be my internet) which is why I changed it to set the button’s visibilty to true (default button visibilty state is false) after it’s checked everything as to avoid issues.

If the speed really is slower than ideal because of the blocks, you can play around with the triggers and blocks to reduce the delay or do something like have the app pull in the list directly from the column and not the rows when the screen opens and save those in a varibale so that the check time is reduced. Just some thoughts

Edit: Spelling errors

2 Likes

Try this example.
I made it using a local DB but you just need to connect the project to a Google sheet or an Airtable table and use the same code.

You might need to re-connect the block after connecting to a table.

https://x.thunkable.com/projectPage/613616bb80cb6100104bebc6

2 Likes