How to Get Current Quote Id by Checkout Session Magento 2?

To Retrieve Current Quote Id from the cart checkout page, You need to use a checkout session to fetch all the information related to quote data.

Use Magento\Checkout\Model\Session to inject the object using the class __construct() method. While you working with the checkout page and need to fetch quote data by current quote id, in this case this article is useful for you.

Checkout session contains the quote data and using session fetch getQuote(), based on the quote, you can get any quote related data.

Use Function with the method name,

You can also Optionally declare Session class as a proxy in the di.xml file to prevent resource-hungry specific class and call Session class as needed in the class.

Above Given XML File, Pass type name attribute value as Original Class Name with argument name is the checkoutSession and add suffix as the Proxy for the given class.

Leave a Reply