How do I have a quantity system on an ecommerce site?

I want to create a function for an ecommerce site where there is a button the adjust the quantity of the product that the user is adding to their cart. I have built a display that shows the current quantity and button that adjust the quantity. As the quantity is adjusted the price displayed on the product pages changes. However, I can’t figure out how to put that desired quantity of the product into the users cart. I want to have the quantity displayed on the cart page and then can do a simple workflow to multiply the price of the product by the quantity to get a final price for the payment.

I managed to transfer the data of the quantity selected by the user to the cart page through URL page parameters however the issue with that is that it only worked for one product and as my product page can show multiple products if there are multiple different products in the cart they all have the same quantity shown.

I’m very stuck and any help would be much appreciated. Thanks!