I managed to do that in CART. According to the code I found here and put it in catalog/view/theme/YOURTHEME/template/checkout/cart.tpl:
<script type="text/javascript">
$("input[name^='quantity']").change(function() {
$("input[name^='quantity']").closest('form').submit();
});
</script>
I want to do the same in Quick Checkout from Journal 2 theme, which is even more important than cart. I managed to make it work, but it works only on a computer, but not on touch devices.
On the line 521: $(document).delegate('.checkout-product .input-group .btn-update', 'click', function () {
I changed 'click' to 'keyup click' and this works on a computer.
For touch devices I've been trying with touchend, touchmove combinations, but I cannot get it to work. Can someone please help what I need to write that auto quantity will be updating when there is a input, instead of hitting update button everytime.
Here is the original code from checkout.tpl:
$(document).delegate('.checkout-product .input-group .btn-update', 'click', function () {
var key = $(this).attr('data-product-key');
var qty = $('input[name="quantity[' + key + ']"]').val();
$.ajax({
cache: false,
url: 'index.php?route=journal2/checkout/cart_update',
type: 'post',
data: {
key: key,
quantity: qty
},
dataType: 'json',
beforeSend: function() {
triggerLoadingOn();
$('#cart > button > a > span').button('loading');
$('.checkout-cart').addClass('checkout-loading');
},
complete: function() {
triggerLoadingOff();
$('#cart > button > a > span').button('reset');
},
success: function(json) {
setTimeout(function () {
$('#cart-total').html(json['total']);
}, 100);
if (json['redirect']) {
location = json['redirect'];
} else {
$('#cart ul').load('index.php?route=common/cart/info ul li');
$(document).trigger('journal_checkout_reload_payment');
$(document).trigger('journal_checkout_reload_shipping');
}
}
});
});