Would you suggest the possible reason for the cart summary is displaying '0'?
Please see the screenshot:
https://prnt.sc/od4sy7
This happens after an ajax call which is running two functions below:
protected function _updateShoppingCart()
{
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->addInfo("_updateShoppingCart");
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$customerSession = $objectManager->get('Magento\Customer\Model\Session');
$postcode = $this->getRequest()->getParam('postcode');
$customerSession->setPostcode(($postcode==null?"":$postcode));
try {
$cartData = $this->getRequest()->getParam('cart');
$this->_checkoutSession->setMyValue($cartData);
if (is_array($cartData)) {
$filter = new \Zend_Filter_LocalizedToNormalized(
['locale' => $this->_objectManager->get(
\Magento\Framework\Locale\ResolverInterface::class
)->getLocale()]
);
foreach ($cartData as $index => $data) {
if (isset($data['qty'])) {
$cartData[$index]['qty'] = $filter->filter(trim($data['qty']));
}
}
if (!$this->cart->getCustomerSession()->getCustomerId() && $this->cart->getQuote()->getCustomerId()) {
$this->cart->getQuote()->setCustomerId(null);
}
$cartData = $this->cart->suggestItemsQty($cartData);
$this->cart->updateItems($cartData)->save();
$this->_checkoutSession->setMyValue($cartData);
}
} catch (\Magento\Framework\Exception\LocalizedException $e) {
$this->messageManager->addException($e, __('We can\'t update the shopping cart.'));
$this->messageManager->addError(
$this->_objectManager->get(\Magento\Framework\Escaper::class)->escapeHtml($e->getMessage())
);
} catch (\Exception $e) {
$this->messageManager->addException($e, __('We can\'t update the shopping cart.'));
$this->_objectManager->get(\Psr\Log\LoggerInterface::class)->critical($e->getMessage()."------2");
}
}
protected function _getTotalsHtml()
{
$resf = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
$layout = $resf->addHandle('checkout_cart_index')->getLayout();
$response['cartcontent'] = $this->_view->getLayout()->getBlock('checkout.cart.form')->toHtml();
$response['checkout_method'] = $this->_view->getLayout()->getBlock('checkout.cart.methods.bottom')->toHtml();
$response['page_messages'] = $this->_view->getLayout()->getBlock('checkout.cart.validationmessages')->toHtml();
$response['content'] = $layout->renderNonCachedElement('checkout.cart.empty');
$cartQuote= $this->cart->getQuote()->setTotalsCollectedFlag(false)->collectTotals()->save();
$response['subtotaldata'] = $this->_objectManager->create('Magento\Checkout\Model\DefaultConfigProvider')->getConfig();
$resultJson = $this->resultFactory->create(ResultFactory::TYPE_JSON);
$resultJson->setData($response);
$this->_checkoutSession->getQuote()->collectTotals()->save();
return $resultJson;
}
The grand totals become '0', once in 2 times.