Hi,
I indeed didn't understood that you wanted to create a cart for another user than the one currently connected.
In that case, after creating the cart and adding the products to it, you can simply run an update query on it to change the user_id to the user_id of the user and potentially the session_id to the session_id of the user for which you want to assign the cart.
If you want to know the session_id based on the current user_id, you first need to load the user_cms_id from the hikashop_user table using the user_id you know. Then, you need to load the session_id from the table session using the user_cms_id you just got on the userid column.