3

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.

1

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.

| improve this answer | |
  • I have adjusted the code to load the layout prior to me editing the cart; however, it will not show the updates. I have the following at the beginning of my controller action: $this->loadLayout(); $this->getLayout()->generateXml(); $this->getLayout()->generateBlocks(); I then do my edits and render the blocks necessary capturing the HTML output. – Brett Apr 9 '15 at 19:04

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.