Magento: How to get all shopping cart items and total

In this article I'll talk about how to get all shopping cart items and total in Magento Shopping Cart. lets move on to the point.

[php]
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();
foreach($items as $item) {
echo 'Product ID: '.$item->getProductId().'<br>';
echo 'Product Name: '.$item->getName().'<br>';
echo 'Product Sku: '.$item->getSku().'<br>';
echo 'Product Quantity: '.$item->getQty().'<br>';
echo 'Product Price: '.$item->getPrice().'<br>';
if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()):
$_incl = $this->helper('checkout')->getPriceInclTax($item);
echo 'Product Price: '. $this->helper('checkout')->formatPrice($_incl- $item->getWeeeTaxDisposition());
else:
echo 'Product Price: '. $magento_style_price = Mage::helper('core')->currency($item->getPrice());
endif;
echo "<br>";
}
// Total items added in cart
$totalItems = Mage::getModel('checkout/cart')->getQuote()->getItemsCount();
// Total Quantity added in cart
$totalQuantity = Mage::getModel('checkout/cart')->getQuote()->getItemsQty();
// Sub Total for item added in cart
$subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal();
//grand total for for item added in cart
$grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();

[/php]