Log in or create an account
If you have an account with us, please log in.

You have no items in your shopping cart.

Frequently Asked Questions

How can we help you?

banner image

How to get a current quote ID from a checkout session in Magento 2?

When we are talking about cart processing from the technical side, we often need to get current quotes in Magento 2. It is used for such functions as adding products to the cart, processing them, applying discounts, etc.

Our Request a Quote plugin is a good example of how you can use received code in your custom plugins. This extension allows buyers to request a special price according to the number of items they want to purchase. For instance, it may be useful for B2B stores that offer personal discounts for wholesale customers. In this plugin, we have an additional quote cart into which you can add products to form a request. 

How to get a quote ID from the checkout session Magento 2?

Warning: The code is illustrative. You may need to do some customization to make it work with your Magento 2 installation.

 * @var \Magento\Quote\Model\Quote
 private $quote;
 public function __construct(\Magento\Quote\Model\Quote $quote)
 $this->quote = $quote;
 * @return int
 public function getQuoteId()
 return $this->quote->getId();

And that’s it. With this code, you can get a cart ID and use it for your purposes in Magento 2.

Rate the answer?

Total rating: 5.0

If you didn’t find the answer on your question, please, ask here:

Back to top