1
Answers
Vote up!
0
Vote down!

How do i specify a user name for new account other than the email address on an anonymous order?

Ok so here's the use case:

Our site also includes phpBB forums, which of course display the user name in posts... most people don't like their email address being displayed, for obvious reasons.

Orders placed by anonymous users automatically generates an account with the username the same as the email address. I want to keep the auto account creation, but have the user enter a UserID when they enter their billing info.

So i've created a field on the billing profile (field_account_name is the machine name). How do i reference that field in the entity creation rule? I looked at this topic:
http://www.drupalcommerce.org/questions/5370/how-do-i-base-new-account-u...
but that doesn't show me how to reference a field i've created, only ones that already exist in the commerce-order entity.

This might be a stupid question, but i'm still relatively new to drupal... any help would be HUGELY appreciated.

Asked by: joleenshook
on January 2, 2014

1 Answer

Vote up!
2
Vote down!

joleenshook,

So, this is a relatively tricky request because of all the edge cases that could pop up:

  • What if that username is taken?
  • Do you want to hide the field when someone is logged in?
  • What if the supplied username gets "sanitized"?
  • Not to mention all the frustrations that exist when usernames are the primary way of identifying someone (avoiding profanity, common misspellings, etc)

As long as you are aware this solution doesn't account for any of the above edge cases, it's really pretty easy :)

STEP BY STEP

Step 1) Find the rule "Create a new account for an anonymous order"

Step 2) Click "Add Condition"

Step 3) Choose "Entity has field"

Step 4) Specify the entity "Commerce Customer Billing" ... you want the "data selector" to say something like this (notice it doesn't have a colon): commerce-order:commerce-customer-billing

Step 5) Choose your custom field you added to the Billing profile

Step 6) Click "Edit" next to "Create a new identity"

Step 7) In the "Name" you can select your new field :)

Josh Miller
Answer by: Josh Miller
Posted: Jan 15, 2014

Comments

Thanks - that worked quite nicely. Now to work on the rules to handle the fringe cases ;)

- joleenshook on January 15, 2014