Try this,
To get guest user orders by specific email
<?php
namespace Vendor\Module\Controller\Orders;
class ReadOrders extends \Magento\Framework\App\Action\Action {
public function __construct(\Magento\Framework\App\Action\Context $context,
\Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory) {
$this->orderCollectionFactory = $orderCollectionFactory;
parent::__construct($context);
}
public function execute()
{
$orders = $this->orderCollectionFactory->create()
->addAttributeToFilter('customer_email', '[email protected]')
->addAttributeToFilter('customer_is_guest', '1');
foreach ($orders as $items) {
echo $items->getEntityId() . '<pre>';
}
}}
It will print the increment id of the above order collection filter.
Hope this helps.
Peace :)