OCA_Detailed Order Admin Email Notification(1.5.2) vQmod - worked on 1.5.6.4 OpenCart v1.5.x only - 2


/ Published in: XML
Save to your folder(s)

Allow you to change the admin notification email to the same level of detail as the customer receives.


Copy this code and paste it in your HTML
  1. <modification>
  2. <id>OCA_Detailed Order Admin Email Notification(1.5.x)</id>
  3. <version>1.0</version>
  4. <vqmver>1.0.0</vqmver>
  5. <author>Joel - http://opencartaddons.com - [email protected]</author>
  6. <file name="catalog/model/checkout/order.php">
  7. <operation>
  8. <search position="replace"><![CDATA[$mail->setText($text);]]></search>
  9. <add><![CDATA[
  10. $mail->setHtml($html);
  11. $mail->setText(html_entity_decode($text, ENT_QUOTES, 'UTF-8'));
  12. $mail->addAttachment(DIR_IMAGE . $this->config->get('config_logo'));
  13. ]]></add>
  14. </operation>
  15. <operation>
  16. <search position="before" index="2"><![CDATA[$mail = new Mail();]]></search>
  17. <add><![CDATA[
  18. // HTML Mail
  19. $template = new Template();
  20.  
  21. $template->data['title'] = sprintf($language->get('text_new_subject'), html_entity_decode($order_info['store_name'], ENT_QUOTES, 'UTF-8'), $order_id);
  22.  
  23. $template->data['text_greeting'] = sprintf($language->get('text_new_received'));
  24. $template->data['text_link'] = '';
  25. $template->data['text_download'] = '';
  26. $template->data['text_order_detail'] = $language->get('text_new_order_detail');
  27. $template->data['text_invoice_no'] = $language->get('text_new_invoice_no');
  28. $template->data['text_order_id'] = $language->get('text_new_order_id');
  29. $template->data['text_date_added'] = $language->get('text_new_date_added');
  30. $template->data['text_payment_method'] = $language->get('text_new_payment_method');
  31. $template->data['text_shipping_method'] = $language->get('text_new_shipping_method');
  32. $template->data['text_email'] = $language->get('text_new_email');
  33. $template->data['text_telephone'] = $language->get('text_new_telephone');
  34. $template->data['text_ip'] = $language->get('text_new_ip');
  35. $template->data['text_payment_address'] = $language->get('text_new_payment_address');
  36. $template->data['text_shipping_address'] = $language->get('text_new_shipping_address');
  37. $template->data['text_product'] = $language->get('text_new_product');
  38. $template->data['text_model'] = $language->get('text_new_model');
  39. $template->data['text_quantity'] = $language->get('text_new_quantity');
  40. $template->data['text_price'] = $language->get('text_new_price');
  41. $template->data['text_total'] = $language->get('text_new_total');
  42. $template->data['text_footer'] = '';
  43. $template->data['text_powered'] = '';
  44.  
  45. $template->data['logo'] = 'cid:' . basename($this->config->get('config_logo'));
  46. $template->data['store_name'] = $order_info['store_name'];
  47. $template->data['store_url'] = $order_info['store_url'];
  48. $template->data['customer_id'] = $order_info['customer_id'];
  49. $template->data['link'] = '';
  50. $template->data['download'] = '';
  51.  
  52. if (isset($comment) && isset($notify)) {
  53. if ($comment && $notify) {
  54. $template->data['comment'] = nl2br($comment);
  55. } else {
  56. $template->data['comment'] = '';
  57. }
  58. }
  59.  
  60. $template->data['invoice_no'] = $invoice_no;
  61. $template->data['order_id'] = $order_id;
  62. $template->data['date_added'] = date($language->get('date_format_short'), strtotime($order_info['date_added']));
  63. $template->data['payment_method'] = $order_info['payment_method'];
  64. $template->data['shipping_method'] = $order_info['shipping_method'];
  65. $template->data['email'] = $order_info['email'];
  66. $template->data['telephone'] = $order_info['telephone'];
  67. $template->data['ip'] = $order_info['ip'] . '<br/><b>' . $language->get('text_new_order_status') . '</b> ' . $order_status;
  68.  
  69. if ($order_info['shipping_address_format']) {
  70. $format = $order_info['shipping_address_format'];
  71. } else {
  72. $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
  73. }
  74.  
  75. $find = array(
  76. '{firstname}',
  77. '{lastname}',
  78. '{company}',
  79. '{address_1}',
  80. '{address_2}',
  81. '{city}',
  82. '{postcode}',
  83. '{zone}',
  84. '{zone_code}',
  85. '{country}'
  86. );
  87.  
  88. $replace = array(
  89. 'firstname' => $order_info['shipping_firstname'],
  90. 'lastname' => $order_info['shipping_lastname'],
  91. 'company' => $order_info['shipping_company'],
  92. 'address_1' => $order_info['shipping_address_1'],
  93. 'address_2' => $order_info['shipping_address_2'],
  94. 'city' => $order_info['shipping_city'],
  95. 'postcode' => $order_info['shipping_postcode'],
  96. 'zone' => $order_info['shipping_zone'],
  97. 'zone_code' => $order_info['shipping_zone_code'],
  98. 'country' => $order_info['shipping_country']
  99. );
  100.  
  101. $template->data['shipping_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
  102.  
  103. if ($order_info['payment_address_format']) {
  104. $format = $order_info['payment_address_format'];
  105. } else {
  106. $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
  107. }
  108.  
  109. $find = array(
  110. '{firstname}',
  111. '{lastname}',
  112. '{company}',
  113. '{address_1}',
  114. '{address_2}',
  115. '{city}',
  116. '{postcode}',
  117. '{zone}',
  118. '{zone_code}',
  119. '{country}'
  120. );
  121.  
  122. $replace = array(
  123. 'firstname' => $order_info['payment_firstname'],
  124. 'lastname' => $order_info['payment_lastname'],
  125. 'company' => $order_info['payment_company'],
  126. 'address_1' => $order_info['payment_address_1'],
  127. 'address_2' => $order_info['payment_address_2'],
  128. 'city' => $order_info['payment_city'],
  129. 'postcode' => $order_info['payment_postcode'],
  130. 'zone' => $order_info['payment_zone'],
  131. 'zone_code' => $order_info['payment_zone_code'],
  132. 'country' => $order_info['payment_country']
  133. );
  134.  
  135. $template->data['payment_address'] = str_replace(array("\r\n", "\r", "\n"), '<br />', preg_replace(array("/\s\s+/", "/\r\r+/", "/\n\n+/"), '<br />', trim(str_replace($find, $replace, $format))));
  136.  
  137. $template->data['products'] = array();
  138.  
  139. foreach ($order_product_query->rows as $product) {
  140. $option_data = array();
  141.  
  142. $order_option_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_option WHERE order_id = '" . (int)$order_id . "' AND order_product_id = '" . (int)$product['order_product_id'] . "'");
  143.  
  144. foreach ($order_option_query->rows as $option) {
  145. if ($option['type'] != 'file') {
  146. $option_data[] = array(
  147. 'name' => $option['name'],
  148. 'value' => (strlen($option['value']) > 20 ? substr($option['value'], 0, 20) . '..' : $option['value'])
  149. );
  150. } else {
  151. $filename = substr($option['value'], 0, strrpos($option['value'], '.'));
  152.  
  153. $option_data[] = array(
  154. 'name' => $option['name'],
  155. 'value' => (strlen($filename) > 20 ? substr($filename, 0, 20) . '..' : $filename)
  156. );
  157. }
  158. }
  159.  
  160. $template->data['products'][] = array(
  161. 'name' => $product['name'],
  162. 'model' => $product['model'],
  163. 'option' => $option_data,
  164. 'quantity' => $product['quantity'],
  165. 'price' => $this->currency->format($product['price'], $order_info['currency_code'], $order_info['currency_value']),
  166. 'total' => $this->currency->format($product['total'], $order_info['currency_code'], $order_info['currency_value'])
  167. );
  168. }
  169.  
  170. $template->data['totals'] = $order_total_query->rows;
  171.  
  172. if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/mail/order.tpl')) {
  173. $html = $template->fetch($this->config->get('config_template') . '/template/mail/order.tpl');
  174. } else {
  175. $html = $template->fetch('default/template/checkout/mail/order.tpl');
  176. }
  177. ]]></add>
  178. </operation>
  179. </file>
  180. </modification>

URL: https://forum.opencart.com/viewtopic.php?t=45829#p224874

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.