【问题标题】:Magento email templates based upon customer group and payment method基于客户组和付款方式的 Magento 电子邮件模板
【发布时间】:2014-04-03 10:55:53
【问题描述】:

是否可以根据客户群和付款方式使用不同的电子邮件模板?

我知道我可以在 Conf->Transactional Emails 中设置不同的模板,我还可以看到我可以在 Conf-> Sales Emails 中为不同的销售电子邮件分配不同的模板。但是,我看不到在哪里可以根据客户组和付款方式设置不同的电子邮件模板。

任何建议都会很棒

【问题讨论】:

    标签: magento email magento-1.7


    【解决方案1】:

    根据客户群更换不同的邮件模板

    按照以下步骤进行

    1.创建您的电子邮件模板并将其放在模板文件夹中。对于我来说,它是“app\locale\en_US\template\email\sales”。

    2.创建您的新模块。在 config.xml 中定义电子邮件模板。

    <global>
    ...
    <template>
    <email>
    <custom_email_customorder_new module="sales">
         <label>custom email module</label>
         <file>sales/order_new_custom.html</file>
         <type>html</type>
    </custom_email_customorder_new>
    <custom_email_customorder_log module="sales">
        <label>custom email module</label>
        <file>sales/order_log_custom.html</file>
        <type>html</type>
    </custom_email_customorder_log>
    </email>
    </template>
    ... 
    </global>
    

    3.扩展“Sales/Model/Order.php”并覆盖方法sendNewOrderEmail()

     $paymentMethodCOde=$this->getPayment()->getMethodInstance()->getCode();
        if($paymentMethodCOde=="checkmo"){
         $mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
                $mailer->setStoreId($storeId);
                $mailer->setTemplateId('custom_email_customorder_new');
                $mailer->setTemplateParams(array(
                        'order'        => $this,
                        'password'  => $password,
                        'billing'      => $this->getBillingAddress(),
                        'payment_html' => $paymentBlockHtml
                    )
                );
                $mailer->send();
        }elseif($paymentMethodCOde="cashondelivery"){
             $mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
                $mailer->setStoreId($storeId);
                $mailer->setTemplateId('custom_email_customorder_log');
                $mailer->setTemplateParams(array(
                        'order'        => $this,
                        'password'  => $password,
                        'billing'      => $this->getBillingAddress(),
                        'payment_html' => $paymentBlockHtml
                    )
                );
                $mailer->send();
    
        }
         else
         {
             $mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
                $mailer->setStoreId($storeId);
                /* magento default  sales template*/
                $mailer->setTemplateId($templateId);
                $mailer->setTemplateParams(array(
                        'order'        => $this,
                        'billing'      => $this->getBillingAddress(),
                        'payment_html' => $paymentBlockHtml
                    )
                );
                $mailer->send();
         }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-25
      • 2014-05-17
      • 1970-01-01
      • 2017-07-14
      • 1970-01-01
      • 1970-01-01
      • 2014-08-04
      • 1970-01-01
      相关资源
      最近更新 更多