本文整理汇总了PHP中Mage_Sales_Model_Order_Creditmemo::sendEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Sales_Model_Order_Creditmemo::sendEmail方法的具体用法?PHP Mage_Sales_Model_Order_Creditmemo::sendEmail怎么用?PHP Mage_Sales_Model_Order_Creditmemo::sendEmail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Sales_Model_Order_Creditmemo
的用法示例。
在下文中一共展示了Mage_Sales_Model_Order_Creditmemo::sendEmail方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testSendEmail
/**
* @magentoConfigFixture current_store design/theme/full_name default/default/default
* @magentoDataFixture Mage/Sales/_files/order.php
*/
public function testSendEmail()
{
$order = new Mage_Sales_Model_Order();
$order->loadByIncrementId('100000001');
$order->setCustomerEmail('customer@example.com');
$creditmemo = new Mage_Sales_Model_Order_Creditmemo();
$creditmemo->setOrder($order);
$payment = $order->getPayment();
$paymentInfoBlock = Mage::helper('Mage_Payment_Helper_Data')->getInfoBlock($payment);
$paymentInfoBlock->setArea('invalid-area');
$payment->setBlockMock($paymentInfoBlock);
$this->assertEmpty($creditmemo->getEmailSent());
$creditmemo->sendEmail(true);
$this->assertNotEmpty($creditmemo->getEmailSent());
$this->assertEquals('frontend', $paymentInfoBlock->getArea());
}
示例2: sendEmail
/**
* Send email with creditmemo data
*
* @param boolean $notifyCustomer
* @param string $comment
* @return Mage_Sales_Model_Order_Creditmemo
*/
public function sendEmail($notifyCustomer = true, $comment = '')
{
if (!Mage::getStoreConfig('pdfpro/config/enabled')) {
return parent::sendEmail($notifyCustomer, $comment);
}
switch (Mage::getStoreConfig('pdfpro/config/creditmemo_email_attach')) {
case VES_PdfPro_Model_Source_Attach::ATTACH_TYPE_NO:
return parent::sendEmail($notifyCustomer, $comment);
case VES_PdfPro_Model_Source_Attach::ATTACH_TYPE_ADMIN:
$this->sendEmailForAdmin($notifyCustomer, $comment, true);
$this->sendEmailForCustomer($notifyCustomer, $comment, false);
return $this;
case VES_PdfPro_Model_Source_Attach::ATTACH_TYPE_CUSTOMER:
$this->sendEmailForAdmin($notifyCustomer, $comment, false);
$this->sendEmailForCustomer($notifyCustomer, $comment, true);
return $this;
}
$order = $this->getOrder();
$storeId = $order->getStore()->getId();
if (!Mage::helper('sales')->canSendNewCreditmemoEmail($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('pdfpro/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('pdfpro/email_template_mailer');
if ($notifyCustomer) {
$emailInfo = Mage::getModel('pdfpro/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('pdfpro/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, 'creditmemo' => $this, 'comment' => $comment, 'billing' => $order->getBillingAddress(), 'payment_html' => $paymentBlockHtml));
/* Attach Invoice PDF in email */
$creditmemoData = Mage::getModel('pdfpro/order_creditmemo')->initCreditmemoData($this);
try {
$result = Mage::helper('pdfpro')->initPdf(array($creditmemoData), 'creditmemo');
if ($result['success']) {
$mailer->setPdf(array('filename' => Mage::helper('pdfpro')->getFileName('creditmemo', $this) . '.pdf', 'content' => $result['content']));
} else {
Mage::log($result['msg']);
}
} catch (Exception $e) {
Mage::log($e->getMessage());
}
$mailer->send();
$this->setEmailSent(true);
$this->_getResource()->saveAttribute($this, 'email_sent');
return $this;
//.........这里部分代码省略.........