How to Get Quote Id by Masked id Magento 2.

Retrieve Quote id from the masked hash string of the guest quote in Magento 2 to fetch quote object.

masked_id is stored in the quote_id_mask table and it’s the cart hash for the guest customer. When you add a guest item to the cart, one entry generated in the quote_id_mask table to prevent quote id and masked id of the quote.

You can retrieve quote id by using interface,
Magento\Quote\Model\MaskedQuoteIdToQuoteIdInterface

Call from the template or PHP class,
echo $quoteId = $this->getQuoteIdFromMaskedHash();

Output: (int) value
3

One Reply to “How to Get Quote Id by Masked id Magento 2.”

Leave a Reply