Adding a discount code system

I am trying to add a discount code feature to my app, where the user can input a code at the checkout, and if the products that relate to the code are in their cart, a discount will be applied, any suggestions would be appreciated!


Have a datatype for Discount Code, with fields relating it to different products, as well as the code itself, expiry date, discount amount etc.

Then, when a customer enters a code check for valid codes in the database, and apply the discount to the relevant items.

1 Like

Hey, thanks for the reply; I have that much built but the actual workflow I cannot figure out

I’m not sure any workflows are required here at all… (although it depends on how you’re doing things).

but in any case, once the code has been entered, and retrieved from the database, wherever you’re defining your prices for checkout just apply the discount to that amount.

Hey, so what would trigger the price change - e.g. if a user puts a code into an input - and it is a discount code in the database - how do I change the price of the products in the customers cart that are affected without changing the price of the others and how do I let bubble know that because that discount code has been entered it should apply that discount percentage to those specific products?

Well… as I said, it depends entirely on how and where you’re defining your prices…

If, for example you’re defining the price somewhere on the page (in a custom state or a group), then just adjust that price by the amount of the disount.

If you’re defining it directly in your go-to-checkout workflow, then adjust it there.

Or you could adjust it directly in the database.

@micheal.killarney How do you do your payments? What service are you using? Because if you e.g. use stripe, you should leave it to them, they have a whole system for discount codes in place that allows you to create codes via api or your dashboard etc… I have built these systems a lot using stripe.

the price of each product is stored with the products datatype

the cart is in the datatype user

So they are kind’ve all separated

And they populate the repeating group and the extractor sums the information and moves it a button at the bottom of the page with the prices

I’ll look into this, thanks,

I’ll be changing my discounts and the products they apply to weekly, assume this wouldn’t be a problem?

I’m not too sure what that means… but if you’re using some plugin to extract values out of a RG, then there’s your answer (adjust the price there).

hey, I am definitely not being clear, sorry, I mean I cannot get that to trigger when the user enters a discount code

I am using an input box, but it won’t change the RG, I am wondering how i trigger this because if I use button I can only change a ‘thing’ - am I right?

I really don’t understand what you’re doing (it looks as though you’re allowing your customer to enter the price the want to pay?)

In any case, I can’t really give any specific instructions as I don’t know anything about your app, how it works, or where/how your price (for checkout) is being defined.

But presumably you must know that, so you just need to adjust that price according to whatever discount you want to apply. Without knowing how you’ve built your app, I can’t say exactly how you do that (but i should be dead simple).

This topic was automatically closed after 70 days. New replies are no longer allowed.