【问题标题】:How to show order details in Magento transaction email templates?如何在 Magento 交易电子邮件模板中显示订单详情?
【发布时间】:2015-06-19 22:06:01
【问题描述】:

我想在交易电子邮件模板中显示客户姓名和订单 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";
                }

【问题讨论】:

  • Prince,您对以下答案的理解如何?它看起来很有用,但您似乎没有回复/投票。

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


【解决方案1】:

请先在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);

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-21
    • 1970-01-01
    • 2012-07-05
    • 2013-01-14
    • 2012-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多