Frequently Asked Questions
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.
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
public function __construct(\Magento\Quote\Model\Quote $quote)
$this->quote = $quote;
* @return int
public function getQuoteId()
And that’s it. With this code, you can get a cart ID and use it for your purposes in Magento 2.