0

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

1

1 Answer 1

0

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);
        }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.