{"id":970,"date":"2020-04-30T16:10:56","date_gmt":"2020-04-30T16:10:56","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/2020\/04\/30\/update-mini-cart-in-magento-2\/"},"modified":"2025-07-17T10:39:28","modified_gmt":"2025-07-17T05:09:28","slug":"update-mini-cart-in-magento-2","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/update-mini-cart-in-magento-2\/","title":{"rendered":"How to Update Mini Cart in Magento 2"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Magento 2\u00a0offers a mini cart feature that allows the visitors to conveniently check their cart items and other details without having to leave the current page and load the cart page.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Mini cart improves the on-site experience of any online store. However, Magento developers have noted an issue of mini cart not refreshing when a visitor adds or removes an item or make any changes in the cart. You can also&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/show-additional-data-in-magento-2-mini-cart\/\">show additional data in Magento 2 Mini Cart<\/a>&nbsp;to show shipping charge, discount or tax information etc.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This is surely a blow to the user experience and needs a solution!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here\u2019s the programmatic solution to overcome this issue and update mini cart in Magento 2.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method to update mini cart in Magento 2:<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">require([\n           'Magento_Customer\/js\/customer-data'\n        ], function (customerData) {\n            var sections = ['cart'];\n            customerData.invalidate(sections);\n            customerData.reload(sections, true);\n        });<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Do share the solution with Magento community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Likewise in&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/restrict-quantity-update-from-mini-cart-in-magento-2\/\">Magento 2 restrict quantity update from minicart<\/a>&nbsp;which will be helpful to you when you have set condition of limiting the order quantity.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Magento 2\u00a0offers a mini cart feature that allows the visitors to conveniently check their cart items and other details without having to leave the current&#8230;<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-970","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/970","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=970"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/970\/revisions"}],"predecessor-version":[{"id":14941,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/970\/revisions\/14941"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=970"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=970"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=970"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}