2

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?

2
  • That should definitely work... are you successfully populating the userId field in the save-user form when saving the address? Aug 18 '20 at 7:37
  • 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. Aug 18 '20 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.