Add Thing to Current User created before login

Hello Bubble community,

I am encountering an issue that I can’t seem to resolve. I am developing an e-commerce website for a custom product. Once a customer completes a configuration, I create a new “Thing” named “Shopping Cart Product” and add it to the “Current User” > List of Shopping Cart Product.

However, some users are not logged in or don’t have an account yet. So, I store a unique number in the browser cache. After they log in, I want to add the items from the cache to the “Current User” > List of Shopping Cart Product Things. No matter what I try, I can’t get it to work. It seems I am not allowed to use the previously created Thing (because it’s not linked to a user) to connect to the logged-in user.

I have tried the following steps in a Workflow and also tried creating a Backend Workflow:

  1. User is logged in and lands on the dashboard page
  2. Once the page has loaded, check if there are still products in the browser cache
  3. If so, do a search for “Shopping Cart Product” based on the unique number
  4. Make changes to current user “Add thing to a list”, Add to Current User “Shopping Cart Product”

However, for some reason, it does not work. The logs don’t seem to provide any solutions either. Is there perhaps an easier way? Or does anyone have an idea how I can best accomplish this?

Thanks in advance!

I do something similar; when a user isn’t yet logged in, Bubble assigns then a temporary unique user id. I have a workflow that when they log in, anything created by the temp user has a change applied, changing user to current user.

Can you maybe share the workflow with me? I see in the browser storage that there is a ID assigned to a not logged in “user” but the things they created don’t have the same ID.

Thanks!

I won’t be at my laptop for a bit, but I believe I had the login workflow look something like:

When Login is clicked → Set custom state (type user): current user (referring to the not logged in User’s temp user ID) → log in user → make changes to list of things: list to change: things created by Custom States temp user; field to change: user = Current User

1 Like

Your approach did help me. It wasn’t clear to me that I could use the Current User before a user had logged in to use the data they had created in a workflow.

I have indeed now used your suggestion in the login workflow.

  1. Save Current User (before login) in a Custom State
  2. Log in User
  3. Make changes to the Current User (logged in) by searching for Cart products created by the Logged Out user and adding these to the list of the Current User logged in.
1 Like

Glad it worked for you!

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