what's the best replace for

\Magento\Checkout\Model\Cart $cart

since this class Cart is deprecated ?

  • 1
    @deprecated 100.1.0 Use \Magento\Quote\Model\Quote instead clearly written in the class – Philipp Sander Jan 21 '19 at 14:54

You can use cart Items by two ways

  1. Inject direct \Magento\Quote\Model\Quote and get cart items

  2. Inject Magento\Checkout\Model\Session from checkout session get Quote to get Items like that using $items = $this->session->getQuote()->getAllVisibleItems();

     class Reepaypayment {
         protected $session;
         public function __construct(
             \Magento\Checkout\Model\Session $session
         ) {
             $this->session = $session;
         public function afterIsAvailable(
             \Radarsofthouse\Reepay\Model\Reepaypayment $subject,
         ) {
             $items = $this->session->getQuote()->getAllVisibleItems();
             return $result;


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.