3

I want to hide qty box and remove/delete icon from mini cart for few products. For this I overwrite checkout_cart_sidebar_item_renderers.xml

<?xml version="1.0"?>
<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="component" xsi:type="string">uiComponent</item>
                                    <item name="config" xsi:type="array">
                                        <item name="displayArea" xsi:type="string">defaultRenderer</item>
                                        <item name="template" xsi:type="string">Custom_Module/minicart/item/default</item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

Then create default.html file under Custom/Module/view/frontend/web/template/minicart/item/default.html

But after doing this I found minicart is blank. like below image. Can you please help me to understand my mistake?

Mini Cart

1 Answer 1

1

Try this,

Add requirejs-config.js in the following path

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

then add the below code in it

var config = {
map: {
    '*': {
        'Magento_Checkout/template/minicart/item/details.html':
            'Custom_Module/template/minicart/item/default.html'
    }

}};

then copy the file from

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

to

app/code/Custom/Module/view/frontend/web/template/minicart/item/default.html

and run below comments in you magento root after made these changes

rm -rf pub/static/frontend/
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f
php bin/magento cache:flush

Hope this helps :)

10
  • means I need to add require-config.js with my existing code or I need to remove layout file? Mar 6, 2019 at 7:14
  • Remove the checkout_cart_sidebar_item_renderers.xml from your custom module then do the above things and it will help you Mar 6, 2019 at 7:16
  • after doing this mini cart not showing product correctly, I added two product in the cart but mini cart display only one product. The count is perfect but displays only one product. I need to overwrite some other file or not for this, Please help me. Mar 6, 2019 at 7:33
  • In the cart page two product showing perfectly but not in minicart. Mar 6, 2019 at 7:34
  • Right now all products are showing after running the command. I want to hide qty box and remove icon in cart page and I can see my code under pub/static folder in my module. But in mini cart section, it is not reflected. Below are my code <!-- ko if: is_visible_in_site_visibility --> <!-- /ko --> This I need to add before qty box and remove icon [This is used for edit button, I copied this condition and add before qty and remove icon section] Mar 6, 2019 at 7:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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