首页 文章

Prestashop:从BackOffice激活帐户后,无法向用户发送电子邮件

提问于
浏览
0

我到处寻找,找不到问题的答案 . 我想在注册时取消激活用户帐户,然后在BackOffice中激活它 . 我设法做到这一点,但我想在他的帐户被激活时向用户发送电子邮件,所以我在激活/取消激活单选按钮旁边添加了一个按钮,我在AdminCustomers.php中添加了以下内容

<input type="submit" value="'.$this->l('   Send Email to inform user   ').'"/>

但我不知道如何发送电子邮件 . 我的问题对你来说似乎很简单,但我是php / html的新手,所以对我来说有点困难 . 我搜索并发现了许多发送电子邮件的例子,但似乎没有一个能够正常工作 .

编辑:我这样做的原因是我们有两种类型的客户:个人和公司 . 对于公司,我们需要验证提供的信息(例如:增值税号) . 然后激活帐户,因为它可以让他们获得特殊价格 .

2 回答

  • 0

    我最终为此创建了一个模块 . 它与Prestashop 1.5完美配合 .

  • 0

    你在哪里激活帐户?您应该只是添加代码以在帐户激活后发送电子邮件 - 添加额外步骤(管理员可能忘记采取)似乎没有意义 .

    在一个模块中,我会使用如下内容:

    private function _emailNewAccount($customer, $address, $messages)
      {
        $configuration = Configuration::getMultiple(array('PS_LANG_DEFAULT', 'PS_SHOP_EMAIL', 'PS_SHOP_NAME'));
        $id_lang = (int)$configuration['PS_LANG_DEFAULT'];
        $template = 'new_account';
    $subject = $this->l('New Account', $id_lang);
        $templateVars = array(
          '{firstname}' => $customer->firstname,
          '{lastname}' => $customer->lastname,
          '{address1}' => $address->address1,
          '{address2}' => !empty($address->address2) ? $address->address2 : $this->l('--',     $id_lang),
          '{city}' => $address->city,
          '{postcode}' => $address->postcode,
          '{email}' => $customer->email,
          '{messages}' => is_array($messages) ? implode("\n", $messages) : (isset($messages) ? $messages : ''),
          '{phone}' => !empty($address->phone) ? $address->phone : $this->l('n/a', $id_lang),
          '{mobile}' => !empty($address->phone_mobile) ? $address->phone_mobile : $this->l('n/a', $id_lang),
          '{customer_id}' => (int)$customer->id
        );
        $iso = Language::getIsoById((int)($id_lang));
        if (file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.txt') AND file_exists(dirname(__FILE__).'/mails/'.$iso.'/'.$template.'.html'))
          Mail::Send($id_lang, $template, $subject, $templateVars, $customer->email,$customer->firstname.' '.$customer->lastname, $configuration['PS_SHOP_EMAIL'], $configuration['PS_SHOP_NAME'], NULL, NULL, dirname(__FILE__).'/mails/');
    }
    

    显然,您还需要创建相应的文本和HTML电子邮件模板 . 在这种情况下,这些将在我的模块dorectory中:/ modules / mymodulename / mails / en / new_account.html /modules/mymodulename/mails/en/new_account.txt

    您可以在模板中使用上面定义的字段,因此对于 new_account.txt 中可能包含的纯文本模板:

    Hi {firstname} {lastname},
    
     You have just registered on {shop_name}.
    
     Address:
    
     {address1}
     {address2}
     {city}, {postcode}
     Telephone: {phone}, Mobile: {mobile}
    
     {messages}
    

    如果你在你的问题中包含你到目前为止所尝试的内容可能会很好....

相关问题