I need some help in a craft backend plugin.
I use this plugin in a commerce order page.

I'm using it to handle onStatusChange (commerce_orderHistories).
In this event, i'm testing a custom variable order and current order status.

Here is my code ...

public function init() {
    craft()->on('commerce_orderHistories.onStatusChange', [$this, 'onStatusChange']);

public function onStatusChange(Event $event) {
    $customVar = $event->params['order']->customVar;
    $orderStatusId = $event->params['order']->orderStatus->id;

    if ($orderStatusId == 2 && $customVar == '') {
        $event->performAction = false;
        craft()->userSession->setFlash('error', 'CustomVar required');
        $order->orderStatusId = 1;

If orderStatusId = 2 and customVar is empty :
   -  orderStatusId go back to 1
   -  set Flash Error
   -  Save order

It's working, status go back to 1.
But there is no refresh/reload/redirect of the page.
Just my status modal get closed.
And if I reload manually, i've got the Flash Error.

I'm not sure about the good way do to it ...

Thanks for your help !

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.