Refreshing the Mini Cart and Other Customer Sections in Magento 2
Magento 2 caches customer-specific blocks like the mini cart in the browser’s local storage. After a custom AJAX action, you may need to refresh them so the page shows current data.
The script
List the sections you want to reload in the array:
require([
'Magento_Customer/js/customer-data'
], function (customerData) {
var sections = ['cart','checkout-data'];
customerData.invalidate(sections);
customerData.reload(sections, true);
});
For server-side actions, you can also declare the sections to invalidate in your module’s sections.xml, so Magento refreshes them automatically.
Stuck on something similar? Our Magento development team is happy to take a look.