Post by asia » 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.

Newbie

Posts

Joined
Tue Mar 28, 2017 8:52 pm

Post by opencart-templates » Fri Mar 31, 2017 12:55 am

Let me know what code you have so far to send the email but here's an example.

1. Load template

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);
2. Add data (can be used as shortcodes e.g {$foo})

Code: Select all

$template->data['foo']  = 'test';
// Or pass full array
$template->addData($data);
3. Attach html template to mail object. Calling hook method to merge mail properties and sets html template.

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();
4. Called after email is sent. Cleans up attachments and other sent tasks

Code: Select all

$template->sent();

User avatar
Active Member

Posts

Joined
Mon May 16, 2011 7:24 pm
Location - UK

Post by estand » Sun May 20, 2018 3:30 am

Can you tell me how i can fix this with this code ?

//$this->template = 'mailtemplates/product_email.html';
$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));
$mail->send();

Newbie

Posts

Joined
Sun Jan 15, 2017 9:24 pm

Post by opencart-templates » Sun Jun 03, 2018 4:30 pm

See below example. Please open support ticket if you need support with this.

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();

Advanced Professional Email Template
Customers Pre-Sale. Inc abandoned cart email
Order Follow-Up Email. Inc request review
Email Validation with ZeroBounce


User avatar
Active Member

Posts

Joined
Mon May 16, 2011 7:24 pm
Location - UK
Who is online

Users browsing this forum: No registered users and 22 guests