2

I am trying to update an order's custom field after order complete. I set it like this in my plugin:

Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, function(Event $e) {
        $order = $e->sender;
        $order->setFieldValue("customFieldHandle", "My value");
    });

But it is not working. I guess I used the wrong method to do it.

2

What I wrote is correct. I debugged it, and I had a problem in another place where the order did not get completed in the first place. silly me LOL. So my answer is:

Event::on(Order::class, Order::EVENT_AFTER_COMPLETE_ORDER, function(Event $e) {
    $order = $e->sender;
    $order->setFieldValue("customFieldHandle", "My value");
});
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.