Search code examples
phpapachemodel-view-controlleropencartopencart-3

Opencart Missing Orders: $this->model_checkout_order->addOrderHistory(...) not being executed


Every incoming order's order status can't be updated. Any default extension such as cash on delivery and any controller that runs $this->model_checkout_order->addOrderHistory(...); is not executing. However, it seems that events are being fired for order emails are still being received. ?

Even on the admin area, updating the missing order's status or any order is not working. I have tried duplicating the function addOrderHistory to testOrderHistory (with the very same contents) and updated every call from $this->model_checkout_order->addOrderHistory(...); to $this->model_checkout_order->testOrderHistory(...); and it seems to work now.

However I would like to avoid editing core files just to fix it. Is there any other way? It also feels wrong to just change all core files from $this->model_checkout_order->addOrderHistory(...); to $this->model_checkout_order->testOrderHistory(...);

I have also checked both server logs and opencart logs and I can't find anything of relevance.

I have also tested returning strings from both testOrderHistory() and addOrderHistory() and proceeds to log them. Logging works fine at the controller's end but $this->model_checkout_order->addOrderHistory(...); always returns a bool(true) rather than the string I've been trying to return. However $this->model_checkout_order->testOrderHistory(...); seems to return the string correctly.

I'm stucked, It would be nice if you guys can shed me some light with regards to this. Thanks~

Using opencart 3.0.3.7


Solution

  • I did it. $this->model_checkout_order->addOrderHistory(...); was not being called because I've added another custom function that listens on event addOrderHistory/before that returns a boolean. This in turn halts the sequence.

    I did not know that there are controllers that must not return a value especially if it is listening on an event.