I am working with magento 2. I got php error when am using
echo Mage::helper(‘checkout/cart’)->getCart()->getItemsCount();
how to get cart item count in magento 2?
$counter = $this->helper('\Magento\Checkout\Helper\Cart');
echo $counter->getItemsCount();
Magento 2 provides 2 ways to show items count. One shows the number of individual items in the cart, while the other one shows the total count of items in the cart.
Let us say that cart helper is;
$helper = $this->helper('\Magento\Checkout\Helper\Cart');
When you do:
echo $counter->getItemsCount();
it will show the number of individual items in the cart.
If you want to show total items count, then use:
echo $counter->getSummaryCount();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With