So I need to check if the cart on my magento site is empty or not. I can do this using php like this:

    $count = $this->helper('checkout/cart')->getSummaryCount();
      echo '<a href="#" data-url="checkout/cart/add/product/59/form_key/' . Mage::getSingleton('core/session')->getFormKey() . '" class="btn btn-success ac-button-top add-to-cart">Order</a>';
    } else {
      echo '<a href="' . $this->getUrl('checkout/cart') .'" class="btn btn-success ac-button-top add-to-cart">CHECKOUT</a>';

However, the problem is that using PHP it will get cached.
So in order for the button to change you'd have to refresh the cache.
So I was wondering if there is any way to do this check in javascript instead of PHP as I can't think of a way to do it?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.