Jump to content

[SOLVED] Prevent mailalerts from sending an email


devzk

Recommended Posts

Hello,

 

in my store when someone buys a product mailalerts send 2 emails. One for the customer and another for the admin/merchant configured in Mailalerts's BO settings.

 

Via PHP I want to prevent mailalerts to send an email to admin/merchant when order state id equals 8.

 

I checked mailalerts.php module and it has the hook function hookActionValidateOrder($params);

 

I know inside $params there's an Order object and I can access it like $params['order'];

 

So the default code (prestashop untouched) is:  

$order = $params['order'];

And then I check if the state equals 8:

if ($order->current_state == 8) {
  return;
}

But mailalerts keep sending the email.

 

I'm checking the state in the right place?

 

Thanks.

Edited by devzk (see edit history)
Link to comment
Share on other sites

Your code doesn't work this way. $order->current_state == 8 is referring to $order handeled as object. I don't think it is an object but rather an array with some values containing. You should dump the $order variable. If you are lucky, the current order state is already there. In my code further down I find the following which might work:

$order_state = $params['orderStatus'];
Link to comment
Share on other sites

 

Your code doesn't work this way. $order->current_state == 8 is referring to $order handeled as object. I don't think it is an object but rather an array with some values containing. You should dump the $order variable. If you are lucky, the current order state is already there. In my code further down I find the following which might work:

$order_state = $params['orderStatus'];

 

Scully, thank you so much it was that.

$order_state_id = $params['orderStatus']->id;

I'll check anyways what $params contains for further information.

 

Again, thanks!

Edited by devzk (see edit history)
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...