0

I am using Ultimo Infortis theme. I am facing issue in adding product to mini cart. First time when i click on Add to Cart button, it do not show product in mini cart but on cart page it show added product. If i again add product to cart then mini cart show added products lists.

This is happening form the first day. I disabled magento cache but still the issue is there.

Can anyone suggest me how to fix this issue.

2

That is magento2's default bug

https://github.com/magento/magento2/issues/5377

https://github.com/magento/magento2/issues/4170

for the temporary solution, you can refresh mini cart in all page for that you can use below code.

default.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
  <body>
    <referenceContainer name="content">
        <block class="Magento\Framework\View\Element\Template" name="refresh.minicart" template="{vendor}_{module}::refreshMinicart.phtml"  />
    </referenceContainer>
  </body>
</page>

refreshMinicart.phtml

<script>
  require([
    'Magento_Customer/js/customer-data'
  ], function (customerData) {
    var sections = ['cart'];
    customerData.invalidate(sections);
  });
</script>

EDIT

/app/design/frontend/Magento/luma/Magento_Theme/layout/default.xml

/app/design/frontend/Magento/luma/Magento_Theme/templates/refreshMinicart.phtml

or if you have created module then you can paste at

app/code/Vendor/Module/view/frontend/layout/

app/code/Vendor/Module/view/frontend/templates/

  • Thanks for your response.. Can you tell the path of files where i should place this code – dev tester Feb 16 '17 at 8:32
  • /app/design/frontend/Magento/luma/Magento_Theme/layout/default.xml /app/design/frontend/Magento/luma/Magento_Theme/templates/refreshMinicart.phtml or if you have created module then you can paste at app/code/Vendor/Module/view/frontend/layout, app/code/Vendor/Module/view/frontend/templates – chirag Feb 16 '17 at 8:36
  • i don't have templates folder in my theme.. I placed xml code in /app/design/frontend/Infortis/base/Magento_Theme/layout but for script changes i dont have template folder inside Magento_theme.. In Magento_theme i have layout,page_layout, web folders not template and inside these folder i don't have refreshminicart.phtml.. I checked for module but ib app/code there is no vendor folder – dev tester Feb 16 '17 at 9:36
  • Thanks for your big help.. The links you provided works for me.. Thanks alot.. :) – dev tester Feb 16 '17 at 10:06
  • you have to create refreshminicart.phtml file and vendor is not a folder its a just a vendor of any module e.g. app/code/Folder/Module/ .. Folder is your vendor and Module is Module. – chirag Feb 16 '17 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.