3

I am working on ajax cart. When i update the cart qty, I am trying to reload the quote but its not loading properly

$this->cart->getQuote()->getShippingAddress()->collectShippingRates()->save();
$this->cart->getQuote()->setTotalsCollectedFlag(false);
$this->cart->getQuote()->collectTotals();
$this->cart->getQuote()->save(); 

How to reload the quote so that total calculation should happen properly in magento1 we use cart::init()

  • 1
    did you get any success on this? – Pallavi Nov 3 '16 at 12:22
  • did you get any success on this? i am getting same problem – Navin Bhudiya Feb 15 '18 at 8:42
0

I hope this may helps you

After add to cart run this code:

use Magento\Framework\Session\SessionManagerInterface;
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
use Magento\Framework\Stdlib\Cookie\PublicCookieMetadata;
use Magento\Framework\Stdlib\CookieManagerInterface;

in constructor:

    CookieManagerInterface $cookieManager,
    CookieMetadataFactory $cookieMetadataFactory,
    SessionManagerInterface $sessionManager,

After product was added to cart

$metadata = $this->_cookieMetadataFactory
        ->createPublicCookieMetadata()
        ->setPath('/');

$sectiondata = json_decode($this->_cookieManager->getCookie('section_data_ids'));

$sectiondata->cart += 1000;

$this->_cookieManager->setPublicCookie(
    'section_data_ids',
    json_encode($sectiondata),
    $metadata
);  

Before trying above code try with frontend/section.xml :

 <action name="NAMESPACE/MODULE/CARTUPDATE/">
     <section name="cart"/>
 </action>

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.