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.

closed as too broad by Qaisar Satti, 7ochem, mbalparda, Pratik bhatt, Klettseb Jan 15 '16 at 15:18

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


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.