I have tried below code

        var deferred = $.Deferred();  
        getTotalsAction([], deferred);

But no luck and instead below error i am facing

Uncaught TypeError: Cannot read property 'sectionLoadUrl' of undefined

Same code is working in Magento 2.1.9 but not working in Magento 2.2.7

Could you guys please help me out. How to Refresh/Reload the totals cart via ajax Thanks in advance.


You can add below code in ajax done function:

                    function ($, getTotalsAction, customerData) {
                        var sections = ['cart'];
                        customerData.reload(sections, true);
                        // The totals summary block reloading
                        var deferred = $.Deferred();
                        getTotalsAction([], deferred);
  • Thanks for quick reply but the code is not working in magento 2.2.7 – gajjala sandeep Mar 25 at 11:04
  • This is working on 2.2.7 . Can you please share your full code? – Mohit chauhan Mar 25 at 11:07
  • require(['jquery','uiComponent','Magento_Checkout/js/model/quote','ko','Magento_Checkout/js/action/get-totals','Magento_Checkout/js/model/full-screen-loader','Magento_Checkout/js/model/totals','Magento_Customer/js/customer-data'], function($,Component,quote,ko , getTotalsAction,fullScreenLoader,totals,customerData) { $.ajax({ async:true, beforeSend: function() { },success: function(data) { var deferred = $.Deferred(); var sections = ['cart']; customerData.reload(sections, true); fullScreenLoader.stopLoader(); getTotalsAction([], deferred); } }); }); – gajjala sandeep Mar 25 at 11:14
  • i have aded the code above please check and let me know please. – gajjala sandeep Mar 25 at 11:15
  • Try these solutions : magento.stackexchange.com/questions/160707/… – Mohit chauhan Mar 25 at 11:22

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.