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

March 6, 2020 0 Comments
<?php
namespace Yuvraj\Raulji\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.

Leave A Comment

To Top