I am currently trying to add a product to my cart useing this code.
$quote = $this->_session->getQuote();
$quote->addProduct($product);
$this->_cartRepository->save($quote);
When I do this in a new session, the price of the product and the subtotal show as 0.00, but in the summary the Subtotal and Order Total are correct.
After editing the product quantity, the prices all function as they should.
I have tried to use $quote->collectTotals();
, but this gives no visible changes.
How can I update cart so that the price of the product shows when I open the cart page?
2
Answers
Try with this code:
Or
You need to reload the quote from a DB to have all collectedTotals flags empty there.
See
MagentoQuoteModelQuote::collectTotals
andMagentoQuoteModelQuoteAddressTotalSubtotal::collect