Dynamically Calculate Weight Of Cart Items

Hi Bubble Community,

I hope you’re all doing well.

I’m currently working on a project where I need to dynamically calculate the total weight of items in a user’s cart at checkout. The system should sum up the weights of all cart items and adjust the delivery fee based on the total weight.

Here’s what I’ve done so far:
• Each product has a weight field.
• The cart stores items added by the user, along with their quantities.
• I’ve attempted to calculate the total weight using workflows and custom states, but I’m running into challenges ensuring it updates dynamically, especially when users add or remove items from the cart.

My questions are:
1. What’s the best approach to calculate the total weight dynamically as users add/remove items?
2. How can I integrate this calculation with a weight-based delivery fee system at checkout?
3. Are there plugins or specific workflows that can make this process more seamless?

I’d really appreciate any advice, examples, or resources you could share. Thanks in advance for your help!

Hi there,

If the items in the cart each include their respective weight and age in a repeating group, you can have a field that is 'Repeating Groups (list of things)' each item's weight: SUM.

Now anytime a cart item is updated, this will dynamically update to match. You can have a field on the cart datatype that saves this value as well, and pass it along to any workflow calculating the shipping.

Hey, thank you so much for this solution! I am trying it out and will let you know how this goes!

1 Like