I have this use case:
I am creating a shopping cart on weweb, I have been able to make the functionality and get to the check out process as shown in the first and second image,
I have a problem trying to add the total dynamically, I created an object type variable so that the product id and the selected quantity are saved dynamically, can anyone help me with ideas to know how I can do the total sum of all the products, thanks all
I think you should first of all use an array of objects (items), not an object. If you want to do it with your object though, you can use this one-liner formula. I would probably still opt for the array approach as also @luka suggested, as it is more flexible and simpler (no need to to the values() conversion).
values( [your_cart_object_here] ).reduce((partialSum, a) => partialSum + a, 0);
Thanks for the reply, i tried using an array, but im stuck in the same issue, the Total, how can i do the math (price*qty) an the total SUM, any thought?