In 2014 I've added some code to auto update the product qty in the cart checkout of Magento so if I were to change the qty of the product it automatically updates this. Sometimes a customer forgets to press enter or click on update shoppingcart. This worked very well.

I've placed this code in the head.phmtl file of my template:

<script type="text/javascript">
function ajaxCartPost(item){
    element='cart[' + item +'][qty]';
        url: '<?php echo Mage::getUrl('checkout/cart/ajaxcart')?>',
        dataType: 'json',
        data: jQuery("form#cartform").serializeArray(), 
        success: function(data) {
            if(data.status == 'Y'){
    return false;

And disabled this line in /app/design/frontend/base/default/template/checkout/cart/item/default.phtml

<input name="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" class="input-text qty" maxlength="12" />


<input name="cart[<?php echo $_item->getId() ?>][qty]" id="cart[<?php echo $_item->getId() ?>][qty]" value="<?php echo $this->getQty() ?>" size="4" title="<?php echo $this->__('Qty') ?>" maxlength="12" style="float: left; width:1.9em!important;" onkeyup="ajaxCartPost(<?php echo $_item->getId() ?>);"  />

I've updated the Magento shop from version to and all of a sudden this doesn't work anymore. I did some tracing to check and see if there was an error but there is none. Can someone point me to the right direction?



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.