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.

1 Answer 1

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); } ); 
6
  • Thanks for quick reply but the code is not working in magento 2.2.7 Commented Mar 25, 2019 at 11:04
  • This is working on 2.2.7 . Can you please share your full code? Commented Mar 25, 2019 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); } }); }); Commented Mar 25, 2019 at 11:14
  • i have aded the code above please check and let me know please. Commented Mar 25, 2019 at 11:15
  • Try these solutions : magento.stackexchange.com/questions/160707/… Commented Mar 25, 2019 at 11:22

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.