简体   繁体   English

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

[英]I want to use Mail::send functionality for sending email on order confirmation?

I want to use mail::send() for sending the notification to admin when order is placed in prestashop.My mail are working for customers but i want to send a mail to shop admin too regarding order placement.And one more thing i dont want to use any seperate plugin for this,I have my payment module in which at the end order status is changed after placing a order.So, I just need to use Mail::send() in that file in order to send notification. 我想使用mail :: send()在prestashop中下订单时向管理员发送通知。我的邮件对客户有效,但我也想向下订单管理员发送邮件。想要使用任何单独的插件,我有我的付款模块,下订单后最终订单状态会更改。因此,我只需要在该文件中使用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
    );

something like this need to implement but this is not working directly. 诸如此类的东西需要实现,但这不能直接起作用。 All suggestions are welcome. 欢迎所有建议。 Thanks in advance. 提前致谢。

Send is a static function of Mail, you can use it anywhere in the project PrestaShop. 发送是邮件的静态功能,您可以在项目PrestaShop中的任何位置使用它。 An example of use is this: 使用示例是这样的:

        $context = Context::getContext();
        $id_shop = (int)$context->shop->id;
        $id_lang = (int)$context->language->id;

        $configuration = Configuration::getMultiple(
            array(
                    'MA_LAST_QTIES',
                    'PS_STOCK_MANAGEMENT',
                    'PS_SHOP_EMAIL',
                    'PS_SHOP_NAME'
            ), null, null, $id_shop
        );

        Mail::Send(
            $id_lang,
            'checker',
            Mail::l('Ordini', $id_lang),
            array('template_vars'=>$vars),
            $dest_mail,
            null,
            (string)$configuration['PS_SHOP_EMAIL'],
            (string)$configuration['PS_SHOP_NAME'],
            null,
            null,
            dirname(__FILE__).'/mails/',
            false,
            $id_shop
        );

this model I use it. 我用这个模型。 if there are doubts here 如果这里有疑问

In you example code you are sending email to client instead of shop admin. 在示例代码中,您是向客户而不是商店管理员发送电子邮件。 You should change it like this: 您应该像这样更改它:

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
);

You can also use mail alerts module for this functionality. 您也可以使用邮件警报模块来实现此功能。

Good luck. 祝好运。

    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']
                        );


}
             }

Guys, this is the class I have use to send the email to admin and surely it works.You just have to make a object of this class and use it.If any one is having any query about this they can ask from me.If anyone found this answer useful just give a upvote.Thanks for giving the suggestions. 伙计们,这是我用来向管理员发送电子邮件的类,肯定可以正常工作。您只需要创建此类的一个对象并使用它即可。如果有人对此有任何疑问,可以向我询问。任何人都认为此答案有用,只是给个赞。谢谢您的建议。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM