Display value of dynamic text element inside repeating group in element outside the RG

I am wondering if there is a way to access and display the value of a dynamic text element inside a repeating group in another text element outside of that repeating group, and better yet to then save that value to the database?

I have a nested RG in a shopping cart situation. Inside the nested RG, I have used dynamic text elements to calculate and display various subtotals and shipping costs specific to the contents of that particular cell. I need to then add these values together for a grand total that will display outside of the RG. Initially, performing these calculations on the page seemed simpler than creating a long series of temporary database items during the add to cart process, but that no longer seems to be the case. Anyone run into this before or have a simple workaround?

Hey @josh1, I think you’ll need to use custom states for this. Depending on how the flow goes, it would look something like “when values inside the RG change, change the custom state” then access that custom state value for the totals.

If you want to share a link, I can help give you more specifics.

Gaby | Coaching Bubble

1 Like

Thanks, @romanmg. Here’s a link: https://bubble.io/page?type=page&name=shopping_cart&id=locaverse&tab=tabs-1

You’ll see the calculations happening in the individual cells. I’m not sure if custom states would work, since the values don’t actually change after the page load, so wouldn’t trigger a change of state.

Ok, so I’m looking at the page. I understand what you’re saying - the subtotals aren’t results of any workflows on this page. So, is there a reason the total needs to be outside the RG? Since it’s a fixed 1x1 cell, you’re only always going to see 1 user’s information at a time, right?

You might have a good reason for this, so if it must be outside, you’re correct - the data has to be pulled from elsewhere. The key thing you need is the user’s shopping cart. 1 quick option is to change the page type to a Shopping Cart instead of User and send that shopping cart data from the marketplace page like you currently are with the user. Not sure if that’ll make your grand total search easier to compose (I’m not familiar enough with the formula you need). Otherwise, here’s what I’d suggest if you want to keep the page type User…

When the user navigates to this page, send another parameter - the shopping cart in question. That way your totals can pull data from the URL value. I followed 1 of the add to cart > go to shopping_cart flows and got this started for you. I duplicated the Total value inside the cell to the grand total text so that you can see how you access the data from URL, but that grand total might be a different expression, so change whatever you need, just note all the “Search for Shopping Cart” parts and look at the constraint: unique id = get “cart” from URL.

I created the “cart” parameter from when the user clicks “add to cart” on the marketplace page. Since that triggers the creation of a cart and then opens a popup for the user, I sent that new cart data to the popup (I had to set a type to the popup… type of content = shopping cart). Then when “go to shopping cart” is clicked from that popup, it sends a URL parameter - the unique ID of the popup’s cart (that is, the cart data sent from the add to cart action). another popup. I’m including screenshots so you know where to look, but this should solve it for you. Let me know if you have any questions.

Gaby | Coaching Bubble

@romanmg, thanks so much for the detailed response! That’s an interesting solution, but seems to have the problem that the Grand Total will be calculated differently depending on whether the shopper navigates to the page directly via the marketplace add to cart modal, or if she takes another roundabout way to get there. This is demonstrated by the different values calculated if you try loading the page directly vs navigating from the marketplace.

The biggest roadblock I am facing with all of this is the shipping calculation, since it is based on the number of unique ship dates per vendor in the shopping cart multiplied by a shipping rate based on the distance from that vendor to the buyer. So, it is necessary to create some logic to group all shopping cart items from each vendor together, and then identify the number of unique ship dates within that group, which can then be multiplied by the shipping rate. With the current database setup, I can’t figure out a way to operate on the data to produce the needed results, so it seems like a series of temporary things will need to be generated each time a user adds an item to her cart and then accesses the shopping cart page, in order to try to reconstruct the functions that the repeating group does so elegantly. That’s why I was hoping there were some way to extract the data that each RG cell is generating, so as to avoid the clunkiness of the database approach.

From reading the forums, it sounds like some people use a custom state linked to a disabled input element inside the RG to get around this issue, similar to what you initially suggested, but again that seems to require the input element to change its value in order to trigger the workflow or for the user to directly interact with each cell, which is not ideal.

Can you see anything that I am missing?

Im stuck with the same issue bro, were you able to find a proper solution to this?

I ended up running an API on a list and saving the result to a database item. The API can be run every time the user’s shopping cart is updated.

I did solved it the other way, I instead created a “confirm” button inside the list items of the cart on the client UI, The client has to press the button which then saves the cart item total in db. Then I pass this total down for payment. The purpose of confirm button was not just for this but for holding the product as a booking for 5 min, within which the user has to make a payment. My products are limited edition and so lets say there are 7 products available and maybe multiple people might end up buying the last product simultaneously which could cause an issue. So for that reason I added the confirm button that holds this product for you for 5 min and at the same time shows the other users that a product is on hold which may or may not be sold out after 5min (depending on if the user holding the product makes the payment or not). After 5min if the user doesnt make any payment then the product is unconfirmed and the Total amount is resetted. The user can again confirm them and try to make a payment in case if the product is still available.

Btw, im jealous of you that you knew bubble back in 2016 lol wish I had known it earlier. Thanks for replying back on a thread 4 years old. Have a good day :slight_smile:

Just an FYI, I have had to extract calculated data from RGs before and found this pluggin useful.