Method 1->
You can disable the standard order confirmation email from Admin-
Stores > Configuration > Sales > Sales Email > Order
.
Method 2->
Here $this->orderSender->send($order, true);
called which extends abstract class method() which check if Order confirmation email is enabled from backend or not so we need create plugin for that
To create a plugin, you need to use di.xml
.
[Package_Name]\[Module_Name]\etc\di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Sales\Model\Order\Email\Container\OrderIdentity">
<plugin name="change_is_enable_method" type="\[Package_Name]\[Module_Name]\Plugin\Sales\Order\Email\Container\OrderIdentityPlugin"/>
</type>
</config>
[Package_Name]\[Module_Name]\Plugin\Sales\Order\Email\Container\ OrderIdentityPlugin.php
<?php
namespace [Package_Name]\[Module_Name]\Plugin\Sales\Order\Email\Container;
class OrderIdentityPlugin
{
/**
* @param \Magento\Sales\Model\Order\Email\Container\OrderIdentity $subject
* @param callable $proceed
* @return bool
*/
public function aroundIsEnabled(\Magento\Sales\Model\Order\Email\Container\OrderIdentity $subject, callable $proceed)
{
$returnValue = $proceed();
if(some condition)
{
if($returnValue)
$returnValue = false;
else
$returnValue = true;
}
return $returnValue;
}
}