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,
<?php namespace Rbj\GuestCart\Block; class Demo { public function __construct( \Magento\Quote\Api\GuestCartManagementInterface $guestCart, ) { $this->guestCart = $guestCart; } /* Create Guest Cart */ public function createEmptyCart() { return $this->guestCart->createEmptyCart(); } }
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.