:::: MENU ::::
Posts tagged with: magento 2 quote

magento 2 get current quote

Today we talk about how Magento 2 get current quote. You can get quote data from the checkout session. You can get data to manipulate the data in the cart. So let start with our example.

namespace QaisarSatti/HelloWorld/Block;

use Magento\Backend\App\Action;

class GetQuote extends Action

    protected $checkoutSession;

    public function __construct(
              \Magento\Checkout\Model\Session $checkoutSession    
        $this->checkoutSession = $checkoutSession;

    public function getQuotes()
            return $this->checkoutSession->getQuote();


Now we call our function and get a quote data.

$allItems = $this->getQuotes()->getAllVisibleItems();
foreach ($allItems as $item) {
    echo $item->getProductId();
Author: Qaisar Satti
Category: Magento 2
Last Modified: November 2, 2020