I can't get the current quote in the Product view page. I have 3 items in my cart.

I have used both files.

use Magento\Checkout\Model\Session;
use Magento\Checkout\Model\Cart;

$quote = $this->_checkoutSession->getQuote();
echo $quote->getId();

But, I can't get it. After that adding new product in view page. I can got it.

How to do that.


  • Where you use this code ? In observer or? Please explain more. Aug 5, 2019 at 11:55
  • I used this code in the custom model file in view page.
    – Mahi M
    Aug 5, 2019 at 11:56
  • I want to get a quote on page load
    – Mahi M
    Aug 5, 2019 at 12:00
  • Let me know if you still can't able to get quote. Aug 5, 2019 at 12:23

1 Answer 1


I think u have to add getAllVisibleItems() for get quote item

    $om = \Magento\Framework\App\ObjectManager::getInstance();
    $cartData = $om->create('Magento\Checkout\Model\Cart')->getQuote()->getAllVisibleItems();
    echo $cartData->getId();
  • Its also not working
    – Mahi M
    Aug 5, 2019 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.