<p>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:</p>

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

CC BY-SA 4.0
2018-12-24T18:05:34.390Z
2018-12-24T18:05:34.390Z
Flying Car 0013
<p>I am trying to update an order's custom field after order complete. 
I set it like this in my plugin:</p>

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

<p>But it is not working. I guess I used the wrong method to do it. </p>

<plugin-craftcommerce2>
Update an order custom field after order complete in Craft 3
# Update an order custom field after order complete in Craft 3

(Asked by: username_0 on 2018-12-24)

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.

**Tags:** plugin-craftcommerce2


---

## 1 answers

### Answer by username_0 on 2018-12-24. Score: 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");
});


---

