我想使用Mail :: send功能在订单确认时发送电子邮件?

时间:2017-01-27 11:47:46

标签: php prestashop prestashop-1.6

我想使用mail :: send()将订单发送到prestashop时向admin发送通知。我的邮件正在为客户工作,但我想向商店管理员发送邮件,关于订单放置。还有一个我不想为此使用任何单独的插件的东西,我有我的支付模块,其中在下订单状态更改后下订单。所以,我只需要在该文件中使用Mail :: send()以便发送通知。

   Mail::Send(
       (int)$order->id_lang,
       'order_conf',
       Mail::l('Order confirmation', (int)$order->id_lang),
       $data,
       $this->context->customer->email,
       $this->context->customer->firstname.' '.$this->context->customer->lastname,
       null,
       null,
       $file_attachement,
       null, _PS_MAIL_DIR_, false, (int)$order->id_shop
    );

这样的事情需要实现,但这不能直接起作用。 欢迎所有建议。 提前致谢。

3 个答案:

答案 0 :(得分:0)

发送是Mail的静态功能,您可以在项目PrestaShop中的任何位置使用它。 使用的一个例子是:

(unavailable)

这个模型我用它。如果有疑问的话

答案 1 :(得分:0)

在您的示例代码中,您向客户端发送电子邮件而不是商店管理员。你应该改变它:

Mail::Send(
   (int)$order->id_lang,
   'order_conf',
   Mail::l('Order confirmation', (int)$order->id_lang),
   $data,
   Configuration:get('PS_SHOP_EMAIL')/*or directly desired email address*/,
   '',
   null,
   null,
   $file_attachement,
   null, _PS_MAIL_DIR_, false, (int)$order->id_shop
);

您还可以使用邮件提醒模块来实现此功能。

祝你好运。

答案 2 :(得分:0)

    class sendEmail extends MailCore {
    public function mailSend($data, $language){
    if($language == 'en'){
        $toSendLang = "new_order_en";
    }else {
        $toSendLang = "new_order_nl";
    }
      $shop_email = strval(Configuration::get('PS_SHOP_EMAIL'));
            Mail::Send(
                            $data['mailIdLang'],
                            $toSendLang,
                            Mail::l('Order confirmation', $data['mailIdLang']),
                            $data['templateVars'],
                            $shop_email,
                            ''.' '.'',
                            null,
                            null,
                            null,
                            null, dirname(__FILE__).'/mails/', false, $data['idShop']
                        );


}
             }

伙计们,这是我用来向管理员发送电子邮件的类,当然它确实有效。你只需要创建这个类的对象并使用它。如果任何人对此有任何疑问,他们可以询问我。如果有人发现这个答案很有用,那就给一个upvote.Thanks提出建议。

相关问题