Hello OpenCarters,
I am trying to add some information to the order alert email that is sent to the store owner when a customer places an order, and I need some help to get it working.
I’ve just started using OpenCart, and I’m not a professional programmer, but I have a lot of programming experience (from long ago) and am familiar with HTML and CSS. The Model–Controller–View architecture is new to me, but I have a basic understanding of how it works. This is my first post to this forum, and I was unable to find an answer to my question using the search function. If I have forgotten to include any essential information, please ask.
I have a working online store, built with the help of a web designer, running on OpenCart version 3.0.3.8, mostly with the Default theme, but overlayed with a custom theme (made by the web designer, who has used it for many other customers in the past). It uses the Bank Transfer, Cash On Delivery, and EasyStripe PRO v4.6 extensions and the following modifications: Custom Shipping Method (author: Mika Design; version 1.5.0 OC3x), Quick Checkout By ModulePoints (author: ModulePoints; version 3x), and Show Information Pages in Menu (author: Davx, version 1.0). It also has three languages installed (Swedish, English, Dutch). The new site just went live a couple of weeks ago.
The standard ‘order alert’ email looks like this:
You have received an order.
Order ID: 100
Date added: 2022-05-15
Order status: Pending
Products
1x Coffee cup (CC002L) $15
1x Tea cup (TC004) $12
Totals
Sub-total: $27
Shipping: $9
Tax: $9
Total: $45
I want to add the customer’s ID, first name, last name, telephone number and email address.
Here are the five steps I took during my attempt to implement this change:
Step 1 (adding the label text to the language files). I changed the catalog\language\xx-xx\mail\order_alert.php files (where xx-xx represents the language code) for the three installed languages by adding the following five lines, localized with the correct text for each language:
$_['text_customer_id'] = 'Customer ID:';
$_['text_firstname'] = 'First name:';
$_['text_lastname'] = 'Last name:';
$_['text_telephone'] = 'Tel. no.:';
$_['text_email'] = 'Email address:';
Step 2 (adding the new info to the view). I changed the catalog\view\theme\default\template\mail\order_alert.twig file by adding the following five lines between line 1 ({{ order_id}}) and line 3 ({{text_order_id }} {{ order_id }}):
{{ text_customer_id }} {{ customer_id }}
{{ text_firstname }} {{ firstname }}
{{ text_lastname }} {{ lastname }}
{{ text_telephone }} {{ telephone }}
{{ text_email }} {{ email }}
Step 3 (adding the lookup for the label text to the controller). I changed the catalog\controller\mail\order.php file by adding the five lines to the Admin Alert Mail section (which starts on line 333). In this section, where the content of the email is gathered (comment ‘HTML Mail’ on line 364), the first line is:
$data['text_received'] = $this->language->get('text_received');
I added five lines just below it, as follows:
$data['text_customer_id'] = $this->language->get('text_customer_id');
$data['text_firstname'] = $this->language->get('text_firstname');
$data['text_lastname'] = $this->language->get('text_lastname');
$data['text_telephone'] = $this->language->get('text_telephone');
$data['text_email'] = $this->language->get('text_email');
Step 4 (verifying that the data is made available in the model). In the controller (the file from step 3) I can see that the getOrder function is called in line 359:
$order_info = $this->model_checkout_order->getOrder($order_id);
And when I look at the getOrder function in the model file (\catalog\model\checkout\order.php), starting on line 118, I can see that the return array already includes the data I am looking for (customer_id, firstname, lastname, email, and telephone on lines 175-179).
Step 5 (testing). When I place a test order, the store owner receives the order alert email and it includes the new text labels (that were added to the language file in step 1), but the actual content that should appear after those labels is missing.
Can anyone tell me what I did wrong or forgot to do? All help and tips will be greatly appreciated!
I am trying to add some information to the order alert email that is sent to the store owner when a customer places an order, and I need some help to get it working.
I’ve just started using OpenCart, and I’m not a professional programmer, but I have a lot of programming experience (from long ago) and am familiar with HTML and CSS. The Model–Controller–View architecture is new to me, but I have a basic understanding of how it works. This is my first post to this forum, and I was unable to find an answer to my question using the search function. If I have forgotten to include any essential information, please ask.
I have a working online store, built with the help of a web designer, running on OpenCart version 3.0.3.8, mostly with the Default theme, but overlayed with a custom theme (made by the web designer, who has used it for many other customers in the past). It uses the Bank Transfer, Cash On Delivery, and EasyStripe PRO v4.6 extensions and the following modifications: Custom Shipping Method (author: Mika Design; version 1.5.0 OC3x), Quick Checkout By ModulePoints (author: ModulePoints; version 3x), and Show Information Pages in Menu (author: Davx, version 1.0). It also has three languages installed (Swedish, English, Dutch). The new site just went live a couple of weeks ago.
The standard ‘order alert’ email looks like this:
You have received an order.
Order ID: 100
Date added: 2022-05-15
Order status: Pending
Products
1x Coffee cup (CC002L) $15
1x Tea cup (TC004) $12
Totals
Sub-total: $27
Shipping: $9
Tax: $9
Total: $45
I want to add the customer’s ID, first name, last name, telephone number and email address.
Here are the five steps I took during my attempt to implement this change:
Step 1 (adding the label text to the language files). I changed the catalog\language\xx-xx\mail\order_alert.php files (where xx-xx represents the language code) for the three installed languages by adding the following five lines, localized with the correct text for each language:
$_['text_customer_id'] = 'Customer ID:';
$_['text_firstname'] = 'First name:';
$_['text_lastname'] = 'Last name:';
$_['text_telephone'] = 'Tel. no.:';
$_['text_email'] = 'Email address:';
Step 2 (adding the new info to the view). I changed the catalog\view\theme\default\template\mail\order_alert.twig file by adding the following five lines between line 1 ({{ order_id}}) and line 3 ({{text_order_id }} {{ order_id }}):
{{ text_customer_id }} {{ customer_id }}
{{ text_firstname }} {{ firstname }}
{{ text_lastname }} {{ lastname }}
{{ text_telephone }} {{ telephone }}
{{ text_email }} {{ email }}
Step 3 (adding the lookup for the label text to the controller). I changed the catalog\controller\mail\order.php file by adding the five lines to the Admin Alert Mail section (which starts on line 333). In this section, where the content of the email is gathered (comment ‘HTML Mail’ on line 364), the first line is:
$data['text_received'] = $this->language->get('text_received');
I added five lines just below it, as follows:
$data['text_customer_id'] = $this->language->get('text_customer_id');
$data['text_firstname'] = $this->language->get('text_firstname');
$data['text_lastname'] = $this->language->get('text_lastname');
$data['text_telephone'] = $this->language->get('text_telephone');
$data['text_email'] = $this->language->get('text_email');
Step 4 (verifying that the data is made available in the model). In the controller (the file from step 3) I can see that the getOrder function is called in line 359:
$order_info = $this->model_checkout_order->getOrder($order_id);
And when I look at the getOrder function in the model file (\catalog\model\checkout\order.php), starting on line 118, I can see that the return array already includes the data I am looking for (customer_id, firstname, lastname, email, and telephone on lines 175-179).
Step 5 (testing). When I place a test order, the store owner receives the order alert email and it includes the new text labels (that were added to the language file in step 1), but the actual content that should appear after those labels is missing.
Can anyone tell me what I did wrong or forgot to do? All help and tips will be greatly appreciated!
Last edited by BHickman on Thu Jul 07, 2022 3:03 pm, edited 1 time in total.
Both OC caches should be cleared from the OC admin.BHickman wrote: ↑Tue Jun 07, 2022 10:31 pmHello OpenCarters,
I am trying to add some information to the order alert email that is sent to the store owner when a customer places an order, and I need some help to get it working.
I’ve just started using OpenCart, and I’m not a professional programmer, but I have a lot of programming experience (from long ago) and am familiar with HTML and CSS. The Model–Controller–View architecture is new to me, but I have a basic understanding of how it works. This is my first post to this forum, and I was unable to find an answer to my question using the search function. If I have forgotten to include any essential information, please ask.
I have a working online store, built with the help of a web designer, running on OpenCart version 3.0.3.8, mostly with the Default theme, but overlayed with a custom theme (made by the web designer, who has used it for many other customers in the past). It uses the Bank Transfer, Cash On Delivery, and EasyStripe PRO v4.6 extensions and the following modifications: Custom Shipping Method (author: Mika Design; version 1.5.0 OC3x), Quick Checkout By ModulePoints (author: ModulePoints; version 3x), and Show Information Pages in Menu (author: Davx, version 1.0). It also has three languages installed (Swedish, English, Dutch). The new site just went live a couple of weeks ago.
The standard ‘order alert’ email looks like this:
You have received an order.
Order ID: 100
Date added: 2022-05-15
Order status: Pending
Products
1x Coffee cup (CC002L) $15
1x Tea cup (TC004) $12
Totals
Sub-total: $27
Shipping: $9
Tax: $9
Total: $45
I want to add the customer’s ID, first name, last name, telephone number and email address.
Here are the five steps I took during my attempt to implement this change:
Step 1 (adding the label text to the language files). I changed the catalog\language\xx-xx\mail\order_alert.php files (where xx-xx represents the language code) for the three installed languages by adding the following five lines, localized with the correct text for each language:
$_['text_customer_id'] = 'Customer ID:';
$_['text_firstname'] = 'First name:';
$_['text_lastname'] = 'Last name:';
$_['text_telephone'] = 'Tel. no.:';
$_['text_email'] = 'Email address:';
Step 2 (adding the new info to the view). I changed the catalog\view\theme\default\template\mail\order_alert.twig file by adding the following five lines between line 1 ({{ order_id}}) and line 3 ({{text_order_id }} {{ order_id }}):
{{ text_customer_id }} {{ customer_id }}
{{ text_firstname }} {{ firstname }}
{{ text_lastname }} {{ lastname }}
{{ text_telephone }} {{ telephone }}
{{ text_email }} {{ email }}
Step 3 (adding the lookup for the label text to the controller). I changed the catalog\controller\mail\order.php file by adding the five lines to the Admin Alert Mail section (which starts on line 333). In this section, where the content of the email is gathered (comment ‘HTML Mail’ on line 364), the first line is:
$data['text_received'] = $this->language->get('text_received');
I added five lines just below it, as follows:
$data['text_customer_id'] = $this->language->get('text_customer_id');
$data['text_firstname'] = $this->language->get('text_firstname');
$data['text_lastname'] = $this->language->get('text_lastname');
$data['text_telephone'] = $this->language->get('text_telephone');
$data['text_email'] = $this->language->get('text_email');
Step 4 (verifying that the data is made available in the model). In the controller (the file from step 3) I can see that the getOrder function is called in line 359:
$order_info = $this->model_checkout_order->getOrder($order_id);
And when I look at the getOrder function in the model file (\catalog\model\checkout\order.php), starting on line 118, I can see that the return array already includes the data I am looking for (customer_id, firstname, lastname, email, and telephone on lines 175-179).
Step 5 (testing). When I place a test order, the store owner receives the order alert email and it includes the new text labels (that were added to the language file in step 1), but the actual content that should appear after those labels is missing.
Can anyone tell me what I did wrong or forgot to do? All help and tips will be greatly appreciated!
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Did you clear all the caches?
https://www.antropy.co.uk/blog/how-to-c ... t-3-0-2-0/
https://www.antropy.co.uk/blog/how-to-c ... t-3-0-2-0/
UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk
Legendary Member
Thanks for the quick replies, Straightlight and Paul.
No, I hadn't cleared the caches.
So I repeated the test after first clearing the two caches (Theme and SASS) from the OC dashboard and then clearing all the caches in my browser (Microsoft Edge (version 102.0.1245.33).
Unfortunately, that didn't make any difference. The result was the same.
Any other ideas?
Just so you don't think I've just disappeared: I'm going to be out of the office until Tuesday, June 14th.
No, I hadn't cleared the caches.
So I repeated the test after first clearing the two caches (Theme and SASS) from the OC dashboard and then clearing all the caches in my browser (Microsoft Edge (version 102.0.1245.33).
Unfortunately, that didn't make any difference. The result was the same.
Any other ideas?
Just so you don't think I've just disappeared: I'm going to be out of the office until Tuesday, June 14th.
You have to pass that data to the view.
ex:
Code: Select all
$data['telephone'] = $order_info['telephone'];
Code: Select all
{{ telephone }}
Backup and learn how to recover before you make any changes!
Thanks, sw!tch! This was the missing piece of the puzzle for me. I added five lines to the controller file, and it now works perfectly. Your example made the solution clear, with little explanation needed. I appreciate your having taken the time to read my long post and providing an answer.sw!tch wrote: ↑Thu Jun 09, 2022 2:44 pmYou have to pass that data to the view.
ex:Then you can access your variable in the view.Code: Select all
$data['telephone'] = $order_info['telephone'];
Code: Select all
{{ telephone }}
Or, by using Event Triggers rather than playing with the core files. However, now that the issue has been resolved, please add: [SOLVED] at the beginning of the subject line on your first post.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Hey Hi Straightlight , I have a similar issue over additional email alert.
I'm using open cart Version3x and I've configured the additional email tab within settings.
Now iam trying to pass the value of product SKU or MPN input data to additional email alert in setting of the store.
Now what it should do is if I put email id into the field of SKU or MPN of any product then every time that particular product is purchased it should send alert mail to the email Id which I have put in SKU of that particular product.
Example :
In Product Id 40 if i have stated email (xyz@abc.com) in SKU text area then when product id 40 is purchased an email alert should be sent to the respective (xyz@abc.com) using the feature of additional email alert .
Similarly,
In Product Id 60 if i have stated email (pqr@123.com) in SKU text area then when product id 60 is purchased an email alert should be sent to the respective pqr@123.com) using the feature of additional email alert .
So every product have different sku as different email id so when particulat product is purchased it should send alert to that SKU based email id.
Please suggest ...
I'm using open cart Version3x and I've configured the additional email tab within settings.
Now iam trying to pass the value of product SKU or MPN input data to additional email alert in setting of the store.
Now what it should do is if I put email id into the field of SKU or MPN of any product then every time that particular product is purchased it should send alert mail to the email Id which I have put in SKU of that particular product.
Example :
In Product Id 40 if i have stated email (xyz@abc.com) in SKU text area then when product id 40 is purchased an email alert should be sent to the respective (xyz@abc.com) using the feature of additional email alert .
Similarly,
In Product Id 60 if i have stated email (pqr@123.com) in SKU text area then when product id 60 is purchased an email alert should be sent to the respective pqr@123.com) using the feature of additional email alert .
So every product have different sku as different email id so when particulat product is purchased it should send alert to that SKU based email id.
Please suggest ...
Who is online
Users browsing this forum: No registered users and 21 guests