1

I try to override the following template from my own module

vendor\magento\module-checkout\view\frontend\web\template\minicart\item\default.html

but I don't find the file where I can override it, I searched the whole module-checkout folder for the place where the default.hmtl is added, but can't find it.

Is it possible to override the file?

1

You can override this by adding this folder to your theme:

Magento_Checkout/web/template/minicart

In this folder you can create the default.html file. After a change made in this file make sure you flush your browser cache to see the changes.

OR

After changes in default.html file, we have to deploy static file using command php bin/magento setup:static-content:deploy

Reference : Magento 2: How to override mini-cart default template html file?

2
  • I tried to figure out how to override it in my module though, not theme. And whats the content.html file? Do you mean default.phtml? – Black Aug 11 '20 at 9:10
  • @Black, yes "default.html" – Chirag Rajput Aug 11 '20 at 9:18
0

I searched for minicart/item and now I found:

vendor\magento\module-checkout\view\frontend\layout\checkout_cart_sidebar_item_renderers.xml

I override it like this:

<?xml version="1.0"?>
<!--
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="minicart">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="minicart_content" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="item.renderer" xsi:type="array">
                                    <item name="config" xsi:type="array">
                                        <item name="template" xsi:type="string">Vendor_Module/minicart/item/default</item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>
0

cretae requirejs-config.js

Copy default.html vendor\magento\module-checkout\view\frontend\web\template\minicart\item\default.html

past app/code/Vendor/Module/view\frontend\web\template\minicart\item\default.html

app/code/Vendor/Module/view/frontend/requirejs-config.js

var config = {
    map: {
        '*': {
            "Magento_Checkout/template/minicart/item/default.html":
                "Vendor_Module/template/minicart/item/default.html"
        }
    }
};
3
  • Does not work for me – Black Aug 11 '20 at 9:55
  • override checkout_cart_sidebar_item_renderers.xml – Himanshu Aug 11 '20 at 10:40
  • Thats a duplicate of my answer now. – Black Aug 11 '20 at 11:01

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.