1

We sell on Amazon, eBay and via the website. I have setup the CC in the System > Configuration > Sales > Sales Emails to copy all of the emails there to the store owner (Order, Order Comments, Invoice, Invoice Comments, Shipment, Shipment Comments, Credit Memo, Credit Memo Comments).

Store owner wants to receive emails generated from the website only. Other orders from marketplaces, currently Amazon and eBay, these email should not be sent to him via the CC field. They have Order ID prefixes of AMZ and EBAY in front of them while the website orders have no prefix.

How can this be accomplished?

2

You need to override the Mage_Core_Model_Email_Template class via the

Magento_root/app/code/local/Mage

directory or rewrite it in your custom extension.
And you need add some code into the send function, please replace the following code:

foreach ($emails as $key => $email) {
    $mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?=');
}

by the following code:

$sendCC = true;
if (isset($variables['order'])) {
    $order = $variables['order'];
    $orderIncrementId = $order->getIncrementId();
    if (0 === strpos($orderIncrementId, 'AMZ')
        || 0 === strpos($orderIncrementId, 'EBAY')
    ) {
        $sendCC = false;
    }
}
$storeOwnerEmails = array('email1@domain.com', 'email2@domain.com'); // here you need set store owner emails
foreach ($emails as $key => $email) {
    if (!$sendCC && in_array($email, $storeOwnerEmails)) {
        continue;
    }
    $mail->addTo($email, '=?utf-8?B?' . base64_encode($names[$key]) . '?=');
}
  • You are back :) welcome:) – Amit Bera Mar 6 '18 at 7:32
  • Hi Amasty & thx for the reply. I overrode the core file at /home/shoe/public_html_new/app/code/local/Mage/Core/Model/Email/Template.php and replaced the code per your instructions but no website orders (those without AMZ and EBAY prefixes) are being sent to the addresses in the $storeOwnerEmails array set in the code. I even tried modifying the core file at /home/shoe/public_html_new/app/code/core/Mage/Core/Model/Email/Template.php starting at line 438 in case I mucked it up somehow but again no email was sent from a store order. Any ideas? Thanks – ComputerGiant Mar 28 '18 at 19:22

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.