You get a bonus - 1 coin for daily activity. Now you have 1 coin

How to make opencart send order notification emails with full data to both the admin and the customer?

Practice



how do I make opencart send order notification emails with full data (including the invoice) both to the administrator and to the customer?

in the file catalog/model/checkout/order.php find

around line 497
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
$mail->setHtml($html);
$html2=$html;

$mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
$mail->send();



add $html2=$html;


and below add at line 558
$mail->setSender($order_info['store_name']);
$mail->setSubject(html_entity_decode($subject, ENT_QUOTES, 'UTF-8'));
$mail->setText(html_entity_decode($text2, ENT_QUOTES, 'UTF-8'));
$mail->setHtml($html2);
$mail->send();



$mail->setHtml($html2);

and how do I add product images to the order email message?

edit the file /model/checkout/order.php

1. $order_product_query = $this->db->query("SELECT * , o.quantity AS quantity FROM " . DB_PREFIX . "order_product ".
" o LEFT JOIN " . DB_PREFIX . "product p ON (p.product_id = o.product_id) ".

"WHERE o.order_id = '" . (int)$order_id . "'");
add the JOIN and aliases to the queries

2. $this->load->model('tool/image'); load the model that provides the image-resizing method
3. add a variable holding the image $template->data['products'][] = array(
'name' => $product['name'],
'model' => $product['model'],
'option' => $option_data,
'image' => $this->model_tool_image->resize($product['image'], 190, 190),



4. in the file /catalog/view/theme/yourtheme/template/mail/order.tpl add
the image output to the email
after
How to make opencart send order notification emails with full data to both the admin and the customer?

I have a problem: some images aren't visible
in mail.ru mail

I looked and found that they contain Russian letters... it seems they need to be encoded correctly in the URL somewhere

in the file /catalog/model/tool/image.php of opencart

at the very end add urlencode

if (isset($this->request->server['HTTPS']) && (($this->request->server['HTTPS'] == 'on') || ($this->request->server['HTTPS'] == '1'))) {
return HTTPS_IMAGE . urlencode($new_image);
} else {
return HTTP_IMAGE . urlencode($new_image);
}

if the folders have Russian letters in their names, the images still don't show — it seems there's a problem with the slash / being replaced by urlencode with %2F, and it's better to leave it as /
and the space being replaced by urlencode with +, and it's better to use %20

so it's better to do it like this
return HTTP_IMAGE . str_replace('+', '%20', str_replace('%2F', '/', urlencode($new_image)));

See also

  • [[b6841]]
  • [[b11166]]
  • [[b11329]]
  • [[b730]]
  • [[b8929]]
  • [[b11558]]
  • [[b5196]]
  • [[b11273]]
  • [[b6020]]
  • [[b11601]]
  • [[b11276]]
  • [[b11625]]
  • [[b11545]]
  • [[b11659]]
  • [[b11165]]
  • [[b4749]]
  • [[b11845]]
  • [[b6409]]
  • [[b5963]]
  • [[b4379]]

See also

Comments

To leave a comment

If you have any suggestion, idea, thanks or comment, feel free to write. We really value feedback and are glad to hear your opinion.
To reply

Lectures and tutorial on "Running server side scripts using PHP as an example (LAMP)"

Terms: Running server side scripts using PHP as an example (LAMP)