#StackBounty: #magento2 #knockoutjs #requirejs #magento2.4 #default.xml <referenceBlock name="header.container" remove=&qu…

Bounty: 100

I’ve added <referenceBlock name="header.container" remove="true" /> to my themes default.xml and instead has been replaced with:

<referenceContainer name="page.wrapper">
    <block  class="MagentoFrameworkViewElementTemplate" 
            name="top.header" 
            template="Magento_Theme::html/custom_header.phtml" 
            before="header.container"
    />
</referenceContainer>

But, by doing this I lose all of the minicart functionality. The JS is not added. This is a problem for me because when I attempt to get the cart total like so:

<div data-bind="scope: 'minicart_counter'">
    <span data-bind="html: getCartParamUnsanitizedHtml('summary_count')"></span>
</div>

<script type="text/x-magento-init">
    {
        "*": {
            "Magento_Ui/js/core/app": {
                "components": {
                    "minicart_counter": {
                        "component": "Magento_Checkout/js/view/minicart"
                    }
                }
            }
        }
    }
</script>

I get an error:

console-output-handler.js:34 [2020-11-12 10:34:54] [ERROR] Failed to load the 
"Magento_Checkout/js/view/minicart" component.

But if I make the header.container visible with <referenceBlock name="header.container" remove="false" /> my custom header shows the cart quantity total … except I now have two headers showing (the default one and my custom).

I’ve battled with this for hours to no avail. What am I missing?


Get this bounty!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.