I have + and - buttons in the cart layout that are changing the value of the quantity input using jQuery.
It works perfectly on the page and in the source code (quantity values changes) but it doesn't work after page refresh and doesn't get reflected on the checkout page.
Changing the quantity manually (with built-in input arrows or by typing the new amount into the field) works normally.
$(".qty-button").on("click", function() {
var $button = $(this);
var oldValue = $button.parent().find("input").val();
var newVal;
if ($button.text() === "+") {
newVal = parseFloat(oldValue) + 1;
} else {
if (oldValue > 0) {
newVal = parseFloat(oldValue) - 1;
} else {
newVal = 0;
}
}
$button.parent().find("input").attr('value', newVal).trigger('change');
});
It changes the value in the page source and is reflected on the cart page but does nothing in terms of functionality as it gets back to the original value on page refresh or checkout.
Any ideas?