Magento – Reload Quote In Controller Action

ajaxcart

I have a custom action which I use to adjust some options for products. This is done from the cart with an AJAX request. I'd like to be able to just return the adjusted item's HTML and update that table row. I can successfully edit the cart item options; however, when rendering that item no options show up in the returned HTML. If I refresh the page, then the options appear.

Is there any way I can "refresh" or "reload" the quote within the cart and session? I've tried the following code after I've done my cart edits and before I start the layout rendering.

    $quote = Mage::getModel('sales/quote')->load($cart->getQuote()->getId());

    $cart->getQuote()->collectTotals()->save();
    $this->_getSession()->replaceQuote($quote);
    $cart->setQuote($quote);
    $cart->init();

That does not sufficiently reload the quote so that the Cart block uses the updated quote.

UPDATE: It appears that the only issue is the item options not showing up, not that it's not showing the updated cart. It's just custom options that are added which aren't showing up. So the real question seems to be reloading options for quote items.

Best Answer

According to your code, you have replace current quote and items and other data at session class checkout/session Mage::getSingleton('checkout/session') using function replaceQuote() .

As per as magento,the session variable does not affective until one time page rendered and cart block content depend on checkout session. So you need to rendered the page and update cart block content via ajax.

Related Topic