I'm using this extension:

Ajax Cart Popup

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);
        $toplinks = $this->getLayout()->getBlock('cart_header')->toHtml();
        preg_match('/<a.+top-link-cart.+>(.+)<\/a>/Us', $toplinks, $linktext);

    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?

1 Answer 1


I figured it out. It was just a wrong block name in _getLinkText() method. Now it's fine. For future reference if someone has the same problem you can easily determine if the right block is loaded by using this extension:

Magento Debug

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.