First, have a look at: Mage_Sales_Model_Order_Invoice->sendEmail() To get an idea of what Magento is doing when the mail is sent. It should be fairly apparent what you'll need to do, as the goal is to add your own BCC to that mail.
You'll also notice that $order
is defined right at the top.
Now I'm assuming that you might have hundreds of products, all of which need to be BCC'ed to different people. In this case, you should be able to iterate over the order items and check a custom product attribute, say product_bcc_email
, to determine if this order needs to have someone BCC'ed and which address to use, something probably looking like (not tested at all).
$items = $order->getItems();
foreach ($items as $item) {
if ($bcc_email = $item->getProduct()->getProductBccEmail()) {
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addBcc($bcc_email);
$mailer->addEmailInfo($emailInfo);
}
}
Ultimately, you will need to determine how you want to implement this. I don't recall a good observer to place this code in, so you might have to override the Invoice model and replace the sendEmail()
method with your own.
Another approach that might work (without having to override core models) would be to find an appropriate observer (maybe sales_order_place_after
) and then just send an entirely separate email to the people that need to be BCC'ed. This will send two mails instead of one, but you at least get past having to override the Invoice model.