1

I need to update quantity of cart items without reloading whole page(using ajax) but with simple code not a lengthy method. anybody please help me out.

8
  • Which magento version
    – Amit Bera
    Commented Apr 29, 2016 at 10:59
  • magento 1.9 version
    – Laty
    Commented Apr 29, 2016 at 11:00
  • 1
    Suggestion to be use any 3rd party extension
    – Amit Bera
    Commented Apr 29, 2016 at 11:01
  • Without a lengthy method. you cannot do it
    – Amit Bera
    Commented Apr 29, 2016 at 11:02
  • i need customization without third party extension
    – Laty
    Commented Apr 29, 2016 at 11:07

2 Answers 2

2

Use below code:

<script>
jQuery(document).ready(function(){
jQuery('.btn-update').on('click',
        function(e){
            e.preventDefault();
            var form = jQuery(jQuery(this).closest('form'));

            // we'll extract the action and method attributes out of the form

            // kick off an ajax request using the form's action and method,
            // with the form data as payload
            jQuery.ajax({
                url: form.attr('action'),
                method: form.attr('method'),
                data: form.serializeArray()
            });
        }
    );
});
</script>

Hope it will helpful to you.

1
  • When i am refreshing cart page it's updating cart not on click of "Update" button.
    – Magecode
    Commented Aug 24, 2017 at 6:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.