Thanks (again) for the great module! Though I really love the functionality it offers, I am also struggling with a few settings that apply to multiple forms.
The core functionality of redirecting users to a login page works excellent. Optionally allowing anonymous checkout if the Continue without register
setting is used works also great, but as soon as the Use username as order email
and Use anonymous checkout as option to login form
are being used we run into problems since these options mostly focus on the login forms, but also apply to the registration and user profile forms.
Situation 1: Only the Use username as order email
is in use
When this setting is in use the following happens for the user login, registration and user profile forms:
$form['name']['#title'] = t('Email');
$form['actions']['continue_button']['#limit_validation_errors'] = array(array('name'));
$form['actions']['continue_button']['#validate'][] = 'commerce_checkout_redirect_username_as_order_email_form_validate';
Problems:
- $form['name'] only exists on login forms, the other forms use $form['account']['name']. No harm done since the other forms contain dedicated e-mail fields, but these forms now contain a
name
element with just a#title
property. - At a login form: Since the
name
field is in the#limit_validation_errors
array, a valid value is required. This is not being communicated to the user who sees two required fields of which only one happens to be required. Only after clicking the Checkout without an account button the user finds out that thename
/ Email field is required through an error message. - At the registration form: This form also requires a value for the
name
field, but it's title still is Username.
The Use anonymous checkout as option to login form
comes to the rescue to clear things up.
Situation 2: Only the Use anonymous checkout as option to login form
is in use
- Now the login forms contain a required Username field and Do you have a password? radio buttons, the Password field is initially hidden. The user can continue without entering a username, so the Username field could initially also be hidden and the name of the radio buttons could change to Do you have an account?.
- The registration form contains the required Username and E-mail fields, required Password fields (if e-mail verification is not required) and optionally other user profile fields. At the bottom of the form remains the Do you have a password? radio buttons. These radio buttons only control the submit buttons since the password element in the form array of register forms is located at
$form['account']['pass']
instead of$form['pass']
. Users might start filling in fields, see these radio buttons, leave it's value at No since they do not have a password yet, press the Continue button and continue to checkout while all input data is being discarded.
Situation 3: Both Use username as order email
and Use anonymous checkout as option to login form
are in use
This works great for the login forms: the name field is titled Email
and is initially visible which is perfect since it's value is required in all cases.
On registration forms again it does not make much sense to me. Problems from situation 1 and 2 get combined. It could make more sense if the registration form initially would look like the login form by retitling the name
field and hiding all other fields.
My two cents
Ideally I think the registration form should only be altered if neither Use username as order email
nor Use anonymous checkout as option to login form
is in use. In this case no username or e-mail address is required, an anonymous checkout button does not validate any fields and the user will just be redirected.
Also I cannot think of a situation where the Continue to checkout button at the password reset page comes in handy without causing trouble. I guess that users often first click the one-time login link, then the Continue to checkout button and eventually forget to set a password and have to request another one-time login link. Also see #2388783: Users cannot set their initial passwords when they continue shopping instead of immediately setting the password.
And I am curious why the user profile form is being altered, can anyone tell me in which situations this form is available for anonymous users? Maybe when using the Profile 2 module?
Proposal
Since I am sure there is use case for almost every setup, I propose to add a setting which allows site maintainers to select which forms should be altered by the module:
- user_login
- user_login_block
- user_register_form
- user_profile_form
- user_pass_reset
This way a site maintainer gains much more control over the user experience.
After this is done I think it's worth to optimize each combination of settings by reconsidering texts and which fields should be shown / hidden initially.
Comments
Comment #1
lmeurs CreditAttribution: lmeurs commentedI attached a patch that:
commerce_checkout_redirect_form_alter()
preliminary if the form is not anonymous checkout enabled. Still thecommerce_checkout_redirect_redirect_anonymous_submit
submit callback is added to unset session variables when necessary.Comment #2
andrea.brogi CreditAttribution: andrea.brogi commentedGreat, #1 is working correctly.
This my cent for user interface.
I'm using anonimous checkout only with "Login form block".
In the original version of this block "Create new account" and "Request new password" are displayed under the "Password" Input Form.
With anonimous checkout are located directly under "Email" Form.
The better solution should be display "Request new password" only if you chose "Yes".
Thanks for #1
Comment #3
elsteff1385 CreditAttribution: elsteff1385 commentedSubscribing, #1 is working great.
I am also using the patch in https://www.drupal.org/node/2391341, which works great too.
Thanks lmeurs
Comment #4
vasike@lmeurs:
- Do we really need the helper function : commerce_checkout_redirect_get_anonymous_checkout_forms()?
- Could you confirm it won't affect the existing (working) "checkout redirects" if this features is commited (module update without doing anything else)?
of course thank you for your help.
Comment #5
lmeurs CreditAttribution: lmeurs commented@vasike: We do not need the helper function, but using it allows us to define the anonymous checkout forms once and use it from
commerce_checkout_redirect_settings()
andcommerce_checkout_redirect_form_alter()
. Also adding a hook might be a better solution.I can confirm the patch from #1 probably does break sites that did not set the new setting. Glancing at my patch from #1 I saw
commerce_checkout_redirect_form_alter()
did not check array keys in the right way.should have been:
After applying these changes locally and removing the
commerce_checkout_redirect_anonymous_checkout_forms
variable, users still get redirected as expected.The module has changed too much for a quick alteration and reroll, unfortunately I do not have the time to provide a new patch.
Comment #6
lmeurs CreditAttribution: lmeurs commentedComment #7
danielmrichards CreditAttribution: danielmrichards commentedHi @Imeurs, thanks for your patch. As you said in #5 it did need a re-roll and some tweaking, so I have done just that!
By and large the patch is the same as yours, just rerolled against 2.0-rc1 and fixed some coding standards issues. Also I did notice a bug with the suggested fix from #5 where that would not actually check the disabled form IDs correctly and all forms would still be affected. A bit of parsing was required to get the array of form IDs in a common format whether taken from the variable or the defaults:
Anyway, have a look at the patch and see what you think.
Comment #8
danielmrichards CreditAttribution: danielmrichards commentedComment #9
danielmrichards CreditAttribution: danielmrichards commentedAnother re-roll now that the module has hit 7.x-2.0.