0

I have a function of ajax add to cart in below file and doing section reload. below code is in app/design/frontend/MyThemeNS/Mytheme/web/js/custom.js (just mentioning sample for understanding.)

require([
  'jquery',
  'mage/url',
  'Magento_Customer/js/customer-data',
], function ($, url, customerData) {
....
    ajax call function {
     on success : {
       .....
      var sections = ['cart'];
      customerData.reload(sections, true);
    }
  }
......
}

File : Magento_Customer/js/customer-data is not initiating. upon more debugging i found in chain of js libirary dependency initialising the last file lib/web/js-storage/storage-wrapper.js is containing 'js-storage/js.storage' file which is not initialising.

i checked the magento2 release 2.4.5 and saw this.

julien-maurel/js-storage instead of jQuery Strograe libraries

is this magento bug or any other way i can do section reload after ajax add to cart in my custom theme custom function.

i am stuck and not able to find solution. can someone support if known any such issue.

2
  • try to add customerData.invalidate(sections); on above customerData.reload(sections, true); Apr 16, 2023 at 16:20
  • on page load, 'Magento_Customer/js/customer-data' itself not initializing, due to that.my custom js itself not working. if i remove 'Magento_Customer/js/customer-data' then my custom js works, but unable to reload sections.
    – Nits
    Apr 17, 2023 at 5:22

1 Answer 1

2

There is a issue 2.4.5 with cookies and storage dependency. here is the patch need to apply. https://github.com/magento/magento2/issues/35913 this solves my problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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