How to convert guest to customer using order id and how to send them password reset email in magento 2.
Please provide me a solution to send convert guest to customer
How to convert guest to customer using order id and how to send them password reset email in magento 2.
Please provide me a solution to send convert guest to customer
To Send Email
In observer:(evevnt:checkout_onepage_controller_success_action)
use Magento\Framework\Event\ObserverInterface;
use Magento\Sales\Model\OrderFactory;
use Magento\Sales\Model\Order\Email\Sender\OrderSender;
use Magento\Checkout\Model\Session as CheckoutSession;
class SendMailOnOrderSuccess implements ObserverInterface
{
protected $orderModel;
protected $orderSender;
protected $checkoutSession;
public function __construct(OrderFactory $orderModel, OrderSender $orderSender, CheckoutSession $checkoutSession)
{
$this->orderModel = $orderModel;
$this->orderSender = $orderSender;
$this->checkoutSession = $checkoutSession;
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
//On Order Success Event, Get Order Id and Send Order Confirmation Email
$orderIds = $observer->getEvent()->getOrderIds();
if (count($orderIds)) {
$this->checkoutSession->setForceOrderMailSentOnSuccess(true);
$order = $this->orderModel->create()->load($orderIds[0]);
$this->orderSender->send($order, true);
}
}