While accounts can be created from anonymous order checkouts (in the last step of checkout), I propose anonymous orders should be associated to new accounts created after checkout by looking up orders with the new account's email address and relating them to the new Drupal user.

See WIP PR: https://github.com/drupalcommerce/commerce/pull/520

CommentFileSizeAuthor
#4 2808813.diff2.48 KBsteveoliver

Comments

steveoliver created an issue. See original summary.

steveoliver’s picture

Issue summary: View changes

Update issue summary.

steveoliver’s picture

Issue summary: View changes

Added GitHub WIP PR link.

steveoliver’s picture

Assigned: steveoliver » Unassigned
Category: Task » Feature request
Status: Active » Needs review
StatusFileSize
new2.48 KB
bojanz’s picture

Title: Associate anonymous orders to new accounts via email » Create a recipe for assigning anon orders on user registration
Category: Feature request » Task
Status: Needs review » Needs work

The current implementation has a security hole: it works regardless of whether email confirmation is enabled.
So if email confirmation is disabled, I can register using another person's email address and get access to their orders.

Another problem is that it doesn't use CartAssignment (since it's cart specific), but the implementation in the hook is incomplete (it won't move the customer profile, for example). So I've refactored CartAssignment to allow this code to use it: #2811085: Refactor CartAssignment into an OrderAssignment class.

After discussing this with Ryan and Matt, we agreed that this should be documented as a recipe in our docs.
It's not generic enough to be used on all sites, and sites might want to tweak it based on their own business rules (only convert incomplete orders, only complete orders younger than 6 months, etc).

So, let's add a check for the email confirmation (return early if it's off), I'll then transfer the code from here into the documentation.