When I put the code to show the number of items in the cart in my custom headerfile.phtml it doesn't work, but when I access a checkout page it works perfectly, what to do?
Here's the code:
<?php
$cart = $this->helper('\Magento\Checkout\Helper\Cart');
$itens = $cart->getQuote()->getItemsQty();
$itens = round($itens, 0);
if ($itens > 0)
echo $itens;
else
echo 0;
?>