Address field from MODX user versus Commerce twig template

I don’t understand how works the address field key under the file shipping-address-fields.twig
Indeed, the default template using address-shipping-address1 and address-shipping-address2 where the MODX user form contain only one address field :crazy_face:
I’m trying to retrieve the address field from my user account during the checkout address step but it don’t want !

What is the correct way to retrieve it (and eventually update it if changed after form validation) ?

Enable the UserProfileAddress module, that will retrieve, set and update the user address in the right place in Commerce. No need to make any template changes at all.

Yes I know this module and it is already activated !
All the others fields are correctly retrieved.

The point is on the two fields on the twig template (address1 and address2) when on the MODX user profile, there is only one field : address

The UserProfileAddress module already accounts for that; the address user field is split up by line breaks (\n) and assigned to address1, address2 and address3 fields in Commerce automatically.

Same in the reverse direction when choosing to update the address on the profile, address1-3 are combined with a linebreak and stored to the user profile address.

Ooooooooookkkkkk.
Thanks for the information. I have to understand now why I don’t retrieve it correctly !

1 Like