1

How can we stop new order confirmation email.

We have 3 payment methods which are EFT(Cash on Delivery), Paypal express checkout & Credit card payment. So when we place an order we get invoice and order confirmation email, so our requirement is something like we don't want order confirmation email if Paypal express checkout is used to order otherwise we want them so can't disable it from admin config and want some custom solution about it, any help will be appreciated, Thanks.

2 Answers 2

0

You can either create around plugin or preference for the "send" function available in this file

vendor/magento/module-sales/Model/Order/Email/Sender/OrderSender.php

You can put your respective business logic in this function to restrict sending order confirmation emails in specific cases.

Hope this help you.

Thanks,

2
  • Thanks, it works. Apr 17, 2020 at 10:28
  • I was not able to override it in conventional Magento 2 way without causing issues so came up with a workaround from the following link... I hope it helps anyone with the same requirements. stackoverflow.com/questions/51133658/… Apr 17, 2020 at 12:23
0

simply Override Magento\Sales\Model\Order\Email\Sender.php

 if($order->getPayment()->getMethodInstance()->getCode() != "yourpaymentmethodcode"){
        $sender->send();
 }
 if($order->getPayment()->getMethodInstance()->getCode() != "yourpaymentmethodcode"){
        $sender->sendCopyTo();
 }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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