I see my mini cart not updating its items when I delete an item from the cart programmatically.

but the cart updating perfectly as per my requirement only after I added a new item into cart or any cart event-triggered non programmatically.


1 Answer 1


You can fix this issue by creating a file app\code\Vendor\Extension\etc\frontend\section.xml using following code inside your extension folder.

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <action name="extension/controller/action">
        <section name="cart"/>

In this action parameter name, you have to pass the full action (For ex. checkout/cart/add ) in which cart is updated. It means you programmatically delete or add a product to cart to the shopping cart.

Also, you can add below code in your observer to refresh the quote for the customer.

$quote = $this->quoteRepository->get($quoteId);
$quote->setCustomerId($customer->getId()); // Whatever you want to update

Reference: how to refresh mini cart programmatically in magento2

Hope it helps!!!

  • "You have to pass the full action (Forex. checkout/cart/add ) "I don't understand this point. which path i have to place here?
    – Sanjun Dev
    Sep 21, 2019 at 10:41
  • This is for controller action.
    – Sumit
    Sep 21, 2019 at 11:32
  • Have you tried it @SanjunDev?
    – Sumit
    Sep 26, 2019 at 11:00
  • 1
    No! it is just hold. anyway it seems to be work.
    – Sanjun Dev
    Sep 26, 2019 at 11:19

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.