Currently the default behaviour is if i have item X in the cart with qty 5, if i put 8 in the qty box and add to cart the new qty is 13 - the expected behaviour we need to for the cart to change to 8 rather than add the 8.

As the category page is using a .js file rather than a phtml file to handle a lot of the customisation it is required somehow to either do this from an observer file seperate from the .js file or an ajax request to a controller in the .js file (this would be prefared).

i have attempted to do AJAX request with no luck, with the URL not being found no matter what i try (i asked the question about this here with no luck)

Calling PHP block or Controller from AJAX from just a .JS file in Magento2

After failing with this i had the idea to use checkout_cart_product_add_before observer event, remove the item from the cart and re-add it with the new value but when i use


It is refreshing the whole page and losing the addition.

Does anyone have any ideas on how i can achieve this? i did manage it with a widget previously but now its been required to be a category page it's become a little more difficult.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.