I am working in magento 1.9.2.2. I am trying to add cart pop up and list the items added in the cart without using any extension.the pop up is appearing successfully. I dont exactly know how to list the items added to the cart with its name, price and items image in the pop up. I just wanted to know how to retrieve the item collection. My code which is not working:
<div id="header-cart1new" class="block block-cartnew skip-content">
<div class="ui-popover__pointer" style="left: 82%;"></div>
<div id="header-cart1" class="block block-cart11 skip-content">
<?php echo $this->getChildHtml('cart_sidebar'); ?>
<?php $cartitem = Mage::getModel('checkout/cart')->getQuote();
<?php if(count($cartitem)> '0'){
foreach ($cartitem->getAllItems() as $pro) {
$productId = $pro->getProductId();
$product = Mage::getModel('catalog/product')->load($productId);
$productName = $product->getName();
$productPrice = $product->getPrice();
}
} ?>
<?php else: ?>
<p class="empty">
<div class="text-center">
<h3 class="mini-cart-empty fontsize18 no-margin-btm">
Your Shopping Cart is empty.
</h3>
<h4 class="mini-cart-empty fontsize15">
What are you waiting for? Start shopping!
</h4>
</div>
</p>
<?php endif ?>
</div>
</div>
</div>
Best Answer
Try this code