How to know if who created the order Is it possible to determine who created the order? I've installed the entity reference module, then added a entity reference field in the order, but I'm not sure if this will work.

I've used the hook_form_alter() to get the current user id and set the current username as a default value.

How to check and save the current user who created the order upon saving the order? Will only set the default value on first save, then it won't change anymore in the next save.

Below is my code:

$user = $GLOBALS['user'];
if ($user-&gt;uid) {
  $form['field_order_created_by'][LANGUAGE_NONE][0]['target_id']['#default_value'] = $user-&gt;name;
}
What you can do is you can create a small table which keeps your order id, user id and anything else you want. Whenever the order is saved you can check whether a record exists for the particular order id. If there is no you add the record otherwise you don't change the current record.
For that you can use hook_commerce_order_presave(). Inside this hook you can use your code l

option 1

function yourmodule_commerce_order_presave($order){
    if(!db_result(db_query('SELECT * FROM {your_table} WHERE orderid = %d', $order-&gt;id)))
        $user = $GLOBALS['user'];
        if ($user-&gt;uid) {
            $form['field_order_created_by'][LANGUAGE_NONE][0]['target_id']['#default_value'] =       $user-&gt;name;

        //add new record to yuor table
    }

}


option 2

function yourmodule_commerce_order_presave($order){
    if(!check_record_exists($order-&gt;id))
        $user = $GLOBALS['user'];
        if ($user-&gt;uid) {
        $form['field_order_created_by'][LANGUAGE_NONE][0]['target_id']['#default_value'] =       $user-&gt;name;
    //add new record to your table
}

function check_record_exists($oid){
    $exists = db_result(db_query('SELECT * FROM {your_table} WHERE orderid = %d', $oid));
}