We currently have, on our site, the option to make payment either by credit card or Bank transfer. We would like a way for the admin to receive an alert email when payment is made using the Bank transfer method. We can get the system to send an email every time an order is made but we'd like to send a specific one, just for Bank transfer orders.

Is there a way to do this?

Thank you.

1 Answer 1


There are many different ways to do this. One way is to make an after plugin for place order like this:


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <type name="Magento\Quote\Api\CartManagementInterface">
        <plugin type="StackExchange\BankTransferNotify\Plugin\NotifyAdminOnBankTransfer" name="NotifyAdminOnBankTransfer" />


<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    <module name="StackExchange_BankTransferNotify" setup_version="0.1.0">



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;



Enable module

Run setup upgrade

Good luck!

  • Hello. There seems to be a parse error on line 15 of the NotifyAdminOnBankTransfer.php, the error message reads as follows reads as follows: PHP Parse error: syntax error, unexpected 'OrderRepositoryInterface' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST) in /var/www/vhosts/powerdev.magedemo.co.uk/httpdocs/app/code/OrderAlert/BankTransferNotify/Plugin/NotifyAdminOnBankTransfer.php on line 15
    – CJNotts
    Commented Oct 21, 2020 at 11:56

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.