Hi, so I am trying to make a cart/shop system, so when a user adds a product to their cart it will show the products they’ve added to that page, and it will also add up all of the prices of the products so it shows a price total of all of the products they have in their cart. how would I make it show the total of all of the prices?
anyone?
This could get complicated quickly, but I’d start out by:
- On a product page, adding a “Add to cart” button that creates a “Product” thing every time the user puts something in their cart. This product should have price, the ID of the user who created it, and true / false field called something like is_currently_in_cart
- In the “Cart” section creating a repeating group (name might be slightly off – I’m still new to Bubble) that shows all products that belong to that user, which also have is_currently_in_cart set to true
- To create the total you would display the sum of all products that belong to that user and have is_currently_in_cart set to true
- Upon purchasing products or removing items from carts, is_currently_in_cart would get set to false
It’s worth noting that this problem gets more complex when you want to allow users to purchase products in quantities greater than 1, or when you want to keep track of inventory and show when products are “unavailable” due to no longer being in stock.
Hope this helps!
Add to same product thing you have created a price and qty.
In the Repeating group add an input field call it qty. And another input called total cost. Upon checkout clients can type on that qty input how many of that product they want on the total cost you will multiply product price * qty.
Now all that has to be stored somewhere as another thing called Orders for example.
Which you will have Client information, product price product total cost and qty. Maybe order status delivered… in progress… canceled.
Now go ahead and try. And let us know how it goes…
You can use auto bindings (if you want client to edit cart it changes database once you modify input, set state it is temporary memory store values and goes to default if you re load the page, current page user (if you want user which is not registered to add item to cart). You can browse fourm for more information.
royalmodificaitons - were you able to do this? I had to create one for a site I’m working on and I’d be happy to share the solution if you need it. It is setup for electronic products and doesn’t do inventory yet. It does have a purchase, cart, and check out process (not very pretty yet, but it works)
Hi
I can help you in this regard. Join me at Skype:- help.paulaustin
This topic was automatically closed after 70 days. New replies are no longer allowed.