title: Hooks for order creation exclusively in Woocommerce 3
body: <p>I need to detect when a new WooCommerce order is successfully created and set to ‘processing’—this is to add some extra functionality etc. This is fine to do on the frontend as it’s pretty easy to hook in when an order is created via either of the WooCommerce <code>woocommerce_thankyou</code> or <code>woocommerce_order_status_processing</code> hooks.</p>
  
  <p>The problem I have is that <strong>I also want this to work when creating a new order manually via the backend of the website</strong>. I am using some custom fields when adding an order via manually which is used to manipulate the order when created. Unfortunately, although the <code>woocommerce_order_status_processing</code> does work for admin orders it seems to trigger before the order meta is saved—therefore when I try to retrieve any meta data it is empty.</p>
  
  <p>To get round this, I have tried the suggestions on <a href="https://stackoverflow.com/questions/44522910/woocommerce-hook-for-order-creation-from-admin">WooCommerce hook for order creation from admin</a> or on this <a href="https://github.com/woocommerce/woocommerce/issues/11967#issuecomment-249811534" rel="noreferrer">GitHub</a> thread which is to use the WordPress hooks <code>wp_insert_post</code> or <code>save_post_shop_order</code> (<code>save_post_{$post-&gt;post_type}</code>). This works to solve my order meta problem as it seems to trigger after the order meta is saved.</p>
  
  <p><em>However</em> — it triggers <strong>everytime</strong> there is an update or a new post so I need to find a way of detecting whether it’s a new post or not. There is an <code>$update</code> parameter on these hooks which is meant to show <em>‘Whether this is an existing post being updated or not’</em> but for some reason it always seems to be set to true even when it is a new post/order.</p>
  
  <h2>To summarise:</h2>
  
  <ul>
  <li>I need a WordPress/WooCommerce hook that is triggered after order/post meta is created via the backend <em>and</em> some way of only running this when an order is newly created and not updated.</li>
  </ul>
  
  <p>The only other way potentially of doing this that I can think of is as per <a href="https://wordpress.stackexchange.com/a/177670/63134">this suggestion</a> of checking post date vs. modified date but I just thought there must be a better way of doing this!</p>
  
  <h3>Here’s my current code just in case</h3>
  
  <pre><code>function my_order_created ( $post_id, $post, $update ) {
  
      // Don’t run if $post_id doesn’t exist OR post type is not order OR update is true
      if ( ! $post_id || get_post_type( $post_id ) != 'shop_order' || $update == 1 ) {
          return;
      }
  
      $order = wc_get_order( $post_id );
  
      if ( $order &amp;&amp; $order-&gt;has_status( 'processing' ) ){
  
          // Do something
  
      }    
  
  }
  
  add_action( 'wp_insert_post', 'my_order_created', 10, 3 );
  </code></pre>