Using custom states for temporary editing mode?

Hi Bubblers,

I am relatively new to bubble and I need to find out the best way to create a temporary editing mode for an app.

I understand that I have to use custom states but I can’t figure out exactly how.

Here is the scenario:

I have a number of items with prices.

A seller can login to their account and update the prices or items…

A buyer can buy these items.

I want to prevent the seller to make any accidental changes to the items or prices while the buyer is shopping.

So I wish to create a temporary editing mode for sellers where changes are not saved to database in real time.

Only when the seller is happy with the changes and clicks the save button, the app ensures that there are no buyers using the database and then it saves the changes to the database.

How can I achieve this ?

Thanks.

Hmmm. I have another approach for this that may work a bit better from a UX POV. You could create a new entry in the database anytime the seller updates the price so that it’s a new item in the database. Then, anytime the page is loaded, load the most recent version of that item.

Then, when buyers are on the page, they see the most recent item (including it’s price). The page doesn’t update with a new price if a new item is added by seller, because the buyer is looking at a different item in the DB.

Then, if new buyer gets to the page, they’ll see the new price.

And, if original buyer clicks “buy” then you can either allow them to buy at the price they saw, or you could notify them that the price has changed (or perhaps just give them the cheaper of the two).

Thoughts?

That could work.

However the items are organised into different categories. And seller has the ability to create or delete new categories as well.

I’m thinking it maybe a little tricky to keep track of all the items and categories in the db.

And there is also the matter of deleting outdated items and categories. I have no clue how to approach that.

Sounds like a fairly complex undertaking. A few thoughts:

  • Databases are good at storing and tracking things. I think that’s exactly where you’d want to keep track of items and categories.
  • Perhaps it’d be best to start with a simpler version. Then, as you get feedback from users and as you become better at bubble, then you can add more of the advanced features / capabilities. In my experience, this approach works better 99 out of 100 times.

Best of luck!

Scott

Thanks Scott,

I also intend to keep the app very simple at this stage.

I have noted your suggestion and i will definitely try it out.

However I want to ask just for curiosity and experimentation, how would one implement such a thing with custom states ?

You could have a “temp price” number field in the same data type that holds the live price and when the seller updates those inputs, it “makes a change to item > temp price = input’s value” and the save button “makes a change to list of items > live price = temp price”

Custom states would not be the ideal way here because you need to associate two pieces of data with each other: item and price. Custom states can’t hold array values.

I agree with @romanmg on this approach. Additionally, custom states are stored on the user’s computer. Software engineers can easily change the values in those custom states. You don’t want to rely on them being correct for things like price because someone could game the system and set all of the custom state prices to zero and then buy.

1 Like

I see.

I’m gonna go ahead and implement that.

Thanks for all great info.

Cheers.

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