How to remove specific item from cart Magento 2?

You can delete specific quote items from the cart by quote id and item id in Magento 2.

With the help of Cart Item Interface, Magento\Quote\Api\CartItemRepositoryInterface you can use the deleteById() method.

Prerequisite to delete quote item:

          • Quote ID
          • Quote Item ID

Continue reading “How to remove specific item from cart Magento 2?”

How to Get Current Quote Id by Checkout Session Magento 2?

To Retrieve the current quote ID from the cart checkout page, You need to use a checkout session to fetch all the information related to quote data.

Use Magento\Checkout\Model\Session to inject the object using the class __construct() method. While you working with the checkout page and need to fetch quote data by current quote id, in this case, this article is useful for you.

The checkout session contains the quote data and using session fetch getQuote(), based on the quote, you can get any quote-related data. Continue reading “How to Get Current Quote Id by Checkout Session Magento 2?”

How to retrieve Masked id from the cart id Magento 2?

Retrieve Masked id (guest cart hash) from the cart id in Magento 2, You required the cart quote id.

masked_id is stored in the quote_id_mask table, it’s the randomly generated string for the guest customer quote in Magento 2.

You can retrieve masked id string by using an interface,
Magento\Quote\Model\QuoteIdToMaskedQuoteIdInterface Continue reading “How to retrieve Masked id from the cart id Magento 2?”