0

I'm using a custom template and having an issue with the minicart rendering. The minicart pop-up renders, but does not gather any data with 2 errors in the console. enter image description here

So the popup does open when you click on it, but due to the errors above, only part of the contents are being loaded:

enter image description here

More info about the environment:

  • Custom theme does not overwrite any Catalog or checkout templates

  • The theme is based upon Luma theme and the minicart does work as expected when activating the Luma theme.

  • Tried resetting cache, compiling and regenerating multiple times

  • I've also tried copying the template files from the base folders to my theme, but the same issue remains

  • The minicart template in the layout file is a straight up copy from the base magento files

    <block class="Magento\Checkout\Block\Cart\Sidebar" name="minicart" as="minicart" after="logo" template="Magento_Checkout::cart/minicart.phtml">
                 <arguments>
                     <argument name="jsLayout" xsi:type="array">
                         <item name="types" xsi:type="array"/>
                         <item name="components" xsi:type="array">
                             <item name="minicart_content" xsi:type="array">
                                 <item name="component" xsi:type="string">Magento_Checkout/js/view/minicart</item>
                                 <item name="config" xsi:type="array">
                                     <item name="template" xsi:type="string">Magento_Checkout/minicart/content</item>
                                 </item>
                                 <item name="children" xsi:type="array">
                                     <item name="subtotal.container" xsi:type="array">
                                         <item name="component" xsi:type="string">uiComponent</item>
                                         <item name="config" xsi:type="array">
                                             <item name="displayArea" xsi:type="string">subtotalContainer</item>
                                         </item>
                                         <item name="children" xsi:type="array">
                                             <item name="subtotal" xsi:type="array">
                                                 <item name="component" xsi:type="string">uiComponent</item>
                                                 <item name="config" xsi:type="array">
                                                     <item name="template" xsi:type="string">Magento_Checkout/minicart/subtotal</item>
                                                 </item>
                                             </item>
                                         </item>
                                     </item>
                                     <item name="extra_info" xsi:type="array">
                                         <item name="component" xsi:type="string">uiComponent</item>
                                         <item name="config" xsi:type="array">
                                             <item name="displayArea" xsi:type="string">extraInfo</item>
                                         </item>
                                     </item>
                                     <item name="promotion" xsi:type="array">
                                         <item name="component" xsi:type="string">uiComponent</item>
                                         <item name="config" xsi:type="array">
                                             <item name="displayArea" xsi:type="string">promotion</item>
                                         </item>
                                     </item>
                                 </item>
                             </item>
                         </item>
                     </argument>
                 </arguments>
                 <container name="minicart.addons" label="Mini-cart promotion block"/>
             </block>`
    

Could it be that I am missing or filtering out any Javascript loading in the custom theme? The theme I'm using is built upon Magento2-sass-tailwind-theme with mostly upgrades to styles.

If anyone could point me in the right direction, I would be most grateful.

2 Answers 2

0

Please check your theme minicart folder, It has .html files.

Magento_Checkout/web/template/minicart/

Match your theme file with vendor files.

The issue seems to be in .html files inside the theme having some HTML tags miss match

2
  • There are no template files inside the Magento_Checkout folder in my theme. I have tried placing the base templates from the Magento source in my theme, but the result stays the same.
    – BroodjeBE
    Commented Jun 28, 2023 at 6:31
  • Check in custom module and run this command : rm -rf generated/* var/cache/* var/view_preprocessed/* var/page_cache/* pub/static/frontend/*
    – MP Raj
    Commented Jun 28, 2023 at 6:41
0

You should look at the error message:

Message: this.itemRenderer is undefined.
getItemRenderer@yourMagentoDomain/.../MagentoCheckout/js/view/minicart.js:131:33

It is called in line 131 in vendor/magento/module-checkout/view/frontend/web/js/view/minicart.js

getItemRenderer: function (productType) {
    return this.itemRenderer[productType] || 'defaultRenderer';
},

itemRenderer is the config declared in vendor/magento/module-checkout/view/frontend/layout/checkout_cart_sidebar_item_renderers.xml. Check your custom themes, custom modules, third-party modules, and third-party theme to ensure nothing overrides minicart_content (the parent of itemRenderer) component and removed the itemRenderer config or something similar.

You can leverage the Knockoutjs context debugger browser extension to debug this issue: https://chrome.google.com/webstore/detail/knockoutjs-context-debugg/oddcpmchholgcjgjdnfjmildmlielhof

More information about it: https://developer.adobe.com/commerce/frontend-core/ui-components/debug/

Update: I've checked your previous post, which indicated you missed the config for itemRenderer. So, to resolve your issue, add this config to "minicart_content" in your xml file (as you mentioned, it is default.xml?):

<argument name="jsLayout" xsi:type="array">
    <item name="components" xsi:type="array">
        <item name="minicart_content" xsi:type="array">
            <item name="config" xsi:type="array">
                <item name="itemRenderer" xsi:type="array">
                    <item name="default" xsi:type="string">defaultRenderer</item>
                    <item name="simple" xsi:type="string">defaultRenderer</item>
                    <item name="virtual" xsi:type="string">defaultRenderer</item>
                </item>
            </item>
            ...
        </item>
    </item>
</argument>

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.