Now add and remove products are taking place via ajax. But when the product is out of stock I want to remove the proceed to checkout button via ajax.
Once that out of stock product has been removed from cart, proceed to checkout button should be displayed again.
public function deleteAction()
{
if ($this->getRequest()->isXmlHttpRequest()) {
$itemId = (int) $this->getRequest()->getParam('id');
$msg = '';
if ($itemId) {
try {
$this->_getCart()->removeItem($itemId)
->save();
$msg = $this->__('Item was removed successfully.');
} catch (Exception $e) {
$msg = $this->__('Cannot remove the item.');
// $this->_getSession()->addError($this->__('Cannot remove the item.'));
Mage::logException($e);
}
}
//$this->_redirectReferer(Mage::getUrl('*/*'));
$layout = $this->getLayout();
$update = $layout->getUpdate();
$update->load('born_checkout_cartheader');
$layout->generateXml();
$layout->generateBlocks();
$minicartHtml = $layout->getOutput();
$update->setCacheId(null);
$update->load('born_checkout_cart');
$layout->generateXml();
$layout->generateBlocks();
$cartHtml = $layout->getOutput();
$result = array('minicartHtml' => $minicartHtml,'cartHtml' => $cartHtml,'msg' => $msg);
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
} else {
parent::deleteAction();
}
}