Jump to content

Prevent order status update


Recommended Posts

Im currently looking into automation of our stores since we spend a lot of time of diffrent taskes that could be done with a "one click" action.

 

My issues is that when we update the order to shipped we would like to capture the transactions in the gateway our customer have paid with. After a little research in the core files and how Bulk status update works it seemed to us like we should be able to use "actionOrderStatusUpdate" hook to check everything before we change the status of the order. 

 

An we can check with our gateway and collect the paid amount by automatic but the biggest issue for us is that if we for some reason fails to capture the money, the order is still changed to "shipped". is it possible somehow to prevent the update of the order when our check fails in actionOrderStatusUpdate ?

public function hookActionOrderStatusUpdate($params)
	{
		$order = new Order($params['id_order']);
		if($order->module = "gateway" && $params['newOrderStatus']->id = Configuration::get('PS_OS_SHIPPING'))
		{
			// Here goes our code for checks if fails it should stop update of status.
			// It sets $ok to true/false depending on if the payment is captured.
			if(!$ok)
			{
				$this->context->controller->errors[] = sprintf(Tools::displayError('ORDER: #%d. CAPTURE ERROR!', $params['id_order']);
				//Stop updating of this orders status
			}

		}

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

No that does not seem to be possible.  The actionOrderStatusUpdate hook is intended to notify modules that the order status is going to be changed, but does not provide any method to prevent the status from being changed.

 

Then there is actionOrderStatusPostUpdate, which is executed after the status is changed.

 

Looks like you might have to create an override of the process so that you could prevent the status from changing if the capture fails.

Link to comment
Share on other sites

  • 5 months later...

Then there is actionOrderStatusPostUpdate, which is executed after the status is changed.

 

The thing is, i really did like to do it before the status really changes and if case the payment do not meet the requirement for some reason. That could be an Employee changed the cart content, so the total order do not match the amount authorized by the payment gateway.

 

I might look into the dynamic Hooks, like hookActionObjectOrderHistoryAddBefore and maybe it would be possible that way to change or cancel the order status update. Question is then just if it woud also prevent the system from sending out emails or not.

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

  • 5 months later...
  • 2 years later...

Hi, I add my question here because the title is quite inherent in what I would like to ask.

My intention is to prevent certain "employees" from changing the status order when it has been changed (eg on "shipped") by the Admin.
Is it possible to set this block?

 

I'm talking about Prestashop 1.7.5

Edited by shon (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...