Magento 在邮件主题部分包括跟踪号码
当我们向客户发送Shipppment电子邮件时,在这封Shipppment电子邮件中,我们从track.phtml获得跟踪号,现在电子邮件的主题部分是订单号和Shipppment号。我想更改邮件的主题,我们在其中被视为装运邮件。受试者必须有追踪号码。对于订单号,我们可以使用“order.increment\u id”获取,但我不知道如何获取跟踪号。那么,如何在电子邮件主题中显示跟踪编号呢?这不能仅通过在电子邮件模板中使用“order.increment\u id”这样的变量名来实现。您必须将跟踪数据发送到电子邮件模板处理器,以通过4个步骤的示例实现这一点 步骤1>>添加模块配置 在app/etc/modules/Eglobe_Sales.xml中Magento 在邮件主题部分包括跟踪号码,magento,magento-1.7,magento-1.4,magento-1.5,magento-1.6,Magento,Magento 1.7,Magento 1.4,Magento 1.5,Magento 1.6,当我们向客户发送Shipppment电子邮件时,在这封Shipppment电子邮件中,我们从track.phtml获得跟踪号,现在电子邮件的主题部分是订单号和Shipppment号。我想更改邮件的主题,我们在其中被视为装运邮件。受试者必须有追踪号码。对于订单号,我们可以使用“order.increment\u id”获取,但我不知道如何获取跟踪号。那么,如何在电子邮件主题中显示跟踪编号呢?这不能仅通过在电子邮件模板中使用“order.increment\u id”这样的变量名来实现。您必须将跟踪
<?xml version="1.0"?>
<config>
<modules>
<Eglobe_Sales>
<active>true</active>
<codePool>local</codePool>
</Eglobe_Sales>
</modules>
</config>
真的
地方的
Step2>>添加config.xml(app/code/local/Eglobe/Sales/etc/config.xml)
0.1.0
Eglobe\销售\型号\订单\发货
步骤3>>覆盖Mage\u销售\u型号\u订单\u发货::sendEmail()
这只能通过在电子邮件模板中使用“order.increment\u id”这样的变量名来实现。您必须将跟踪数据发送到电子邮件模板处理器,以通过4个步骤的示例实现这一点
步骤1>>添加模块配置
在app/etc/modules/Eglobe_Sales.xml中
<?xml version="1.0"?>
<config>
<modules>
<Eglobe_Sales>
<active>true</active>
<codePool>local</codePool>
</Eglobe_Sales>
</modules>
</config>
真的
地方的
Step2>>添加config.xml(app/code/local/Eglobe/Sales/etc/config.xml)
0.1.0
Eglobe\销售\型号\订单\发货
步骤3>>覆盖Mage\u销售\u型号\u订单\u发货::sendEmail()
我已经完成了所有步骤。但它并没有在邮件主题中显示任何追踪号码。。我们在哪里遗漏了什么?@Johngrews确认以下内容。。。1> >没有其他模块重写Mage_Sales_Model_Order_Shipping类(只需在“code”目录中搜索“Order_Shipping”)。如果您发现任何与以下代码类似的匹配项,请告诉我您刷新了magento缓存。3> >您编辑了正确的模板。可能有机会修改错误的模板。如果您在app/locale/your_locale/template/email/sales/shipping_new.html..@Johngrews上一条消息的延续中编辑了模板文件。。。请确保数据库中没有模板副本。。如果有,请编辑该模板的主题。否。。我已经按建议检查过了,但没有用。我不维护电子邮件模板的任何副本database@Johngrews,我唯一能找到的就是代码中缺少“class”关键字。我已经更新了步骤3中使用的代码。要确保该类重写了核心类,请尝试将下面的代码放在index.php的末尾<代码>echo get_类(Mage::getModel('sales/order_-shipping')代码>如果它正在打印“Eglobe\u Sales\u Model\u Order\u Shipping”,一切都应该正常。我想知道您编辑了哪一个模板文件以及如何编辑?我已经完成了所有步骤。但它并没有在邮件主题中显示任何追踪号码。。我们在哪里遗漏了什么?@Johngrews确认以下内容。。。1> >没有其他模块重写Mage_Sales_Model_Order_Shipping类(只需在“code”目录中搜索“Order_Shipping”)。如果您发现任何与以下代码类似的匹配项,请告诉我您刷新了magento缓存。3> >您编辑了正确的模板。可能有机会修改错误的模板。如果您在app/locale/your_locale/template/email/sales/shipping_new.html..@Johngrews上一条消息的延续中编辑了模板文件。。。请确保数据库中没有模板副本。。如果有,请编辑该模板的主题。否。。我已经按建议检查过了,但没有用。我不维护电子邮件模板的任何副本database@Johngrews,我唯一能找到的就是代码中缺少“class”关键字。我已经更新了步骤3中使用的代码。要确保该类重写了核心类,请尝试将下面的代码放在index.php的末尾<代码>echo get_类(Mage::getModel('sales/order_-shipping')代码>如果它正在打印“Eglobe\u Sales\u Model\u Order\u Shipping”,一切都应该正常。我想知道您编辑了哪个模板文件以及如何编辑?
<?php
class Eglobe_Sales_Model_Order_Shipment extends Mage_Sales_Model_Order_Shipment {
/**
* Send email with shipment data
*
* @param boolean $notifyCustomer
* @param string $comment
* @return Mage_Sales_Model_Order_Shipment
*/
public function sendEmail($notifyCustomer = true, $comment = '')
{
$order = $this->getOrder();
$storeId = $order->getStore()->getId();
if (!Mage::helper('sales')->canSendNewShipmentEmail($storeId)) {
return $this;
}
// Get the destination email addresses to send copies to
$copyTo = $this->_getEmails(self::XML_PATH_EMAIL_COPY_TO);
$copyMethod = Mage::getStoreConfig(self::XML_PATH_EMAIL_COPY_METHOD, $storeId);
// Check if at least one recepient is found
if (!$notifyCustomer && !$copyTo) {
return $this;
}
// Start store emulation process
$appEmulation = Mage::getSingleton('core/app_emulation');
$initialEnvironmentInfo = $appEmulation->startEnvironmentEmulation($storeId);
try {
// Retrieve specified view block from appropriate design package (depends on emulated store)
$paymentBlock = Mage::helper('payment')->getInfoBlock($order->getPayment())
->setIsSecureMode(true);
$paymentBlock->getMethod()->setStore($storeId);
$paymentBlockHtml = $paymentBlock->toHtml();
} catch (Exception $exception) {
// Stop store emulation process
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
throw $exception;
}
// Stop store emulation process
$appEmulation->stopEnvironmentEmulation($initialEnvironmentInfo);
// 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 {
$templateId = Mage::getStoreConfig(self::XML_PATH_EMAIL_TEMPLATE, $storeId);
$customerName = $order->getCustomerName();
}
$mailer = Mage::getModel('core/email_template_mailer');
if ($notifyCustomer) {
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo($order->getCustomerEmail(), $customerName);
if ($copyTo && $copyMethod == 'bcc') {
// Add bcc to customer email
foreach ($copyTo as $email) {
$emailInfo->addBcc($email);
}
}
$mailer->addEmailInfo($emailInfo);
}
// Email copies are sent as separated emails if their copy method is 'copy' or a customer should not be notified
if ($copyTo && ($copyMethod == 'copy' || !$notifyCustomer)) {
foreach ($copyTo as $email) {
$emailInfo = Mage::getModel('core/email_info');
$emailInfo->addTo($email);
$mailer->addEmailInfo($emailInfo);
}
}
// Set all required params and send emails
$mailer->setSender(Mage::getStoreConfig(self::XML_PATH_EMAIL_IDENTITY, $storeId));
$mailer->setStoreId($storeId);
$mailer->setTemplateId($templateId);
$mailer->setTemplateParams(array(
'order' => $order,
'shipment' => $this,
'comment' => $comment,
'billing' => $order->getBillingAddress(),
'payment_html' => $paymentBlockHtml,
//setting the `track number here, A shihpment can have more than one track numbers so seperating by comma`
'tracks' => new Varien_Object(array('tracking_number' => implode(',', $this->getTrackingNumbers())))
)
);
$mailer->send();
return $this;
}
//Creating track number array
public function getTrackingNumbers()
{
$tracks = $this->getAllTracks();
$trackingNumbers = array();
if (count($tracks)) {
foreach ($tracks as $track) {
$trackingNumbers[] = $track->getNumber();
}
}
return $trackingNumbers;
}
}