Hide Shopping Cart on Top Menu When it is empty

1.7k views Asked by At

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.

2

There are 2 answers

8
Bruce On

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
0
Gijsve On
$(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