1

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.

gajjala sandeep
  • 491
  • 6
  • 23

1 Answers1

0

You can add below code in ajax done function:

   require(
                    [
                        'jquery',
                        'Magento_Checkout/js/action/get-totals',
                        'Magento_Customer/js/customer-data'
                    ],
                    function ($, getTotalsAction, customerData) {
                        var sections = ['cart'];
                        customerData.reload(sections, true);
                        // The totals summary block reloading
                        var deferred = $.Deferred();
                        getTotalsAction([], deferred);
                      }
                    );
Mohit chauhan
  • 840
  • 5
  • 15
  • Thanks for quick reply but the code is not working in magento 2.2.7 – gajjala sandeep Mar 25 '19 at 11:04
  • This is working on 2.2.7 . Can you please share your full code? – Mohit chauhan Mar 25 '19 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 '19 at 11:14
  • i have aded the code above please check and let me know please. – gajjala sandeep Mar 25 '19 at 11:15
  • Try these solutions : https://magento.stackexchange.com/questions/160707/cannot-read-property-section-loadurl-of-undefined – Mohit chauhan Mar 25 '19 at 11:22
  • and is there any other solutions. – gajjala sandeep Mar 25 '19 at 11:33