它在 OpenCart 代码的哪个位置发送发票电子邮件?

Where in OpenCart's code does it send invoice emails off?

我正在尝试针对某些订单状态禁用发票电子邮件的触发,但找不到 email->send 在哪里执行此操作。 我已经注释掉了 catalog->model->checkout->order.php 中的所有 email->sends 并清除了缓存,但我仍然收到了一封发票电子邮件。 提前致谢。

电子邮件是从文件发送的: catalog/model/checkout/order.php如你所说。

假设您要发送电子邮件的订单的 order_status_id 是:7(通常是默认的订单完成状态 ID)

查找代码:

$mail = new Mail();
$mail->protocol = $this->config->get('config_mail_protocol');
$mail->parameter = $this->config->get('config_mail_parameter');
$mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
$mail->smtp_username = $this->config->get('config_mail_smtp_username');
$mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
$mail->smtp_port = $this->config->get('config_mail_smtp_port');
$mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');

$mail->setTo($order_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
$mail->setHtml($this->load->view('mail/order', $data));
$mail->setText($text);
$mail->send();

并用这样的 if 语句包装它:

if($order_status_id == 7){
    $mail = new Mail();
    $mail->protocol = $this->config->get('config_mail_protocol');
    $mail->parameter = $this->config->get('config_mail_parameter');
    $mail->smtp_hostname = $this->config->get('config_mail_smtp_hostname');
    $mail->smtp_username = $this->config->get('config_mail_smtp_username');
    $mail->smtp_password = html_entity_decode($this->config->get('config_mail_smtp_password'), ENT_QUOTES, 'UTF-8');
    $mail->smtp_port = $this->config->get('config_mail_smtp_port');
    $mail->smtp_timeout = $this->config->get('config_mail_smtp_timeout');

    $mail->setTo($order_info['email']);
    $mail->setFrom($this->config->get('config_email'));
    $mail->setSender(html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'));
    $mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
    $mail->setHtml($this->load->view('mail/order', $data));
    $mail->setText($text);
    $mail->send();
}

此更改将仅在订单 status_id = 7 时构建并发送电子邮件。将此 order_status_id 更改为您的。

重要信息: 1)如果您使用任何更改此代码的opencart扩展,您需要调整您的代码...... 2) 如果您的 order_status_id 是您网店的默认 order_status_id,那么您将永远不会收到电子邮件。小心。

希望我有所帮助。干杯。