Hi,
I just recently learned of a rather odd issue with opencart and language support: when setting opencart to allow only approved users to login the system sends two emails, the first being the account registration confirmation email and the second being the account approval email after the webmester approves it. The issue is with the account approval email because it sends the email in the language of the backend and not in the users language.
Is there some way of solving this issue?
Regards
Rui
I just recently learned of a rather odd issue with opencart and language support: when setting opencart to allow only approved users to login the system sends two emails, the first being the account registration confirmation email and the second being the account approval email after the webmester approves it. The issue is with the account approval email because it sends the email in the language of the backend and not in the users language.
Is there some way of solving this issue?
Regards
Rui
Which OC version are you using ?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
In admin/model/sale/customer.php file,
replace:
with:
Note: Each customers must already be assigned to a group when registering an account.
replace:
Code: Select all
public function approve($customer_id) {
$customer_info = $this->getCustomer($customer_id);
if ($customer_info) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET approved = '1' WHERE customer_id = '" . (int)$customer_id . "'");
$this->load->language('mail/customer');
$this->load->model('setting/store');
$store_info = $this->model_setting_store->getStore($customer_info['store_id']);
if ($store_info) {
$store_name = $store_info['name'];
$store_url = $store_info['url'] . 'index.php?route=account/login';
} else {
$store_name = $this->config->get('config_name');
$store_url = HTTP_CATALOG . 'index.php?route=account/login';
}
$message = sprintf($this->language->get('text_approve_welcome'), $store_name) . "\n\n";
$message .= $this->language->get('text_approve_login') . "\n";
$message .= $store_url . "\n\n";
$message .= $this->language->get('text_approve_services') . "\n\n";
$message .= $this->language->get('text_approve_thanks') . "\n";
$message .= $store_name;
$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($customer_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($store_name);
$mail->setSubject(html_entity_decode(sprintf($this->language->get('text_approve_subject'), $store_name), ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
$mail->send();
}
}
Code: Select all
public function approve($customer_id) {
$customer_info = $this->getCustomer($customer_id);
if ($customer_info) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET approved = '1' WHERE customer_id = '" . (int)$customer_id . "'");
$customer_language_info = $this->db->query("SELECT cgd.`language_id` FROM `" . DB_PREFIX . "customer_group_description` cgd INNER JOIN `" . DB_PREFIX . "customer_group` cg ON (`cg.`customer_group_id` = cgd.`customer_group_id`) INNER JOIN `" . DB_PREFIX . "customer` c ON (c.`customer_group_id` = cg.`customer_group_id`) WHERE c.`customer_id` = '" . (int)$customer_id . "' AND cg.`customer_group_id` = '" . (int)$customer_info['customer_group_id'] . "'");
if ($customer_language_info->num_rows) {
$this->load->model('localisation/language');
$language_info = $this->model_localisation_language->getLanguage($customer_language_info->row['language_id']);
if ($language_info) {
$language_code = $language_info['code'];
$language_filename = $language_info['filename'];
$language_directory = $language_info['directory'];
} else {
$language_code = '';
$language_filename = '';
$language_directory = '';
}
$language = new Language($language_directory);
$language->load($language_filename);
$language->load('mail/customer');
$this->load->model('setting/store');
$store_info = $this->model_setting_store->getStore($customer_info['store_id']);
if ($store_info) {
$store_name = $store_info['name'];
$store_url = $store_info['url'] . 'index.php?route=account/login';
} else {
$store_name = $this->config->get('config_name');
$store_url = HTTP_CATALOG . 'index.php?route=account/login';
}
$message = sprintf($language->get('text_approve_welcome'), $store_name) . "\n\n";
$message .= $language->get('text_approve_login') . "\n";
$message .= $store_url . "\n\n";
$message .= $language->get('text_approve_services') . "\n\n";
$message .= $language->get('text_approve_thanks') . "\n";
$message .= $store_name;
$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($customer_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($store_name);
$mail->setSubject(html_entity_decode(sprintf($language->get('text_approve_subject'), $store_name), ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($message, ENT_QUOTES, 'UTF-8'));
$mail->send();
}
}
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Hi,
Thanks for your reply but I tried it and it's not working. Now when trying to approve a customer I get a blank page and the email doesn't get send.
I'm using opencart 1.5.1.3.
Do you have any other suggestion?
Thanks in advance.
Regards
Thanks for your reply but I tried it and it's not working. Now when trying to approve a customer I get a blank page and the email doesn't get send.
I'm using opencart 1.5.1.3.
Do you have any other suggestion?
Thanks in advance.
Regards
What does your admin - > systems - > error logs states regarding this behavior specifically ?Now when trying to approve a customer I get a blank page and the email doesn't get send.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Who is online
Users browsing this forum: No registered users and 2 guests