Log in
Model

Cart

Magento\Checkout\Model\Cart

What it does

The Cart model manages the shopping cart functionality in Magento 2, providing methods to add, update, and remove products from the cart, as well as managing cart quantities and saving cart data.

Developers use this class when implementing custom cart features, adding products programmatically, or extending checkout functionality.

It acts as a facade for the underlying Quote model, handling product validation, stock checks, and event dispatching during cart operations.

Public Methods

  • getCheckoutSession()
  • getCustomerSession()
  • getItems()
  • getQuoteProductIds()
  • getQuote()
  • setQuote()
  • addOrderItem()
  • addProduct()
  • addProductsByIds()
  • suggestItemsQty()
  • updateItems()
  • removeItem()
  • save()
  • saveQuote()
  • truncate()
  • getProductIds()
  • getSummaryQty()
  • getItemsCount()
  • getItemsQty()
  • updateItem()