Is there a way to hide the Shopping Cart on Top Menu when it's empty? I believe it is on Links.php file but I don't know what code to add. Also, "Links.php" is a Core file, I am thinking on creating a new module on Local for it. Would it work? Thanks.
Asked
Active
Viewed 1,701 times
2 Answers
0
Hide the shopping cart side bar when it is empty:
1. Open: app/design/frontend/default/<your template>/template/checkout/cart/sidebar.phtml
2. Go to line 32 Look for
<div class="box base-mini mini-cart">
3. Add these lines right before that opening div tag
<?php $_cartQty = $this->getSummaryCount() ?>
<?php if ($_cartQty >0): ?>
4.Add this line to the bottom of the file
The shopping cart will only show if user adds items to their shopping cart.
Or use these plugin... it's a free plugin for hiding when it is empty.. Xogenics Hide Cart for Magneto
For hiding in header menu use this
Remove My Cart and Checkout links from the header menu.The code for these links is located in the
checkout.xml
file:
In Magento, on your ecommerce site may be you do not want to show MyCart or Checkout links.Follow the steps below to remove the link.
1. Copy the file checkout.xml from app/design/frontend/base/default/layout to app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout or app/design/frontend/default/YOUR_THEME/layout
2. Edit the checkout.xml copied to the app/design/frontend/YOUR_PACKAGE/YOUR_THEME/layout folder or app/design/frontend/default/YOUR_THEME/layout folder
3. Look for the following Code snippet
<reference name="top.links">
<block type="checkout/links" name="checkout_cart_link">
<action method="addCartLink"></action>
<action method="addCheckoutLink"></action>
</block>
</reference>
4. Comment the following Lines
4.1 Comment the following Line to Remove My Cart Link from header
<!--<action method="addCartLink"></action>-->
4.2 Comment the following Line to Remove Checkout Link from header
<!--<action method="addCheckoutLink"></action>-->
5. Refresh the Magento Cache and Website Page to see the changes

Bruce
- 1,647
- 4
- 20
- 22
-
Thank you for you answer. I have added this code on sidebar.phtml already but to hide it on sidebar, and it worked but I want to hide the Cart on the top when it is empty. Thanks. – CDFT Jun 13 '15 at 04:15
-
I have done that in the past. What I want is to hide the Top Menu's Shopping Cart, not the sidebar one. – CDFT Jun 13 '15 at 04:53
-
Thank you very much. When an user adds a product, will it show again? Also, could you help me out with this issue also http://stackoverflow.com/questions/30720701/highlight-current-link-on-navigation-bar? I haven't been able to find a solution so far. – CDFT Jun 13 '15 at 05:09
-
You asked to hide when it is empty only...? – Bruce Jun 13 '15 at 05:11
-
Yes, only when it is empty. When an user adds an item to cart I want it to show again. – CDFT Jun 13 '15 at 05:12
-
Then you don't want to display cart when user adds also means don't add these lines `
` – Bruce Jun 13 '15 at 05:15 -
I have checked the files and they are already commented out and cart is still showing. Something is wrong. – CDFT Jun 13 '15 at 05:25
-
Then comment the block fully `` – Bruce Jun 13 '15 at 05:48
0
$(document).ready(function(){
$(".top-car").hide();
});
First check if there's quantity in the cart ofcourse with something like:
$qty = $this->helper('checkout/cart')->getSummaryCount()
Hope this helps you

Gijsve
- 78
- 2
- 11