Adding and Removing Products to and from the cart

Hello,

I am running into an issue with trying to add and remove products to and from the cart. I am looking to do this in a very specific way using a quantity tracker, and can not seem to get it to work within the code of the theme I am using. Essentially, when a user clicks the ‘plus’ button, it will add an instance of the item to the cart, and then when the user hits the ‘minus’ button, it will remove a single instance of the item from the cart. I was also hoping to get the quantity of the item to update when this happens, and display the total price of all items in the cart on the page as well. One thought I had was displaying all of the products on the cart page and doing it from there, but I was having difficulty doing that too.

I was hoping someone maybe able to guide me in the right direction for this as I am a Junior Developer and would appreciate some help.

Thanks,

Hayden Crocker

Hi @haycrocks ,

You can refer to Dawn 6.0’s code, it supports this and is an example for you to learn everything. Refer file: https://github.com/Shopify/dawn/tree/main/assets

Hope it helps!