배송 이메일을 고객에게 보내면이 배송 이메일에서 track.phtml에서 추적 번호를 얻습니다. 이제 이메일의 제목 부분은 주문 번호와 배송 번호입니다. 나는 우리가 shippment 전자 우편으로 senidng 인 전자 우편의 주제를 바꾸고 싶으면. 제목은 추적 번호가 있어야합니다. 주문 번호에 대해서는 "order.increment_id"를 얻을 수 있지만 추적 번호를 얻는 방법은 알지 못합니다. 그래서 어떻게 이메일 제목에 추적 번호를 표시 할 수 있습니까?은 이메일 제목에 추적 번호를 포함합니다
0
A
답변
3
전자 메일 템플리트에서 "order.increment_id"와 같은 변수 이름을 사용해야 만이 작업을 수행 할 수 있습니다. 이를 위해 4 단계의 예제를 통해 추적 데이터를 이메일 템플릿 프로세서로 보내야합니다.
1 단계 >> 추가 모듈 구성 응용 프로그램을/etc/모듈에서 /Eglobe_Sales.xml
<?xml version="1.0"?>
<config>
<modules>
<Eglobe_Sales>
<active>true</active>
<codePool>local</codePool>
</Eglobe_Sales>
</modules>
</config>
2 단계 >> config.xml에 추가 (응용 프로그램/코드/지역/Eglobe/판매/등 /config.xml)
<?xml version="1.0"?>
<config>
<modules>
<Eglobe_Sales>
<version>0.1.0</version>
</Eglobe_Sales>
</modules>
<global>
<models>
<sales>
<rewrite>
<order_shipment>Eglobe_Sales_Model_Order_Shipment</order_shipment>
</rewrite>
</sales>
</models>
</global>
</config>
>> 3 단계 무시 Mage_Sales_Model_Order_Shipment :: sendEmail()
<?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;
}
}
4 단계 >> 나는 모든 단계를 따라했습니다 {{var에 tracks.track_number}}
를 추가하여 발송 이메일 tempate 제목을 수정합니다. 그러나 그것은 이메일의 주제에 어떤 추적 번호도 보여주지 않았다. .. 우리는 어느 곳이라도 놓치고 있냐? –
@Johngrews가 다음을 확인합니다 ... ** 1 ** ** Mage_Sales_Model_Order_Shipment 클래스를 다시 쓰는 다른 모듈은 없습니다 (단순히 "order_shipment"의 "code"디렉토리 검색). 당신이 코드를 아래처럼 일치하는 항목을 찾습니다 있으면 알려 주시기 ' Some_Class_Name_Here order_shipment> ' ** 2 >> ** 당신은 당신의 젠토 캐시를 플러시. ** 3 ** ** 올바른 템플릿을 편집했습니다. 잘못된 템플릿을 수정할 기회가있을 수 있습니다. app/locale/your_locale/template/email/sales/shipment_new.html에서 템플릿 파일을 편집 한 경우 –
Nidheesh
@Johngrews 이전 메시지 계속 ... 데이터베이스에 템플릿 복사본이 없는지 확인하십시오. 가지고있는 템플릿을 편집하십시오. – Nidheesh