I may be missing something obvious but I'm trying to update a +/- quantity button system for adding products to work on Craft Commerce 3
The desired functionality is that click '+' increases the cart amount for that item by one, clicking '-' decreases the cart amount for that item by one.
The original build was in commerce 1, and the apparent way it was written was just by running an update cart ajax call (at what was then 'commerce/cart/updateCart') and passing through a '1' or '-1' as the quantity value. That doesn't appear to work anymore. The '+' call will add the '1', but passing the '-1' through for the '-' call does nothing. It just returns the same cart as if I passed through a zero.
I tried with 'commerce/cart/remove-line-item' but that removes all quantities of the line item rather than just decrement it by one.
I've tried passing the following into an ajax post request:
var data = {
['CRAFT_CSRF_TOKEN']: token,
action: 'commerce/cart/update-cart',
lineItems: {[lnid]: {'qty': dec}}
};
With lnid being the line item id and dec being the new desired quantity (I also tried -1 there) but that just destroys the line item completely.