0

I have implemented the ajax cart update following this. But the issue is when I enter the max qty for a product it does not shows any error. (which is Magento default behavior, should show a popup).But when I reload my page that error shows up.

Does anyone know about this?

default behavior: enter image description here

custom after making it ajax based. enter image description here

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

$(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);
                customerData.reload(sections, true);
                var deferred = $.Deferred();
                getTotalsAction([], deferred);
            },
            error: function (xhr, status, error) {
                var err = eval("(" + xhr.responseText + ")");
                console.log(err.Message);
            }
        });
    });
});

});

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.