Main menu

Secondary menu

Automatic user Login for Anonymous Checkout

By Sil, 10/04/2012 - 12:27

Here's a quick howto on how to log in a new user right after the point of purchase in the case of an anonymous checkout in Drupal Commerce. This way a user doesn't have to go 'off-site' to check their email and confirm their account. You give them access to the account right at the point of purchase and you can instantly show the user content that's only available for users.

Step 1 - Make sure anonymous checkout is enabled

Check and make sure your anonymous user has access to the stores checkout at admin/people/permissions. The permission is called 'Access checkout' under 'Checkout'.

You can read more about the differences between authenticated and anonymous checkout in Drupal Commerce in this article.

Step 2 - Enable the module

Step 3 - Add the Login action to the Rule

Edit the Rule "Create a new account for an anonymous order" at Administration -> Configuration -> Workflow ->Rules (it's located at admin/config/workflow/rules/reaction/manage/commerce_checkout_new_account).

Click 'Add action' at the bottom of the page

Select 'Log in user' as the action to add (it's located under System)

enter 'account-created' as data selector.

(save)

The Rule result is supposed to look like this:

Step 4 - Test, Enjoy & Give back

Now make sure to test your checkout process for anonymous users. Be aware of the fact that 'the devil is in the detail' regarding the checkout process. Make sure to test test test. And remember: adding your experience and test results to the designated issue queues makes your own Drupal site better :) thanks.

Important note

"Just remember not to use this feature on the rule to Assign an anonymous order to a pre-existing user, as there is in core no password verification to ensure the anonymous user actually owns the account associated with the e-mail address they entered on the checkout form." (Ryan Szrama)