How to show total shopping cart price in Magento Header

       If you go to pretty much any e-commerce site you will see in the header your quick cart details, these will consist of how many items are in your basket and how much your current total is. By default Magento only shows you how many items are currently in your basket and no total. As a store owner you want to give your customers as much detail as possible and knowing how much they are spending on your site is something the customer may want to know without having to go to their basket to see their current total.

       The solution below shows you how to add the price total of the basket to your basket details; this is a really easy and quick solution. Firstly navigate toyourtemplatename/page/html/header.phtml and copy the code below to where you want it displayed.

<?php
$count = $this->helper('checkout/cart')->getSummaryCount();  //get total items in cart
$total = $this->helper('checkout/cart')->getQuote()->getGrandTotal(); //get total price
echo $this->__(' Total: %s', $this->helper('core')->formatPrice($total, false));
?>
 

      That’s it, you will now be able to add products to your site and see the basket totals update in your header. Don’t forget to refresh your cache if you don’t see this code working.

你可能感兴趣的:(header)