Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-12-24T18:05:34.390Z
Answers.LastActivityDate: 2018-12-24T18:05:34.390Z
Answers.UserDisplayName: Flying Car 0013
Body: <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>
  
Tags: <plugin-craftcommerce2>
Title: Update an order custom field after order complete in Craft 3
ThreadText: # 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");
  });
  
  ```
  
  
  ---
  
  