cancel
Showing results for 
Search instead for 
Did you mean: 

Update Minicart after add product in cart programmatically

SOLVED

Update Minicart after add product in cart programmatically

Hi !

I need a little help

I have create a custom module and with this module, I add a product to my cart with no problem.
But, impossible to update my minicart in header

I have my product to my cart, but my minicart is always empty...

Anybody have a idea to help me ?

9 REPLIES

Re: Update Minicart after add product in cart programmatically

did you customised the minicart ?

_______________________________________________
An Expert in Anything Was Once a Beginner

Re: Update Minicart after add product in cart programmatically

No, this is the default minicart

Re: Update Minicart after add product in cart programmatically

Find myself

Re: Update Minicart after add product in cart programmatically

Hi,

 

Have you found the issue with this, i have the same problem

 

Thanks

Re: Update Minicart after add product in cart programmatically

can you please share how you fixed this?

Re: Update Minicart after add product in cart programmatically

Re: Update Minicart after add product in cart programmatically

Hi Could you please let me know how to add product to cart programatically?

Re: Update Minicart after add product in cart programmatically

what did you find?

Re: Update Minicart after add product in cart programmatically

There are two day to that first is js

require(['jquery','Magento_Customer/js/customer-data'], function ($,customerData) { 
      var sections = ['cart'];
        customerData.invalidate(sections);
        customerData.reload(sections, true);

});

Second this using the section.xml
NameSpace/ModuleName/etc/frontend/section.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Customer:etc/sections.xsd">
    <action name="frontname/controller/action">
        <section name="cart"/>
    </action>
</config>
Find helpful ? Consider Giving Kudos to this post.
Problem solved? Click Accept as Solution!"
Qaisar Satti