A quote is a temporary object that represents the customer’s shopping cart before it is converted
into an order1. A quote can be created by a guest or a registered customer, and it can be active or
inactive depending on whether the customer has completed the checkout process or not2.
The quote table stores the basic information about the quote, such as the customer ID, email,
currency, subtotal, grand total, shipping method, payment method, and so on2. Each row in the
quote table corresponds to one quote object, identified by a unique entity ID2.
The quote item table stores the details of each product added to the quote, such as the product ID,
SKU, name, price, quantity, discount amount, tax amount, and so on2. Each row in the quote item
table corresponds to one quote item object, identified by a unique item ID2. A quote item object is
associated with a quote object by the quote ID column in the quote item table2.
When a customer adds a product to the cart, Magento creates or updates a quote object and a quote
item object for that product. The quote object is initialized by the Magento\Quote\Model\Quote
class, which implements the Magento\Quote\Api\Data\CartInterface interface3. The quote item
object is initialized by the Magento\Quote\Model\Quote\Item class, which implements the
Magento\Quote\Api\Data\CartItemInterface interface3.
Magento uses various classes and interfaces to manipulate the quote and quote item objects, such
as
the
Magento\Quote\Model\QuoteRepository
class,
which
implements
the
Magento\Quote\Api\CartRepositoryInterface interface for saving and retrieving quotes from the
database3, and the Magento\Quote\Model\QuoteManagement class, which implements the
Magento\Quote\Api\CartManagementInterface interface for creating and submitting quotes to
orders3.
Magento also uses various events and observers to perform additional actions on the quote and
quote item objects, such as applying discounts, calculating taxes, validating stock availability, and so
on.
Some
of
these
events
are:
sales_quote_add_item,
sales_quote_collect_totals_before,
sales_quote_collect_totals_after,
sales_quote_save_before,
sales_quote_save_after,
sales_model_service_quote_submit_before, sales_model_service_quote_submit_after.
Magento provides various APIs for interacting with the quote and quote item objects, such as the
Magento\Quote\Api\CartManagementInterface API for creating empty carts and placing orders from
carts, the Magento\Quote\Api\CartItemRepositoryInterface API for adding, updating, and removing
items from carts, and the Magento\Quote\Api\CouponManagementInterface API for managing
coupons for carts.