Jump to content

How to trigger customer email sending after changes directly in the database


razvy

Recommended Posts

Hi,

 

I nee to know how to trigger email sending to the customers after I make a change directly in the database.

 

IE:

- when I change the tracking number, the customer must receive the "in_transit" email

- when I change the order status to shipped, the customer must receive the "shipped" email

 

The usual behaviour is to make these changes in the backoffice and then the emails are immediately sent. This is working fine.

 

But I don't use the backoffice for managing the orders, it is not convenient for me.

Instead, I'm using another way that allows me to make the changes directly in the database, but the problem is that the platform is not sending the emails after these changes are made.

 

How can I solve that?

 

Thanks!

Link to comment
Share on other sites

I've found this code:

if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars,
                            $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null,
                            _PS_MAIL_DIR_, true, (int)$order->id_shop)) {
                            Hook::exec('actionAdminOrdersTrackingNumberUpdate', array('order' => $order, 'customer' => $customer, 'carrier' => $carrier), null, false, true, false, $order->id_shop);
                            Tools::redirectAdmin(self::$currentIndex.'&id_order='.$order->id.'&vieworder&conf=4&token='.$this->token);
                        } else {
                            $this->errors[] = Tools::displayError('An error occurred while sending an email to the customer.');
                        }

But how can I call it from outside the controller?

Link to comment
Share on other sites

I need to call the trigger from ouside the controller.

 

To be more specific, here is my setup:

- I use an Excel spreadsheet to update my orders

- I update the values in the database directly in the database from the Excel file

- I need to call the trigger from the same place

 

I'm not a programmer, but as far as I can see, there are two options:

- I find a way to call the function directly from the Excel file (HOW?)

- I create a specific URL on the server that calls the function (HOW?), then I can acces this URL easily from VBA

 

Maybe there are other ways...

Link to comment
Share on other sites

  • 1 year later...

Hi,

Did you solve this?

I'm having a similar problem.

I use a 3rd party software to update the order status directly in the database.

However, I need a certain module to trigger on the status update, but since it is changed in the database the module does not trigger.

Any ideas?

Thanks

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...