Email template for new email
Posted: Tue Mar 28, 2017 9:01 pm
I am using Advanced Professional Email Template, and i am sending an email from catelog account/customer page for auto reward notification. How could i set the template here.
OpenCart Community Forum - Discuss shopping cart and e-commerce solutions.
https://forum.opencart.com/
Code: Select all
$this->load->model('extension/mail/template');
$load_data = array(
'emailtemplate_key' => 'order.customer',
'language_id' => $order_info['language_id'],
'store_id' => $order_info['store_id']
);
$template = $this->model_extension_mail_template->load($load_data);
Code: Select all
$template->data['foo'] = 'test';
// Or pass full array
$template->addData($data);
Code: Select all
$mail = new Mail();
$mail->setTo($order_info['email']);
$mail->setFrom($this->config->get('config_email'));
$mail->setSender($order_info['store_name']);
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
$mail = $template->hook($mail);
$mail->send();
Code: Select all
$template->sent();
Code: Select all
$this->load->model('extension/mail/template');
// Load email template
$load_data = array(
'emailtemplate_key' => 'order.customer',
'language_id' => $order_info['language_id'],
'store_id' => $order_info['store_id']
);
$template = $this->model_extension_mail_template->load($load_data);
// Optional add data
$template->data['foo'] = 'test';
// Or pass full array
$template->addData($data);
$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->setFrom($fromID);
$mail->setTo($product_info['customer_email']);
$mail->setSender($store_name);
$mail->setSubject("product from " .$order_info['store_name']. " - Ref : ".$invoice_no);
//$mail->setHtml($this->load->view('mailtemplates/product', $data));
// Merge template and mail settings.
$mail = $template->hook($mail);
// Optional wrap text inside email template
$html = $template->fetch(null, $this->load->view('mailtemplates/product', $data));
$mail->setHtml($html);
$mail->send();
$template->sent();