How to create Guest Empty Cart quote programmatically in Magento 2?

Magento 2, You can create a Guest or anonymous customer empty quote programmatically using Magento\Quote\Api\GuestCartManagementInterface class.

You can create quote entry using interface GuestCartManagementInterface

You have to pass dependency to construct a function to create a guest quote.

Enable a customer or guest user to create an empty cart and quote for an anonymous customer using below way,

Call createEmptyCart function and you can create automatically quote for guests.

Once you run the above code new quote entry generated in a database table.

Affected Database will be quote, quote_address and quote_id_mask table, one new record will be inserted.

Leave a Reply