簡體   English   中英

我想使用Mail :: send功能在訂單確認時發送電子郵件嗎?

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

我想使用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
    );

諸如此類的東西需要實現,但這不能直接起作用。 歡迎所有建議。 提前致謝。

發送是郵件的靜態功能,您可以在項目PrestaShop中的任何位置使用它。 使用示例是這樣的:

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

我用這個模型。 如果這里有疑問

在示例代碼中,您是向客戶而不是商店管理員發送電子郵件。 您應該像這樣更改它:

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

您也可以使用郵件警報模塊來實現此功能。

祝好運。

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


}
             }

伙計們,這是我用來向管理員發送電子郵件的類,肯定可以正常工作。您只需要創建此類的一個對象並使用它即可。如果有人對此有任何疑問,可以向我詢問。任何人都認為此答案有用,只是給個贊。謝謝您的建議。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM