Post by MarcPinnell » Wed Mar 28, 2018 1:47 am

Working to add a custom email that is sent to the store owner when an order is placed in OC 3.02. I have it working wonderfully, except for one piece and I think it has to do with timing. The order emails appear to go out before the order history entries are written to the order_history table. Unfortunately, I need the authorize.net info that is there.

From my testing it would appear the order of operations are:
1) Click "confirm" on the confirm order / payment info screen
2) Payment is processed if necessary (like authorize.net)
3) Order emails are dispatched
4) Order and order history tables are updated.

So, my question is this, where does the order email controller get called/triggered? I've tried a multi-file search for "mail/order", but came up empty. I essentially need to reverse steps 3 & 4 so I can get at the info in the order_history table.

New member

Posts

Joined
Wed Jul 26, 2017 1:12 am

Post by straightlight » Wed Mar 28, 2018 1:50 am

Launched from the oc_event database table and executed into the catalog/controller/mail/order.php file to output the information in the catalog/view/theme/<your_theme>/template/mail folder.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by MarcPinnell » Wed Mar 28, 2018 3:57 am

Interesting! Never noticed that before. Looking through it I kinda get what is going on with the trigger/action columns. But what about the syntax?

To get what I need, would it be as simple as changing:
catalog/model/checkout/order/addOrderHistory/before
to
catalog/model/checkout/order/addOrderHistory/after

New member

Posts

Joined
Wed Jul 26, 2017 1:12 am

Post by MarcPinnell » Wed Mar 28, 2018 4:49 am

So I tried the obvious and just changed before to after, but all that did was cause it to not send any emails at all. :( Must be something else that I would need to change?

New member

Posts

Joined
Wed Jul 26, 2017 1:12 am

Post by straightlight » Wed Mar 28, 2018 5:17 am

To get what I need, would it be as simple as changing:
catalog/model/checkout/order/addOrderHistory/before
to
catalog/model/checkout/order/addOrderHistory/after
What is it that you need?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by MarcPinnell » Wed Mar 28, 2018 5:28 am

I need the order history to be written before I send the emails so that I can retrieve it in the email send controller.

Or at the very least I need to find a way to pass the information that would end up in the comment field to the order email controller.

New member

Posts

Joined
Wed Jul 26, 2017 1:12 am

Post by straightlight » Wed Mar 28, 2018 5:38 am

Or at the very least I need to find a way to pass the information that would end up in the comment field to the order email controller.
Simply go to your relative payment controller and modify the comment text which would be way simpler. Another way would be to update the comment field in the edit() method of your catalog/controller/api/order.php file.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by MarcPinnell » Wed Mar 28, 2018 5:57 am

I don't need to edit or modify the comment field. I need to retrieve it in the order email. Right now the order email fires before the comment is written to order_history.
I am good with the idea of passing the comment field to the order email controller, but have no clue how to pass it. Save it as a session var? I am using the authorize.net payment extension.

New member

Posts

Joined
Wed Jul 26, 2017 1:12 am

Post by straightlight » Wed Mar 28, 2018 6:06 am

Simply go to your relative payment controller ...
I am good with the idea of passing the comment field to the order email controller, but have no clue how to pass it. Save it as a session var? I am using the authorize.net payment extension.
Then, the first idea is what you'd be looking for; the payment controller. In your catalog/controller/extension/payment folder, you have your authorizenet controller files. Since you didn't specified which one you were using on your last post, pick the relative file. As for the session vars, that would be correct:

Code: Select all

$this->session->data['comment']

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by MarcPinnell » Wed Mar 28, 2018 8:21 am

Thank you, that did the trick!

New member

Posts

Joined
Wed Jul 26, 2017 1:12 am
Who is online

Users browsing this forum: OSWorX and 419 guests