I’m looking for some advice and suggestions from those of you that have published apps with adalo that deal with ecommerce sales where stock is limited.
In my case my app will sell event tickets and I will have a limited number of tickets. Some of the tickets won’t be that popular but others will and could potentially have 200+ users trying to purchase up to 400 tickets at the same time when they’re released. I have my app set up with a remaining capacity field that reduces as orders are made etc. and this works great when one user at a time makes an order.
However, if two users click the ‘add to cart’ button at the same time the Adalo databse does not run the requests in order and both users are able to add the items to their cart, even if there was only 1 ticket left. Imagine if there was 20 users clicking purchase at the same time… The database would be so out of sync it would be impossible to offer the tickets for sale at all.
I’ve raised a ticket with Adalo support who after looking into it confirmed this is a limitation and also something that affects large tech companies (they linked this site to me to help explain: design - Best-practice to manage concurrency into a basket in a e-commerce website - Software Engineering Stack Exchange). There are some ways to add failsafes but I’m not sure how these would be implemented within Adalo.
So… How are you doing this at the moment if you’re running an ecommerce / ticket sales or similar type app?
Bump… (extra text to meet the 20 character limit…)
@Ash1 this is an interesting problem to solve.
Couple of ways to do this:
When users add to cart, put a disclaimer text saying “order is not complete until checkout is successful”
This will nudge them to checkout asap
When they hit checkout and enter card details, perform a validation to check for the remaining quantity available is less than or equal to ordered quantity. If not available, throw an error message and reset cart.
When users add to cart, start a timer say, 180 seconds to checkout, if they don’t checkout, clear the cart and send the user back to start.
With this approach, you’ll have to hold other users if they try to add fo cart while the person 1 is finishing his checkout
If the checkout is not successful by the first person, notify the person in waitlist to checkout.
Second approach will have many more conditions to solve, I’d recommend to go with the first.
Hope this helps.
Thanks for the reply.
Unfortunately it doesn’t seem to be this easy to solve though. The problem is that if 2 users click ‘add to cart’ at the exact same time the database doesn’t register the second users request, BUT the second users still gets the items added to their cart (as does the first user).
I think putting the validation on the payment button would provide the same results - in that if 2 users both clicked ‘pay’ at the same time it would allow the payments to go through for them both.
Here’s the latest reply from Adalo support that I received:
Currently the way that these logic checks are made is that they are actually made client side, not server side. This is an extremely important to note because it means essentially this;
User 1: Loads the screen and gets the latest data from the server and it is held in their browser locally. They then take the action and it checks the logic against the data held locally. This checks out ok and the user is able to perform the action.
User 2: Loads the same product (screen) at the same time as user 1. They store the same data from the server at that time, locally. The new data that user 1 has taken an action that affects this data is not known to user 2 as they have the locally stored data.
This is a fundamental nature of how Adalo currently works and there are plans to make these checks happen server side but the architecture to do that is currently not possible and is an extremely big project to tackle on our side and will take considerable time.
You could probably use an external data collection like Airtable to perform calculations on the backend without having the issues which Adalo team mentioned.
I’ve been thinking about a workaround like this too at the moment. Can Airtable handle concurrent orders in the way that I need?
I’ve just been reading about MySQL as an alternative so please let me know your thoughts
If you use calculated fields in Airtable, the concurrency issue can be solved.
Technically you’ll be performing a check against the real-time data in Airtable, so you can stop leaking checkouts when the quantity in your stock is insufficient
Thanks Bhanu - I’ve taken your advice and setup the data as an external collection in Airtable.
It’s nearly working but I’m having an issue when updating the ‘remaining capacity’ in Airtable with the chosen item quantity in Adalo. I’ve got the external collection update set at ‘PATCH’ as detailed in the Adalo documentation.
However, when the user presses the add to cart button it does not update in Airtable. I’ve got a auto refresh list shown in Adalo for the Airtable remaining capacity and when the add to cart button is pressed it does reduce by the required amount for a split second, but then reverts back to the original number.
The only update I’m doing when the button is pressed is to update the ‘remaining capacity’ and no date fields are sent (I’ve seen this can be an issue).
@Ash1 can you share a screen recording to understand the issue better?
Hi Bhanu - I’ve uploaded a screen recording to Youtube here: - YouTube
In the video you’ll see me try to add an order which should reduce the ‘remaining capacity’ in Airtable but it doesn’t. There’s also another issue with the list showing 4 times even though I’ve set the list to only display current ‘remaining capacity’ based on the same record ID.
Ignore the horrible layout at the moment… Just trying to get all the functionality down first
Thanks for your help with this!
@Ash1 your update trigger to Airtable is not reaching the Airtable base, looks like there’s an error with your update action.
Try doing a custom action via Airtable API instead of Update Action to the collection and see if that’s working.
I’m trying to setup the custom action as suggested at the moment but I’m not too sure how to do it in order to update the Airtable record. There was a really useful tutorial on connecting Airtable as an external collection but I can’t find one about custom actions.
Do you know where I can find any documentation specifically for Airtable?
Custom actions to Airtable is similar to any other http API requests with GET, POST, PATCH etc.
here’s the documentation for custom actions: Custom Actions - Adalo Resources
I’m having issues with setting up the custom action though as the documentation isn’t specific for Airtable (like it is for the external collection).
I have the below error when I try and set it up - can you see what’s causing it?
This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.