Remove product items from mini-cart if shopping cart empty.

Problem 01:
In Magento 2, if you remove shopping cart items (from quote table) manually then you will notice that the items in mini-cart still exist because of mini-cart do not get items list from quote table.

Problem 02:
In Magento 2, sometimes mini-cart does not go to empty (but shopping cart is empty) after successfully order posting

Solution:
To remove product items from mini-cart if shopping cart empty. Write the given code in the header/footer or in the specified page where do you want to make empty the mini-cart.

[code] <?php // create objectmanager instance $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); $cart = $objectManager->get(‘\Magento\Checkout\Model\Cart’); $itemsCount = $cart->getQuote()->getItemsCount(); if($itemsCount == 0){ ?> <script> require([‘Magento_Customer/js/customer-data’], function (customerData) { var sections = [‘cart’]; customerData.invalidate(sections); customerData.reload(sections, true); }); </script> <?php } ?> [/code]

Thanks