The goal is to create a new order when a new user registers wordpress site. To achieve that, the following hook was added to child theme's functions.php.
add_action( 'user_register', 'add_order', 10, 1 );
function add_order( $user_id ) {
$order = wc_create_order();
$order->set_customer_id($user_id);
$order->save();
}
However, when a new user registers, no new order is created. No error is seen in the log. Wondering how to achieve the goal correctly.