So I need to check if the cart on my magento site is empty or not. I can do this using php like this:
<?php
$count = $this->helper('checkout/cart')->getSummaryCount();
if($count==0){
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?