php - Magento 1.8.1.0 订单确认电子邮件 - 仅再次向销售人员发送电子邮件

标签 php email magento confirmation-email

我们的销售团队没有收到 5 个不同订单的订单确认电子邮件。此问题的原因仍不清楚,但他们询问我们是否可以再次向他们发送订单确认电子邮件,而不将其发送给客户

订单详细信息页面上的“发送电子邮件”按钮可以正确发送邮件,但无法阻止客户接收邮件。

是否有某种方法可以让我们仅将此电子邮件发送给销售团队,无论是通过后台还是以编程方式(如果不可能)?

谢谢您的解答

最佳答案

我们最终决定制作一个脚本来以编程方式发送电子邮件。 该脚本已在以下位置创建:

/shell/resendEmails.php

您只需要更改顶部参数。电子邮件将发送到此地址,而不是客户的地址。销售团队将像往常一样收到副本。

代码本身主要是函数Mage_Sales_Model_Order::sendNewOrderEmail()的副本,并进行了一些修改

要执行脚本,您需要访问该页面: http://YOUR-SITE-URL.com/shell/resendEmails.php

(或者无论您的脚本名称是什么)。

<?php
        require '../app/Mage.php';
        Mage::app();

        /********************************
        *   Please modify the following parameters
        ********************************/

        //The orders for you wich you want to send again the confirmation email
        $order_numbers=array(
            'xxxxxxx',
            'yyyyyyy',
        );

        //Your email address (the email will be send to this address instead of to the customer's)
        $custom_email="<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ecb5a3b9bec2a9a1ada5a0acada8a8bea9bfbfc28f8381" rel="noreferrer noopener nofollow">[email protected]</a>";
        $custom_name="YOUR NAME";
        /**********************************
        *   Please modify the above parameters
        **********************************/


        foreach ($order_numbers as $increment_id){

            $this_order = Mage::getModel('sales/order')->loadByIncrementId($increment_id);

            $storeId = $this_order->getStore()->getId();


            // Get the destination email addresses to send copies to
            $method = new ReflectionMethod(get_class($this_order), '_getEmails');
            $method->setAccessible(true);
            $send_to=$method->invoke($this_order,$this_order::XML_PATH_EMAIL_COPY_TO);
            $copyTo=$send_to;

            $copyMethod = Mage::getStoreConfig($this_order::XML_PATH_EMAIL_COPY_METHOD, $storeId);

            // 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($this_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 ($this_order->getCustomerIsGuest()) {
                $templateId = Mage::getStoreConfig($this_order::XML_PATH_EMAIL_GUEST_TEMPLATE, $storeId);
                $customerName = $this_order->getBillingAddress()->getName();
            } else {
                $templateId = Mage::getStoreConfig($this_order::XML_PATH_EMAIL_TEMPLATE, $storeId);
                $customerName = $this_order->getCustomerName();
            }

            $mailer = Mage::getModel('core/email_template_mailer');
            $emailInfo = Mage::getModel('core/email_info');
            $emailInfo->addTo($custom_email, $custom_name);
            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'
            if ($copyTo && $copyMethod == 'copy') {
                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($this_order::XML_PATH_EMAIL_IDENTITY, $storeId));
            $mailer->setStoreId($storeId);
            $mailer->setTemplateId($templateId);
            $mailer->setTemplateParams(array(
                    'order'        => $this_order,
                    'billing'      => $this_order->getBillingAddress(),
                    'payment_html' => $paymentBlockHtml
                )
            );
            $mailer->send();
        }?>

关于php - Magento 1.8.1.0 订单确认电子邮件 - 仅再次向销售人员发送电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32066818/

相关文章:

php - Smarty 3 如何与 Zend Framework 2 一起使用?

Magento:如何检索(即)分组产品的最低价格?

magento - 传统(标准)结账(分步页面)

internet-explorer - Magento Checkout重定向到 “Shopping cart is empty”页面并清除IE7和IE8中的购物车

php - 新闻评论数

php - php 具有多个选项的精确搜索时出错

php - MySQL/PHP : Select Where with multiple conditions does not work

android - 如何在非gmail帐户的gmail应用程序上更改头像?

java - java发送邮件时出现问题

javascript - 向新用户发送电子邮件 firebase