I am trying to build an instacart type of app. The current road block is in getting the cart total to reflect the total including quantities of items. Same issue for the Total items (doesn’t reflect quantity).
Okay perfect so add a new database field under Cart_Item “Item Total” as a number, and make it so when they press the quantity+ button have it recalc the total to “Grocery_Item’s Price * Quantity”
Then your cart total will just be eachitems Item Total:sum.
Test it out but you might run into issues where pressing the + or - qty button will recalc the item total before it write the quantity to the database, so you might have to recalculate it in the workflow with a +1 or -1 since you need to consider the qty change before it writes to the database.
If they edit the quantity number then do the workflow event “Input value has changed”, pick the quantity input, and recalc the Item Total but recalc it as "Grocery Item’s Price * This input’s value and change the quantity in the database after.
Do you have access to backend workflows (a paid plan?) All the calcs can be done in the backend, it might be a slight delay but more reliable
Okay what is the workflow on your + or - button? If you make the quantity change to your database, and your input is automatically reflecting the change, I believe Bubble doesn’t consider that an input change so it won’t trigger a recalculation. Does the user manually type a quantity if they want or just the + and -?
Okay yea so this would update the quantity in the database, but now you have to update the Item Total i was recomending adding to your database. So you could try for step 2 do “Make changes to a thing” Result of step 1, change the field “Item Total” and set it to “This Cart-Item’s Quantity * This Cart Item’s Grocery Item’s Price”
Using the “Result of step 1” should make it wait for the quantity change first before recalculating
it actually does recalculate in the repeating groups individual cells, just cant get it to give a total across the repeating group reflecting quantity and price
If you enable the beta feature that allows paranthesis, then when you press the + sign and it set the quantity, you can have it also set the Item Total, and just make it “(This cart’s_Item’s Quantity +1) * This cart’s Item’s Grocery Item’s Price”
Hey @yasirchau, what was the workflow you applied finally? It does not really work out for me with the “result of step 1”-solution. Would you mind sharing a screenshot of the successfully implemented workflow please?