如何在Magento交易电子邮件模板中显示订单详细信息?

时间:2015-04-14 10:25:29

标签: magento magento-1.7 magento-1.9 magento-1.9.1

我想在交易电子邮件模板中显示客户名称和订单ID。但这些价值观正在动态变化。

我创建了一个商店ID为1的电子邮件模板。我在phtml页面中调用该电子邮件模板。但是我如何向动态出现的模板页面发送订单ID和名称。

phtml页面中的代码

$vars = Array('name' => '$name',
              'orderId' => '$ordernumber');   
 $storeId = Mage::app()->getStore()->getId();
$translate  = Mage::getSingleton('core/translate');
$mailTemplate=Mage::getModel('core/email_template')
->setTemplateSubject('mailSubject')
->sendTransactional(1, $sender, $email, $name, $vars, $storeId);
            if (!$mailTemplate->getSentSuccess()) {
                   echo "no send";
                }

1 个答案:

答案 0 :(得分:0)

请先在phtml中加载您要发送的订单。

然后从中获取所需的参数并传递给跨国模板

您可以根据需要更改发送和收件人

$customer_name   = 'John Doe'; //set dynamically as per you need
$order_id = '1110000'; //set dynamically as per you need

// Here is where we can define custom variables to go in our email template!

$email_template_variables = array(
    'customer_name' => $customerName,
  'order_id ' => $order_id 
    // Other variables for our email template.
);

$templateId = 1;
                // Get Store ID    
                $store = Mage::app()->getStore()->getId();
                $translate  = Mage::getSingleton('core/translate');
                // Send Transactional Email
                Mage::getModel('core/email_template')
                ->sendTransactional($templateId,  Mage::getStoreConfig(self::XML_PATH_EMAIL_SENDER),  Mage::getStoreConfig(self::XML_PATH_EMAIL_RECIPIENT), null,   $email_template_variables        );
                $translate->setTranslateInline(true);

您的模板maust包含要在发送的电子邮件中设置的数组变量

ie. {{var customer_name}}  {{var order_id}}