I want to send different content in invoice e-mails per customer group.

Suppose, I have two customer groups A and B. When customer from group A will place a order it should send another e-mail then a customer from group B will place an order .

Is this possible? Please help me how can I perform this.

1 Answer 1


Magento selects it's templates from app/locale/{LANGUAGE_CODE}/template/email/sales/invoice_new.html or app/locale/{LANGUAGE_CODE}/template/email/sales/invoice_new_guest.html

It selects the correct template based on guest or non guest in app/code/core/Mage/Sales/Model/Order/Invoice.php::sendEmail()

You should create a module and rewrite the given functionality.


public function sendEmail($notifyCustomer = true, $comment = '')
    /*** SKIPPED CODE ***/

    // Retrieve corresponding email template id and customer name
    if ($order->getCustomerIsGuest()) {
        $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
        $customerName = $order->getBillingAddress()->getName();
    } else {

         * ADD LOGIC TO SELECT TEMPLATE BASED ON customergroup
        switch ($order->getCustomerGroupId()) {

            case 1: // Customer group 1
                $templateId = 'sales_email_order_template_custom1';

            case 3: // Customer group 3
                $templateId = 'sales_email_order_template_custom3';

                $templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $storeId);

        $customerName = $order->getCustomerName();

    /*** SKIPPED CODE ***/

    // Set all required params and send emails
    $mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
                    'order'        => $order,
                    'invoice'      => $this,
                    'comment'      => $comment,
                    'billing'      => $order->getBillingAddress(),
                    'payment_html' => $paymentBlockHtml
    $this->_getResource()->saveAttribute($this, 'email_sent');

    return $this;

In your app/code/local/Custom/Module/etc/config.xml you'll add references to the files.

<?xml version="1.0"?>
                <sales_email_order_template_custom1 translate="label" module="sales">
                    <label>New Invoice for Customer group 1</label>
                <sales_email_order_template_custom3 translate="label" module="sales">
                    <label>New Invoice for Customer group 3</label>

You can copy the files from the original sales/invoice_new.phtml and create the edits you'll need.

Not the answer you're looking for? Browse other questions tagged or ask your own question.