Is there a way to hide the Compare and Wishlist blocks on the front-end (in the navigation) when they are not in use?
2 Answers
You can override the block using below file and can remove that using xml:
vendor/magento/module-catalog/view/frontend/layout/default.xml
By adding default.xml you can remove that, In your theme:
Vendor/Theme/Magento_Catalog/layout/default.xml
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
<referenceBlock name="wishlist_sidebar" remove="true" />
<referenceBlock name="catalog.compare.sidebar" remove="true"/>
</body>
</page>
-
Thanks for the answer. But I think I didn't explain it very well. The meaning is that when they are used (active). Thay they become visible in the sidebar if not, that they are not visible in the sidebar May 7, 2019 at 6:55
-
ok, for that you should count the number of item in that, if it is 0 then hide it. May 7, 2019 at 6:58
-
Can you provide me with the code please, i donw't want to make a mistake :) Sep 16, 2019 at 8:26
For wish List you can disabled via Admin
Stores => Configuration => Customers => Wish list => General Options > Enabled = No
For Compare you can hide via xml:
<referenceBlock name="catalog.compare.sidebar" remove="true"/>