On clicking on Add-to-cart, the price is added to cart, in Mini cart it shows cart subtotal and this cart subtotal is saved in the quote table database.
So my question is:
How is these cart subtotal is getting saved to database? from which file?
-
I Mean Cart subtotal, by observer is saving in database or any other way he is saving the value in quote table database– Learing_CoderCommented Feb 14, 2017 at 5:47
Add a comment
|
1 Answer
Take a look the Add to Cart controller vendor/magento/module-checkout/Controller/Cart/Add.php
$this->cart->save();
Go to the save method: vendor/magento/module-checkout/Model/Cart.php
$this->getQuote()->collectTotals();
$this->quoteRepository->save($this->getQuote());
As we can see, Magento will use Magento\Quote\Model\QuoteRepository
to save the quote with collect totals to database.
-
It is helpful,But i need to know how is cart subtotal is getting stored in quote table,above answer is close that the data is getting saved in quote table,but i need to know only where exactly the cart subtotal is saving from Commented Feb 16, 2017 at 4:16
-
@PranayK I think it's better if you debug the code lines above. Commented Feb 16, 2017 at 4:50
-
@KhoaTruongDinh If I am trying to delete item from quote item, then how to execute collect total? I have quote Id, Item id. how do I save? Commented Apr 20, 2020 at 11:59