1

There is 'Send Order Email Copy To' feature on sales email menu. I wand to add additional feature which I can set different email template and other email address.

e.g.) Adding this menu, 'Send Order Email #2 To ' / 'Send Order Email #2 email template'

How can I add this feature?

Thank you!

enter image description here

Yohan
  • 1,610
  • 7
  • 33
  • 51

1 Answers1

0

In app/code/core/Mage/Sales/etc/system.xml in node sales_email -> order -> fields add something like this:

                <copy_to2 translate="label comment">
                    <label>Send Order Email #2 To</label>
                    <frontend_type>text</frontend_type>
                    <sort_order>6</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                    <comment>Comma-separated.</comment>
                </copy_to2>
                <template2 translate="label">
                    <label>Send Order Email #2 email template</label>
                    <frontend_type>select</frontend_type>
                    <source_model>adminhtml/system_config_source_email_template</source_model>
                    <sort_order>7</sort_order>
                    <show_in_default>1</show_in_default>
                    <show_in_website>1</show_in_website>
                    <show_in_store>1</show_in_store>
                </template2>

and in app/code/core/Mage/Sales/Model/Order.php -> public function sendNewOrderEmail() below $mailer->send(); add:

$copyTo2 = $this->_getEmails('sales_email/order/copy_to2');
if ($copyTo2) {
    foreach ($copyTo2 as $email) {
        $emailInfo2 = Mage::getModel('core/email_info');
        $emailInfo2->addTo($email);
        $mailer2->addEmailInfo($emailInfo2);
    }

    $mailer2->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
    $mailer2->setStoreId($storeId);
    $mailer2->setTemplateId(Mage::getStoreConfig('sales_email/order/template2', $storeId));
    $mailer2->setTemplateParams(array(
            'order'        => $this,
            'billing'      => $this->getBillingAddress(),
            'payment_html' => $paymentBlockHtml
        )
    );
    $mailer2->send();
}
michael
  • 2,770
  • 2
  • 11
  • 13