Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento How to check if the shopping cart is empty or not?

I am trying to check if the shopping cart is empty or not. I am trying to do this from a static block and from a phtml file.

Anyone know how to do this?

Thanks in advance

like image 778
Wesley Smits Avatar asked Oct 08 '12 09:10

Wesley Smits


2 Answers

I was able to find the total count of items in the shopping cart using the following code:

$totalItemsInCart = Mage::helper('checkout/cart')->getItemsCount();

If it does not work, let me know.

like image 178
Mukesh Avatar answered Sep 28 '22 02:09

Mukesh


You can try this.

$cart_qty = (int) Mage::getModel('checkout/cart')->getQuote()->getItemsQty();

if($cart_qty) {
    // Not empty.
} else {
    // Empty.
}
like image 23
Cj Belo Avatar answered Sep 28 '22 03:09

Cj Belo