1

I'm trying to reload the cart page with AJAX. I'd like to send a "checkout.cart" block via JSON to replace in AJAX call. In my controller (I overrided CartController.php), I'm trying to call the line:

$checkout_page = $layout->getLayout()->getBlock('checkout.cart')->toHtml();
$response['checkout_block'] = $checkout_page;
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($response));

But a error happen

Fatal error: Call to a member function toHtml() on boolean in C:\D\Websites\magento\app\code\local\Excellence\Ajax\controllers\IndexController.php on line 211

1

if your action which will reload "checkout.cart" in Excellence\Ajax\controllers\IndexController.php named: reloadCart()

you go to checkout.xml and update like this:

<checkout_cart_index>
    ....
</checkout_cart_index>

<ajax_index_reloadcart>
    <update handle="checkout_cart_index"/>
</ajax_index_reloadcart>

then it will works.

ref: http://forum.azmagento.com/how-to/mage_checkout_cartcontroller-class-getblock-8217-8217-checkoutcart-8217-8217-is-false-solved-nbsp--60544.html

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.