Magento 2 - Get Current Cart Items

Magento 2 - Get Current Cart Items:


use the session to get the quote 

public function __construct(
        ...
        Magento\Checkout\Model\Session $session
        ...
    ) {
        ...
        $this->_session = $session;
        ...
    }



public function yourFunctionName()
{
    $items = $this->_session->getQuote()->getAllVisibleItems();
}


NOTE : Magento\Checkout\Model\Cart is deprecated.

Comments