Iâve built a âshopping cartâ like functionality in the past using Bubbleâs database and overall didnât like the user experience. Perhaps I went about it the wrong way but here are the cons I ended up with (skip past these bullet points to get to my actual question):
- Updates to the user cart were slow (needing to wait for the database to update in order for the cart to update). Granted, when I say slow, I mean it takes a half second to a second⌠so itâs not a show stopper but itâs not great.
- Showing order totals and quantities is clunky - needing to set element states for quantities and totals on item groups in a repeating group, and then summing across the repeating group to get an order total.
- Saving carts to the database is nice because you can email existing customers with abandoned carts to increase conversion BUT Bubble does funky things with associating carts in the case when a pre-existing user is logged out, then creates a cart, then signs in (In my case the cart would âvanishâ because Bubble wouldnât intelligently recognize the signed in user as the one that had just been signed out, despite it intelligently working in cases where users did not have a pre-existing account)
- Finally, saving abandoned carts server side creates the janitorial requirement that Iâd need to regularly flush stale carts. Not really an issue, but this gets more complex when trying to build a marketplace using Bubble (where youâre keeping track of multiple sellers plus all of their respective customerâs abandoned carts).
So Iâd much rather save carts on the userâs device via cookies. Shopping cart management is insanely easy to achieve in plain javascript - below two functions addItem
and removeItem
handle everything:
As you see, we are able to easily output a list of objects which I want to save to a userâs âOrderâ thing. Whatâs the best way to publish this list of objects to Bubble? Three lists? One for ItemId
, one for price
, and one for quantity
? Ultimately, I want my orders
database table to look like: