Show the shopping cart sidebar only if it has items

Usually the shopping cart sidebar by default always shows up, even if there aren’t any items in it. This is taking up valuable real estate that isn’t any value to your customer.

A few lines of code will change the display so that it only appears when the customer has items in their cart.

OPEN: app/design/frontent/YOURPACKAGE/YOURTHEME/template/checkout/cart/sidebar.phtml

At the very beginning, add the following lines of code and comment out the redundant qty check


 

?>
<?php // mod to only display cart when it has items ?>
<?php $_cartQty = $this->getSummaryCount() ?>
<?php if ($_cartQty >0): ?>

<?php if ($this->getIsNeedToDisplaySideBar()):?>
<div class="block block-cart">
<?php //$_cartQty = $this->getSummaryCount() ?>
<div class="block-title">

and then at the very end, add a closing endif statement


</div>
<?php endif;?>

<?php endif; // cart mod?>

Upload your changes and the cart will only appear when it makes sense for the customer!

 

Leave a Reply