Adding quantity to product in shopping cart

I’ve been trying, to no avail, create a shopping cart that would let users click on the “add” icon and then add the product to his cart. I created the thing “product”, now many products can be available for the user, like carrots, tomatoes etc in a repeating group scheme.

The problem begins when I try to add the quantity to it, because if I just set a property called “product-quantity” just like any other property like “name” or “picture” and then get the workflow to make change to that “quantity” property, it will change the property in the database and it will affect the product site-wide, not just the cart of this individual user. That would interfere with one user adding to the “quantity” of the “tomato” and then every user online would get its tomato quantity increased.

What I want is just to add a dropdown or numerical input text and then tie that information to the current user’s shopping cart’s product.

Any ideas on how to tackle this problem? I’d love to be answered here or with an example in the forum_app.

Thanks in advance, friends.

Here’s a suggestion. A user maintains a cart, which holds multiple containers (owned by the user), which holds an arbitrary number of a single item (not owned by the user). No other container can carry the same item found in another container in the user’s cart.

1 Like

Yeah, that is almost exactly what I did, except for the “no other container can carry the same item” part, because I’ve set a separate workflow that identifies when a product is already present in the repeating group that gathers data from current’s user “shopping cart”.

However I’m not being able to feed that arbitrary number from any user input. I created the dropdown but I can’t set a “text field” or anything else to be fed from the dropdown. To put it another way, I can’t send the dropdown answer about the quantity (it goes from 1 to 10) to be attached to the product in the current user’s shopping cart without it being attached to the product’s property in the database.

Any ideas on this part, @Scott ? Please?

So, just to get my head round this…

You have a list of products, and the maximum number someone can buy on the product table ?

Tomato 10
Carrot 5
Kale 7

Or is that the number left ?

So there are only 5 carrots left to buy ? So the user can add between 1 and 5 carrots ?

No, don’t focus on the value of the number because there’s no limit to it, I set it from 1 to 10 just for testing purposes, because I want to attach that number to the product without doing it site-wide.

Ok, so you want to limit an numeric input to certain range ?

You could set the max min range on a decimal on the input.

Oh, no, not that. I want to link that numeric input to the product the client clicked on and was added to his personal container called “shopping cart”. Because what it does now is that when the client clicks on the product, it is added to its “shopping cart” (which is a List of Products). But it just adds the product. I want to tie a number to that. Like 2 Carrots, or two Kg of Tomatoes, for it to represent the quantity. But the range is okay to generate an input, I just want to link that input to the product added to the client’s shopping cart.

If it is on the same page, then you could store it on a custom state on the page. You could have a thing that has a link to a product and a quantity.

If it is a different page then you would need to store on the database.

Hey, did you ever figure this out?

Hey… Anyone ever figured this out?

I have a lot of content around this, most recently:

And, further in the past: