1

I have to show the total quantity of the items in the cart. I'm doing this now with:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');

$totalItems = $cart->getQuote()->getItemsCount();
$totalQuantity = $cart->getQuote()->getItemsQty();

echo $totalQuantity;

I have 5 items in the cart and the $totalQuantity will show 5.0000 Why is that? And how can I just display 5?

Regards, Robert

1 Answer 1

2
echo round($totalQuantity); 

PHP built in function round() will do the job.

1
  • AWESOOOOOMEEEEE! :)
    – n00bly
    Mar 6, 2018 at 9:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.