I am a new magento developer and i am currently working on creating a new custom payment module.

My module redirects the user to a 3rd party payment provider to complete the payment. Once the response from that provider is received and is successful the order is being considered as completed.

My issue is, when the user presses the 'Place order' button an email to the seller of the product is being sent. I would like to disable that, because the user is first redirected to the payment provider and there is the possibility of cancelling the order (or fail with it / provide false credit card info). And because of that a seller might get notified with email, but in reality the order can be invalid/not fully completed.

So to summarize, is there a way to disable that programmatically??


For it the best approach would be add any additional functionality that your are trying to achieve to Magento order email. By creating your order email will limit functionality.

If you want continue take a look at send(Order $order, $forceSyncMode = false) in app/code/Magento/Sales/Model/Order/Email/Sender/OrderSender.php

You need to create in your custom module etc/di.xml file

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="\Magento\Sales\Model\Order\Email\Sender\OrderSender" type="Vendorname\Modulename\Model\Order\Email\Sender\OrderSender"/>

I hope it will work

  • Thank you for your answer! I tried to customize this function to disable the email sending and i was successful, but i think this is only done for the email that goes to the customer who is ordering a product. This is still not disabling the email that is being sent to the seller. Please correct me if my thoughts are wrong, or let me know if you need any clarifications. Mar 13 '18 at 11:25

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.