There are many different ways to do this.
One way is to make an after plugin for place order like this:
app/code/StackExchange/BankTransferNotify/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\Quote\Api\CartManagementInterface">
<plugin type="StackExchange\BankTransferNotify\Plugin\NotifyAdminOnBankTransfer" name="NotifyAdminOnBankTransfer" />
</type>
</config>
app/code/StackExchange/BankTransferNotify/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="StackExchange_BankTransferNotify" setup_version="0.1.0">
</module>
</config>
app/code/StackExchange/BankTransferNotify/Plugin/NotifyAdminOnBankTransfer.php
<?php
declare(strict_types=1);
namespace StackExchange\BankTransferNotify\Plugin;
use Magento\OfflinePayments\Model\Banktransfer;
use Magento\Quote\Api\CartManagementInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
class NotifyAdminOnBankTransfer
{
/**
* @var OrderRepositoryInterface
*/
private OrderRepositoryInterface $orderRepository;
public function __construct(
OrderRepositoryInterface $orderRepository
) {
$this->orderRepository = $orderRepository;
}
public function afterPlaceOrder(CartManagementInterface $cartManagement, $orderId)
{
$order = $this->orderRepository->get($orderId);
if ($order->getPayment()->getMethod() == Banktransfer::PAYMENT_METHOD_BANKTRANSFER_CODE) {
//
// Send Email here......
//
}
return $orderId;
}
}
app/code/StackExchange/BankTransferNotify/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'StackExchange_BankTransferNotify',
__DIR__
);
Enable module
Run setup upgrade
Good luck!