Is there a way to add some customer details to the Email Alert which goes to the administrator after a new order has been placed?
I kind of understand PHP, so writing something myself is no problem.
I already wrote myself a script which emails me some user details when they login to the site, but I can't seem to get any details about customers when they place an order.
Help would be really appreciated, because this is the only thing preventing me from launching the shop..
Kind regards,
Marijn Rutten
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
The OC version is 3.0.2.0
When I receive mail that a customer ordered something from the store, I only receive:
- Order number
- Date of purchase
- Order status
- Products
- SubTotal
- Total
I also want to see who bought something from the site.
Where can I edit these settings?
Kind Regards,
Marijn Rutten
In catalog/controller/mail/order.php
Code: Select all
$data['date_added'] = date($this->language->get('date_format_short'), strtotime($order_info['date_added']));
Code: Select all
$data['name'] = $order_info['firstname'])." ".$order_info['lastname']);
Code: Select all
$data['text_date_added'] = $this->language->get('text_date_added');
Code: Select all
$data['text_fullname'] = $this->language->get('text_fullname');
In catalog/language/your_language/mail/order_alert.php find this
Code: Select all
$_['text_date_added'] = 'Date Added:';
Code: Select all
$_['text_fullname'] = 'Name:';
In catalog/view/theme/your_theme_name/template/mail/order_alert.twig find this
Code: Select all
{{ text_date_added }} {{ date_added }}
Code: Select all
{{ text_fullname }} {{ name }}
Opencart Solutions | opencart-solutions.com
With this you can have an exact copy of what the customer gets.
Visit the next file:
Catalog/controller/mail/order.php
Go to:
Code: Select all
public function add($order_info, $order_status_id, $comment, $notify) {
Under:
Code: Select all
$mail->send();
Code: Select all
mail('YOURMAIL@.com', 'New incoming order', $this->load->view('mail/order_add', $data), 'Content-Type: text/html; charset=UTF-8\r\n');
Go to "System"->"Settings"->"Edit"->"Mail" and unmark "New order"
So you won't get duplicate mails from new orders
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I think it's simple,replace in /catalog/controller/mail/order.php line
$mail->setTo($order_info['email']);
with line
$mail->setTo($order_info['email'].";".$from);
or use instead of $from something like $mail->setTo($order_info['email'].";mail@mail.com");
Cheers,
Thomas
If the above solutions are not the answer, then what is the solution?straightlight wrote: ↑Wed Jan 24, 2018 4:34 amI would not suggest the use of the proposed solution above since most hosting providers may filter multiple outbound email activities with the use of different email protocols.
Proper email configuration or the use of an extension that will alternate these manual tactics due to server configuration that may require different email headers in order to send those emails.Ninjas-Everywhere! wrote: ↑Mon Mar 26, 2018 12:05 amIf the above solutions are not the answer, then what is the solution?straightlight wrote: ↑Wed Jan 24, 2018 4:34 amI would not suggest the use of the proposed solution above since most hosting providers may filter multiple outbound email activities with the use of different email protocols.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
If we are receiving the various emails generated by the system, then the email is configured correctly. I am trying to figure out the correct way to adjust the Order Email that is generated by the system and sent to the Administrator to include the First and Last Name of the person who placed the order along with the details that are already present in the email.
The data was added in the .twig files (parameters copied from the New Account email .twig), but in the email generated by the system when a new order is placed, it only shows a space where the information is supposed to be and not the actual information.
If there needs to be an extension added in order to perform this, seemingly small but important function, then which extension do you recommend?
find:
Code: Select all
$data['comment'] = strip_tags($order_info['comment']);
Code: Select all
if ($order_info['payment_address_format']) {
$format = $order_info['payment_address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['payment_firstname'],
'lastname' => $order_info['payment_lastname'],
'company' => $order_info['payment_company'],
'address_1' => $order_info['payment_address_1'],
'address_2' => $order_info['payment_address_2'],
'city' => $order_info['payment_city'],
'postcode' => $order_info['payment_postcode'],
'zone' => $order_info['payment_zone'],
'zone_code' => $order_info['payment_zone_code'],
'country' => $order_info['payment_country']
);
$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))));
if ($order_info['shipping_address_format']) {
$format = $order_info['shipping_address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}
$find = array(
'{firstname}',
'{lastname}',
'{company}',
'{address_1}',
'{address_2}',
'{city}',
'{postcode}',
'{zone}',
'{zone_code}',
'{country}'
);
$replace = array(
'firstname' => $order_info['shipping_firstname'],
'lastname' => $order_info['shipping_lastname'],
'company' => $order_info['shipping_company'],
'address_1' => $order_info['shipping_address_1'],
'address_2' => $order_info['shipping_address_2'],
'city' => $order_info['shipping_city'],
'postcode' => $order_info['shipping_postcode'],
'zone' => $order_info['shipping_zone'],
'zone_code' => $order_info['shipping_zone_code'],
'country' => $order_info['shipping_country']
);
$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))));
you can use:
Code: Select all
{% if payment_address %}
{{ payment_address }}
{% endif %}
{% if shipping_address %}
{{ shipping_address }}
{% endif %}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Thank you for the code. I added thestraightlight wrote: ↑Tue Mar 27, 2018 6:37 amIn catalog/controller/mail/order.php file,
find:
add above:Code: Select all
$data['comment'] = strip_tags($order_info['comment']);
Then, in your catalog/view/theme/<your_theme>/template/mail/order_alert.twig file,Code: Select all
if ($order_info['payment_address_format']) { $format = $order_info['payment_address_format']; } else { $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; } $find = array( '{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}' ); $replace = array( 'firstname' => $order_info['payment_firstname'], 'lastname' => $order_info['payment_lastname'], 'company' => $order_info['payment_company'], 'address_1' => $order_info['payment_address_1'], 'address_2' => $order_info['payment_address_2'], 'city' => $order_info['payment_city'], 'postcode' => $order_info['payment_postcode'], 'zone' => $order_info['payment_zone'], 'zone_code' => $order_info['payment_zone_code'], 'country' => $order_info['payment_country'] ); $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)))); if ($order_info['shipping_address_format']) { $format = $order_info['shipping_address_format']; } else { $format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}'; } $find = array( '{firstname}', '{lastname}', '{company}', '{address_1}', '{address_2}', '{city}', '{postcode}', '{zone}', '{zone_code}', '{country}' ); $replace = array( 'firstname' => $order_info['shipping_firstname'], 'lastname' => $order_info['shipping_lastname'], 'company' => $order_info['shipping_company'], 'address_1' => $order_info['shipping_address_1'], 'address_2' => $order_info['shipping_address_2'], 'city' => $order_info['shipping_city'], 'postcode' => $order_info['shipping_postcode'], 'zone' => $order_info['shipping_zone'], 'zone_code' => $order_info['shipping_zone_code'], 'country' => $order_info['shipping_country'] ); $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))));
you can use:
where you see fit.Code: Select all
{% if payment_address %} {{ payment_address }} {% endif %} {% if shipping_address %} {{ shipping_address }} {% endif %}
Code: Select all
if ($order_info['payment_address_format']) {
$format = $order_info['payment_address_format'];
...<remaining code posted>
Code: Select all
$data['comment'] = strip_tags($order_info['comment']);
Code: Select all
{{ text_received }}
{{ text_firstname }} {{ firstname }}
{{ text_lastname }} {{ lastname }}
{{ text_email }} {{ email }}
{{ text_order_id }} {{ order_id }}
{{ text_date_added }} {{ date_added }}
{{ text_order_status }} {{ order_status }}
{{ text_product }}
...
Code: Select all
{% if payment_address %}
{{ payment_address }}
{% endif %}
{% if shipping_address %}
{{ shipping_address }}
{% endif %}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
"You have received an order.
Jack Boettra<br />1972<br />3410 Fawstenme Ln<br />Round Rock, Texas 78681<br />United States
Order ID: 63
Date Added: 04/04/2018
Order Status: Processing
Products
1x (Member x1) 1 Month - Unlimited ((Member x1) 1 Month - Unlimited) $125.00
Totals
Sub-Total: $125.00
Total: $125.00"
Any ideas?
Code: Select all
$data['firstname'] = strip_tags(html_entity_decode($order_info['shipping_firstname'], ENT_QUOTES, 'UTF-8'));
$data['lastname'] = strip_tags(html_entity_decode($order_info['shipping_lastname'], ENT_QUOTES, 'UTF'8'));
Code: Select all
{% if firstname and lastname %}
{{ firstname }} {{ lastname }}
{% endif %}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Code: Select all
if ($order_info['payment_address_format']) {
$format = $order_info['payment_address_format'];
} else {
$format = '{firstname} {lastname}' . "\n" . '{company}' . "\n" . '{address_1}' . "\n" . '{address_2}' . "\n" . '{city} {postcode}' . "\n" . '{zone}' . "\n" . '{country}';
}
$find = array(...
Code: Select all
$data['comment'] = strip_tags($order_info['comment']);
Code: Select all
{% if payment_address %}
{{ payment_address }}
{% endif %}
{% if shipping_address %}
{{ shipping_address }}
{% endif %}
But when I do a test purchase I get nothing new in the alert email. I have gone through your instructions step by step multiple times to see if I missed anything but I got nothing. I swear I did exactly what you instructed.
What else might I be missing?
Thanks!
p.s. I have opencart 3.0.2.0
Users browsing this forum: Google [Bot] and 419 guests