In my custom plugin (working in WooCommerce 2.6.x and 3.x), I need to get the order ID when a new order is created. I tried different hooks but they work only when the customer creates an order and not when an order is created from admin.

I tried:

* woocommerce\_new\_order
* woocommerce\_thankyou
* woocommerce\_checkout\_order\_processed
* woocommerce\_checkout\_update\_order\_meta

**Update**

Finally I used this:

```
add_action('wp_insert_post', function($order_id)
{
    if(!did_action('woocommerce_checkout_order_processed') 
        && get_post_type($order_id) == 'shop_order'
        && validate_order($order_id))
    {
         order_action($order_id);
    }
});

```

where *validate\_order* is:

```
function validate_order($order_id)
{
    $order = new \WC_Order($order_id);
    $user_meta = get_user_meta($order->get_user_id());
    if($user_meta)
        return true;
    return false;
}

```

Thanks to *validate\_order* the action isn't executed when you start to create the order. I use `!did_action('woocommerce_checkout_order_processed')` because I don't want that the action is executed if the order is created by a customer (I have a specific action for that, using `woocommerce_checkout_order_processed`).