Throughout my form I’m asking is the user needs to add something to their cart and some of those products are the exact same one so logically the quantity for that product should increase by one, but I cannot figure out how to do to.
It seems like when a user clicks the button to add this product to their cart it only adds it one time and you cannot exceed that one. Is there a way to increase the quantity?
The “add to product” action that you can put on buttons and containers always just overwrites the quantity of the product in the cart. It can be configured with a fixed quantity or with a form field to use as the quantity. If you want to implement an “auto-increment” type functionality for add one more to the cart, you can configure a button with add to cart using a form field (or hidden field) for the quantity. Then you can add a one-line advanced logic code rule (available on the plus plan and above) to increment the quantity field by one immediately before it is added. The complete rule would be something like:
quantityField.value = quantityField.value + 1;
Make sure this rule runs on click of the button and before default actions.
Advanced logic rules only run in test mode forms on the free and basic plans to allow you to try it out if interested.
Hey Eric, Thank you for your reply.
I still need some help understanding how to do this. I know how to code but I cannot understand how to set a field value and increment it from there.
The buttons dont have an ID I can get it to and they do not appear in the form field list so I dont understand how I can increment the value when a button is clicked when that button doesnt have a custom ID and I dont know where to store that value. I know you mentioned the hidden field and creating the logic, but I dont understand how these are talking to each other. I also want to show the quantity of the product before they purchase so again I’m struggling understanding how to show that value. I have it set to the stripe quantity but it always stays at 0.00 instead of 1.00 or whatever the quantity is supposed to be.
If you could help me fill in these knowledge gaps I would greatly appreciate it. Thank you again for your time.
I have created a loom video that I believe answers your questions and might be beneficial to others in the future. It shows an example of doing this. Loom | Free Screen & Video Recording Software | Loom
Also there are a few ways to display the current selected quantity for a particular product including using a text and text source property.
This example from our docs shows this in more detail: https://docs.feathery.io/guides/payment-flow/select-products-or-plans#example-2-plan-selector-with-number-of-licenses-input
Also, we are planning to add separate actions for inc/dec cart product quantities in the near future. Until then, the above technique works today.
Thank you so much for the video and your help Eric!