Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The billing information pane also includes a required field for "Full name". I've extended this module to also allow selection of name user fields so this field can be prepopulated as well. Supports the username field as well as custom fields for first/last name.
Patch attached in next post.
Recommended making this a full project ASAP.
Good work by iMiksu :)
Comments
Comment #1
mossy2100 CreditAttribution: mossy2100 commentedPatch
Comment #2
iMiksuActually this is already part of a full project. It's part of Commerce Extra, so I'll just move this issue there.
I'll check the patch details later. Can you rework the patch against Commerce Extra's Addess Populate?
Comment #3
mossy2100 CreditAttribution: mossy2100 commentedSure, I'll give it a crack! Thanks for the rapid response, much appreciated.
Comment #4
mossy2100 CreditAttribution: mossy2100 commentedNew patch attached. Sorry for so many changes, just trying to make it as good as possible and use programming best practices.
Comment #5
iMiksuI have tested the patch and thought thru your feature request.
My first thought was "Why just name field?". What makes name field so special that only that field should be populated by parallel fields? What if user has country or phone number? You could map your name into address field but not phone number?
Secondly, this feature pops up a bit out of scope, this module is more about Address Field and Commerce Customer. And I would really like to keep that simple as possible in sake of maintenance load ;)
Also, I see this feature request more related to address field than commerce stuff together with address field...
However, I was thinking still that how to achieve your need. I came up with an idea of using tokens. Maybe if we could write an separate module for defining default values for address field by defining tokens, your need would be achieved pretty nicely?
So, practically how it could work:
Note: This screenshot just demonstrate how this could work.
In summary, I would recommend to do this feature as a separate feature request to address field or to write an separate module.
Comment #6
mossy2100 CreditAttribution: mossy2100 commentedThe "Full name" field is displayed above the address on the checkout page.
Comment #7
mossy2100 CreditAttribution: mossy2100 commentedHi iMiksu
Sorry if I wasn't clear. When the customer checks out, a set of fields are displayed for their billing address. This includes field for "Full name" and the addressfield fields (see attached screenshot). Your module pre-populates the addressfield fields. My additions merely extend that functionality to also pre-populate the Full name field. Do you really think this should be a separate module? It would seem to me much simpler for users to have the functionality bundled. I agree that it's stretching the scope slightly to include the name, but not by much. A name is usually part of an address.
Comment #8
iMiksuI just think the proposed solution is too specific (just about name fields) and this can be done in more generic way so we can cover more use cases.
May I ask, why you use different name fields instead addressfield's full name fields? If you just configure your addressfield in user entity to have full name field too?
Comment #9
mossy2100 CreditAttribution: mossy2100 commented"I just think the proposed solution is too specific (just about name fields) and this can be done in more generic way so we can cover more use cases."
I agree in principle but when I look at the checkout page I only see fields for the Full name and address field. Is there something I'm missing?
"May I ask, why you use different name fields instead addressfield's full name fields? If you just configure your addressfield in user entity to have full name field too?"
That's not a bad idea - I didn't know addressfield supported a full name field. I will have a look at that.
Comment #10
mossy2100 CreditAttribution: mossy2100 commentedUpdated patch with support for addressfield name fields. See if you like it!
Comment #11
mossy2100 CreditAttribution: mossy2100 commentedHey iMiksu
Looks like your module does what I want anyway - just needed to setup the Full name field in the addressfield the same in both the customer profile and the user fields, and then the Full name field is prepopulated on the checkout page by your code as well, as part of the addressfield :)
Sorry if I wasted your time.
Thanks,
Mossy
Comment #12
iMiksuNo problem, I'm happy you provided patches because someone still can apply this feature even it's not ported into the module.
Thank you for your contribution!
Comment #13
mossy2100 CreditAttribution: mossy2100 commentedNo worries, thanks for making a useful module!