0

Issue:-

Is there a ready solution to update shopping cart page by ajax url/checkout/cart/?

I found similar questions but there is no working solution, but as for me, it's very useful feature and should be some implementation.

I not ready to provide a code, trying to implement this solution for my needs https://magento.stackexchange.com/questions/187226/ajax-cart-validation-on-change-qty?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

1

i did this with such JS, if need ready solution ping me. not pretty cool, but was need to save compatibility with non default themes

define([
    'jquery',
    'Magento_Checkout/js/action/get-totals',
    'Magento_Customer/js/customer-data'
], function ($, getTotalsAction, customerData) {

    $(document).ready(function(){
        $(document).on('change', 'input[name$="[qty]"]', function(){
            var form = $('form#form-validate');
            $.ajax({
                url: form.attr('action'),
                data: form.serialize(),
                showLoader: true,
                success: function (res) {
                    var parsedResponse = $.parseHTML(res);
                    var result = $(parsedResponse).find("#form-validate");
                    var sections = ['cart'];

                    $("#form-validate").replaceWith(result);

                    // The mini cart reloading
                    customerData.reload(sections, true);

                    // The totals summary block reloading
                    var deferred = $.Deferred();
                    getTotalsAction([], deferred);
                },
                error: function (xhr, status, error) {
                    var err = eval("(" + xhr.responseText + ")");
                    console.log(err.Message);
                }
            });
        });
    });
});
  • Hello Maxim R. Please elaborate the answer. We are trying to achieve this. – Raghav Aug 30 '18 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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