<p>I  am working on a craftcms + commerce project and I need to add a billing address to new user during its registration process. The idea is to have a billing address added to any newly registered user (no shipping address needed, as the shop will deliver no physical product).</p>
<p>I have been struggling with this and managed to get the user registered and the address record created in the DB with a 2-step form flow (first register user, then add address), but the address does not get linked to the user.</p>
<p>Is this possible or perhaps I am trying something completely against the way craftcms/commerce works?</p>

CC BY-SA 4.0
2020-08-18T07:37:58.873Z
That should definitely work... are you successfully populating the userId field in the save-user form when saving the address?
James Smith
CC BY-SA 4.0
2020-08-18T09:32:08.217Z
I think I figured out how this works. craftcms/commerce creates a "floating" customer as soon as a guest (not logged user) visits the page. In order to properly add addresses to a user (frontend) it has to be logged in.  
So the process would be: register user -> activate -> user logs in -> user adds addresses.  
I am thinking a way would be checking if the user has any registered address in the login form and:  
- If they  have no addresses, set a redirect to the profile/add address form.  
- If they already have at least one address, set a redirect to homepage.
juanlopez4691
<plugin-craftcommerce><users><registration>
Add billing address to user on registration
# Add billing address to user on registration

(Asked by: username_0 on 2020-08-17)

I am working on a craftcms + commerce project and I need to add a billing address to new user during its registration process. The idea is to have a billing address added to any newly registered user (no shipping address needed, as the shop will deliver no physical product).

I have been struggling with this and managed to get the user registered and the address record created in the DB with a 2-step form flow (first register user, then add address), but the address does not get linked to the user.

Is this possible or perhaps I am trying something completely against the way craftcms/commerce works?

**Tags:** plugin-craftcommerce, users, registration

> **Comments:**
> **username_1**: That should definitely work... are you successfully populating the userId field in the save-user form when saving the address?  
> **username_0**: I think I figured out how this works. craftcms/commerce creates a "floating" customer as soon as a guest (not logged user) visits the page. In order to properly add addresses to a user (frontend) it has to be logged in.   So the process would be: register user -> activate -> user logs in -> user adds addresses.   I am thinking a way would be checking if the user has any registered address in the login form and:   - If they  have no addresses, set a redirect to the profile/add address form.   - If they already have at least one address, set a redirect to homepage.  

---

## 0 answers

