Page 1 of 2

Modifying Order Conformation email

Posted: Sun Jan 07, 2018 8:32 am
by enduroforum
Hi there

Two issues:
1) How can I receive an exact copy of the order confirmation email that is sent to the customer?
2) The order alert sent to the shop owner does not even contain customer name or email address. I tried to alter order_alert.twig but have not been successfull so far. I went to the controler file "order.php" to see how data is passed into the twig-file and found the $data-array. For instance:
$data['order_id'] = ...;
$data['email'] = ... ;
Within the twig-file {{ order_id }} prints the order id.
Copying {{ order_id }} within the twig-file will simply print me the same order id again. BUT: {{ email }} (not used within the order_alert.twig so far) will print nothing. In fact, I can copy any field within the twig-file that is already available in the code and it will print the respective value again but I cannot add any new field.
I access the twig-file via a FTP-connection (tried the template editow: same issue). Once done editing, I clear the server cache within opencart through the button provided on the dashboard.

???

By the way: I just installed a fresh version of OC and tried the above: Same issue!
Hopefully someone can help me here.

Cheerz!
Mike

Re: Modifying Order Conformation email

Posted: Sun Jan 07, 2018 8:49 pm
by straightlight
No OC version posted.
$data['email'] = ... ;
What does this explain to forum posters in order to gather the proper solution exactly?

Re: Modifying Order Conformation email

Posted: Mon Jan 08, 2018 12:04 am
by enduroforum
Sorry, I wanted to keep it brief and the content of the variable does not really matter. I am running version 3.0.2.0.
Here you go:
As I said, I was checking "order.php" to see which variables (apart from those already used in "order_alert.twig") are available.
I found "$data['order_id'] = $order_info['order_id'];" in "order.php" and I found {{ order_id }} in "order_alert.twig". Thus, I tried to use another simple varibale and went for "$data['email'] = $order_info['email'];". I inserted {{ email }} into "order_alert.twig" but the respective mail sent to my account did not contain the email address. In fact, it contained nothing new. So I simply copy/pasted {{ order_id }} to see if changes to the "order_alert.twig" file are noted/processed at all. And they are: The email I received contained the respective order ID twice.
If I copy/paste variables which are already used in "order_alert.twig", everything works as expected.
Using any other varible available within the $data-array in "order.php" and putting {{ VAR_NAME }} into the twig file does not work, though.

Does this help?
If not, I can elaborate even more.

Thanks for your time!

Re: Modifying Order Conformation email

Posted: Mon Jan 08, 2018 5:50 pm
by adamharrisuk
I'm also looking to change the admin confirmation email! The standard one is pretty useless.

Re: Modifying Order Conformation email

Posted: Tue Jan 09, 2018 7:43 am
by straightlight
adamharrisuk wrote:
Mon Jan 08, 2018 5:50 pm
I'm also looking to change the admin confirmation email! The standard one is pretty useless.
More information would be needed.

Re: Modifying Order Conformation email

Posted: Fri Jan 12, 2018 5:50 am
by enduroforum
I think an answer to my original issues would also be helpful for what adamharrisuk is looking for.

Re: Modifying Order Conformation email

Posted: Fri Jan 12, 2018 6:12 am
by straightlight
enduroforum wrote:
Fri Jan 12, 2018 5:50 am
I think an answer to my original issues would also be helpful for what adamharrisuk is looking for.
Then, you would also need to provide more information based on this inquiry.

Re: Modifying Order Conformation email

Posted: Fri Jan 12, 2018 8:01 am
by enduroforum
See my post #9: What kind of additional information are you looking for with respect to my initial question/enquery/problem?

Re: Modifying Order Conformation email

Posted: Fri Jan 12, 2018 9:48 am
by straightlight
enduroforum wrote:
Fri Jan 12, 2018 8:01 am
See my post #9: What kind of additional information are you looking for with respect to my initial question/enquery/problem?
The exact variables of your codes with their values or the attachment file that shows your modifications.

Re: Modifying Order Conformation email

Posted: Fri Jan 12, 2018 8:37 pm
by enduroforum
Original \opencart\catalog\view\theme\default\template\mail\order_alert.twig
{{ text_received }}

{{ text_order_id }} {{ order_id }}
{{ text_date_added }} {{ date_added }}
{{ text_order_status }} {{ order_status }}

Code found in \opencart\catalog\controller\mail\order.php
Line 101: $data['order_id'] = $order_info['order_id'];
Line 105: $data['email'] = $order_info['email'];

Edited \opencart\catalog\view\theme\default\template\mail\order_alert.twig
{{ text_received }}

{{ text_order_id }} {{ order_id }}
{{ text_order_id }} {{ order_id }}
{{ email }}
{{ text_date_added }} {{ date_added }}
{{ text_order_status }} {{ order_status }}

The edited "order_alert.twig" returns the order ID twice but does not give the email address.
Thus, as I said before: If I copy/paste variables which are already used in "order_alert.twig", everything works as expected.
Using any other varible available within the $data-array in "order.php" and putting {{ VAR_NAME }} into the twig file does not work.

Please let me know if you need more Information to help me with this.

Thanks.

Re: Modifying Order Conformation email

Posted: Sat Jan 13, 2018 6:34 am
by straightlight
Code found in \opencart\catalog\controller\mail\order.php
At this lines did you added these entries in the controllers and under which method name?

Re: Modifying Order Conformation email

Posted: Sun Jan 14, 2018 7:32 pm
by enduroforum
All I did is described in the above posts.
If there is anything else I need to do in order to add additonal fields to the order confirmation mail, kindly let me know.

Re: Modifying Order Conformation email

Posted: Sun Jan 14, 2018 7:47 pm
by straightlight
Code found in \opencart\catalog\controller\mail\order.php
Line 101: $data['order_id'] = $order_info['order_id'];
Line 105: $data['email'] = $order_info['email'];
What you did is also indicating this portion of the code but did not mentioned where exactly in the mail/order.php file you did added those lines.

Re: Modifying Order Conformation email

Posted: Sun Jan 14, 2018 11:57 pm
by enduroforum
As I stated: "Coude FOUND in ..."
It's nothing I added. Opencart contains this code within order.php.

Re: Modifying Order Conformation email

Posted: Mon Jan 15, 2018 12:04 am
by straightlight
Now, I understand. Ok, the reason why that's the case it's because you are attempting to use the email within the order alert TWIG files but the core only uses it in the order add TWIG file of the catalog/view/theme/<your_theme>/template/mail folder.

To rectify this, in your catalog/controller/mail/order.php file, in the alert(&$route, &$args) { method,

find:

Code: Select all

$data['order_id'] = $order_info['order_id'];
add below:

Code: Select all

$data['text_email'] = $language->get('text_email');

$data['email'] = $order_info['email'];
Then, in your order_alert.twig file, you can then replicate the {{ text_email }} and the {{ email }} of the order add TWIG file.

Re: Modifying Order Conformation email

Posted: Tue Jan 16, 2018 4:17 am
by enduroforum
Hi

Adding these lines does not change a thing. :-(
I cleared all cashed afterwards.

See my other problem with the shopping cart: viewtopic.php?f=202&t=200989

Seems to be the same issue: No matter what I change, issues remain.

Re: Modifying Order Conformation email

Posted: Tue Jan 16, 2018 5:59 am
by straightlight
As a test, in your admin/controller/common/dashboard.php file,

after:

Code: Select all

<?php
add:

Code: Select all

echo 'test123';
Then, go to your admin dashboard. Do you see the test123 on the top of the page?

Re: Modifying Order Conformation email

Posted: Wed Jan 17, 2018 4:20 pm
by enduroforum
Hi (and thanks for staying with me!)

Yes, that worked!

Re: Modifying Order Conformation email

Posted: Thu Jan 18, 2018 5:39 am
by straightlight
Is your storage folder located outside of your public_html folder? If not, it has to be by also configuring your config.php and admin/config.php files for the modified DIR_STORAGE as well as removing the entire line in your .htaccess file where the ^system/storage folder is specified.

Re: Modifying Order Conformation email

Posted: Tue Jan 23, 2018 5:48 am
by enduroforum
I am about to give up...
Editing these files should be so freaking easy!?

I removed OC 3.0.2.0 since no code adjustments within any PHP file were reflected. I even tried this on a freshly installed instance: Same issues. Not even the "your cart is empty"-bug could be remediated.
So, I am now runing on OC 3.0.1.1. At least this version does not have the "your cart is empty"-bug (hurray!).

Still, though, changes to the PHP files seem to be ignored:
- I went to "\catalog\controller\mail\order.php" and inserted:

Code: Select all

$data['text_email'] = $language->get('text_email');
$data['email'] = $order_info['email'];
- I went to "\catalog\view\theme\default\template\mail\order_alert.twig" and inserted:

Code: Select all

{{ text_email }} {{ email }}
The result was that within the alert email, there was an additional line break where I expected the email address.

In addition, I went to "\catalog\controller\account\account.php" and removed:

Code: Select all

$data['newsletter'] = $this->url->link('account/newsletter', '', true);
From my understanding, this should remove the newsletter link from the right column on the "my account" page of the front end user.
Guess what!? Nothing changed!

Am I really the only one who is having such problems?

I generally agree that the root cause of errors sits mostly between the keyboard and the chair... but as I said: I am running a fresh version of OC.

Could this be a caching problem? Something else I noted just today:
- I add an item to my cart
- The button on the top right side of the page instantly changes and reflects the respective amount
- I click on this button, a box opens and click on the cross behind the item in order to remove this item from the cart.
- The box closes and the button does not show any amount.
- I click on the button, a box opens and I DO SEE the item I actually removed.
- Actually going to my cart reveales that the cart is empty.
Image

Sounds like a caching issue to me.