Get Product Id’s From Cart Session
Here’s another quick and easy way of getting your cart data back from Magento. You may remember in a previous post that I used the checkout/session singleton to find out which attribute id your chosen products were from. 1.4.2.0 and later remove this function and require something like the following:
First of all re-define your session scope:
Mage::getSingleton('core/session', array('name' => 'frontend'));
Secondly go ahead and attach the cart model to a variable:
$cart = Mage::getModel('checkout/cart');
Now that we have the cart model we can go ahead and retrieve the following:
$ids = $cart->getProductIds(); $qty = $cart->getSummaryQty();
What the above will do is retrieve an array of all product ID’s that are in the cart and also a sum of all quantities in the cart. With these you can create your own little box which displays the number of products and also the total quantities of all items in your basket.
Another little trick while we are on the subject of carts is if you wish to create your own “clear cart” button this why not add this little piece of code:
Mage::getSingleton('core/session', array('name'=>'frontend'));
Mage::getSingleton('checkout/session')->clear();
That’s all for today – hope you found it useful in some way – what I’ve found is it’s always good to write down these little snippets of code – it will save you hours of hunting for the same thing further down the road. Thanks for visiting the Magento Blog here at E-commerce Web Design – home of the Magento Fox!

Cool little snippit, Thanks for sharing!
I have created custom shopping cart popup by using some basic provided on blog, How to get all shopping cart items and total.
http://www.phptechi.com/magento-how-to-get-all-shopping-cart-items-and-total.html
hello.
How can I do to put this information in a form and send it by mail? as in: “Product Name Prefills Contact Form” http://www.e-commercewebdesign.co.uk/blog/magento-tutorials/product-name-prefills-contact-form.php
tnx
i need to clear the abandoned carts, but where do i put this snippets?
how to get product company address and company name ? what is the code like
what should i write instend of getShortDescription() ?