I'm using this extension:
It works fine, but there is a problem of updating items counter which renders together with mini cart icon in the header.
With original developers help on GitHub I've figured out how it works. It takes cart complete link with count span strips out everything except value within that span element and after updates using js.
My problem is here (module controller):
private function _getLinkText()
{
if ($block = $this->getLayout()->getBlock('cart_header')):
$cartlink = $block->toHtml();
preg_match('/<a.+skip-cart.+>(.+)<\/a>/Us', $cartlink, $linktext);
else:
$toplinks = $this->getLayout()->getBlock('cart_header')->toHtml();
preg_match('/<a.+top-link-cart.+>(.+)<\/a>/Us', $toplinks, $linktext);
endif;
return $linktext[1];
}
Regex pattern match should give something like:
`<span class="label"><i class="fa fa-cart-arrow-down fa-2x"></i></span><span class="count">11</span>`
However $linktext var which should contain the complete link is always null which I can see from JSON key in debugger. That why I get no update of counter. I think the right Block is loaded (cart_header), at least Magento Debugger Tool says so, but for some reason there is no matching pattern from that function. Could it be that Block is not loaded at he right time which I find very unlikely since ajax calls are made after the whole page has been loaded? Any other ideas?