Help with shopping cart

Hey everyone.
I’m going through the forum since last night for help related to cart, all those answers made me feel little bit dizzy to be honest.
What I’m looking for is adding cart to the temporary user, before they login.
How can we do that? Someone said use session ID, someone said bubble will create temporary user profile for everyone, someone said use IP address etc etc.
Someone who’ve done this before, please help me!

You are wanting to add your cart products to guest user if no user is logged in?

May I know the exact scope for your requirement? So that I can provide my suggestions may be help you.

Do you want retain the user cart after they revisiting your website?

If yes then just create temp user into your user table and use jscookie to store that temp user. After user revisiting your website check for cookie and retain their cart products

Bubble uses cookies to track users and if the user is not a registered user they will keep those cookies for up to 3 days. This means any data that the user creates in your database, the built in ‘created by’ field will reference that user. However, keep in mind this will look empty in your app data since the user is not registered and there is not an email address for them. BUT, in the event that they register for your app within those 3 days, Bubble will automatically adjust all the data they created to be linked to their User data type.

So, for your situation, you would create a shopping cart as normal for any other user. You need to ensure you have the database structure for that.

You should have data type of products, datatype of order and data type of line items. Line items is the product related, the number of quantity and the related Order. The order has a list of the line items.

If you are interested in getting a shopping cart setup properly, both from the database structure, workflows and the UI elements, I’d be happy to assist you with the task. I believe we’d be able to cover all the nitty gritty details in an hour session and have time for you to ask any clarifying questions so you’d be ready to implement.

Learn More

Boston85719 is an expert Bubbler with a decade experience as an educator. Real name Matthew, he has been actively building SaaS apps, marketplace apps, scheduling apps and more for clients, himself and for sale as templates.

As an official Bubble Bootcamp Instructor, he leads Bubble Bootcamps on a regular basis.

Always willing to offer advice via the Bubble Forum, Matthew also offers Private Personal and Group Training Sessions.

Through his site, NoCodeTrainer, Matthew provides a range of tutorials with editor access to help you jumpstart your Bubble development.

Always accessible you can send Matthew a private message via the forum or send an email directly with your requests.

Be sure to checkout the Stripe Integration Course when you are ready to integrate Stripe payments to start monetizing your application via product sales or subscriptions.

Stripe Integration Course

NoCodeTrainer.com

1 Like

I want users to add products to the cart even though they’re not logged in, while redirecting them to the check out page, I’ll ask them to login. They I want to display this cart in check out page…

Oh okay.
For this case, don’t need temp user unless your not using privacy rule for cart table. Maintain some custom state for cart products to show on your checkout. Once user try to login or register move those cart details to that user and process the order.

Can we move items from state to database?

Yes, you can. with help you backend workflow/ custom trigger.

Somewhat understandable now. Thank you so much man.
I’m trying to push list of items from custom state to the database. I’m having some issues. I’ll try to sort them out myself. If I couldn’t, I’ll get back to you

Ok sure and thanks :blush: happy to help you.

Hey Mani,
So I’m having list of food items in the custom state. Food-item is a datatype which contains Food item name, it’s price and its picture. Now I’ve created two datatypes namely “Cart” and “Cart-items”. Cart contains Customer which is of type user and items which is a list of Cart-items. Cart-items contains of Food-item which is of type food-item, quantity which is of type number and cart which is a link to the cart these items are part of.
Now I’m trying to move the list of food items from custom state to the datatype “Cart”. I’m setting customer=current user and items=custom state’s name(list of food-items). I’m getting error saying items should be a list of Cart-items but rn it’s a list of food items. Cart-items is having the food-items in it. Any help would be greatly appreciated.

Dont make more complex. Just create some temp table for maintain the cart-items (list of food-items, price, quantity etc) and store this thing to the custom state as list.

Use this custom state to listout in checkout page.

1 Like

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