发送电子邮件订单 opencart 模块

问题描述 投票:0回答:0

我不能直接说,我必须解释我想做的让你明白。

我已经延期,由 2 名员工按以下方式接单: 1个你 1个我

所以顺序。

我想直接发送订单到邮箱。但是我想把订单准确地发送给接单的员工。

在数据库中,该表的名称为“retrieved”,其中有 2 个数字:5 和 4。 如果是 5 = 员工 1,如果是 4 = 员工 2.

这是我编写的代码,应该 将订单发送到接受订单的电子邮件。但是你看到了什么?它仅将订单发送到第一封电子邮件。即使订单被其他人接受,它仍然会进入第一封电子邮件。 我尝试了 if, ssmd 的变体,但无济于事。这就是为什么我必须在这里问,我能做什么? 另请注意,此模块已插入 (public_html/catalog/model/checkout/order.php)。我不知道这对不对。

`

    $order_query = $this->db->query("SELECT preluat FROM " . DB_PREFIX . "order WHERE order_id = '" . (int)$order_id . "'");
    $order = $order_query->row;
    
    if ($order) {
        $lady1_email = "[email protected]";
        $lady2_email = "[email protected]";
    
        switch ($order['preluat']) {
            case '4':
                $to_email = $lady1_email;
                break;
            case '5':
                $to_email = $lady2_email;
                break;
        }
           if ($to_email != "") {
                $subject = "New order received";
                $body = "Dear Lady,\n\nA new order has been allocated to you. Please check your order list and start processing it as soon as possible.\n\nOrder details:\nOrder ID: " . $order['order_id'] . "\nCustomer Name: " . $order['firstname'] . " " . $order['lastname'] . "\nOrder Total: " . $order['total'] . "\n\nBest regards,\nYour Employer";
        
                $mail = new Mail();
                $mail->protocol = $this->config->get('config_mail_protocol');
                $mail->parameter = $this->config->get('config_mail_parameter');
                $mail->hostname = $this->config->get('config_smtp_host');
                $mail->username = $this->config->get('config_smtp_username');
                $mail->password = $this->config->get('config_smtp_password');
                $mail->port = $this->config->get('config_smtp_port');
                $mail->timeout = $this->config->get('config_smtp_timeout');
                $mail->setTo($to_email);
                $mail->setFrom($this->config->get('config_email'));
                $mail->setSender($order['store_name']);
                $mail->setSubject($subject);
                $mail->setText($body);
                $mail->send();
            }
    }*/

我希望代码像我详细说明的那样工作。根据订单的批准方式将订单正确发送到员工电子邮件。

php twig opencart opencart-module
© www.soinside.com 2019 - 2024. All rights reserved.