0

I am looking to set up an e-commerce site on Drupal 10 (Commerce 2).

Here is the goal:

A user should not be able to create an account without having placed an order. Therefore, on the account settings page (admin/config/people/accounts), under "Who can register accounts?" I select: administrators only.

During the checkout process, the user has two options:

Either they have previously ordered on the site and thus have an account and can log into their account before finalizing their order. If they do not do so and their email is recognized once the order is complete, the order is automatically attached to their account.

Or they do not have an account, in which case they are invited to proceed as a guest. In this case, the account is automatically created once the order is completed, and the user receives an email to log into the newly created account, change their password, and their username (by default it is the email used for the order).

Therefore, in the checkout process, I select:

Assign an anonymous order to a pre-existing user (If the email associated with the order matches an existing user account, the order will be assigned to that account.)

Create a new account for an anonymous order (Creates a new user account on checkout completion if the customer specified a non-existent e-mail address.)

Notify customer of their new account (Sends an email alerting the customer of their new account, with a password reset link to access their account.)

However, when an order is "placed," no user account is created.

Please can you explain where I am making a mistake.

Thank you in advance for your responses.

1 Answer 1

0

Out of the box, this works exactly as you expect. I just confirmed with a clean installation of Commerce Kickstart 3.x. Depending on your test environment, it's possible the user was created and the order was assigned to it but no email was sent.

3
  • Sorry, I didn't give you the URL of the website to give you an idea: acces-piste.com
    – Alexdezark
    Commented May 14 at 6:33
  • As you can see in this screenshot of the "commerce_orders" table in the database: The orders have been successfully created, an incremented order number has been assigned to them, but the unique identifier of the customer account remains zero. These orders are not associated with any customer account. Here is a link to the image: partage.acces-piste.com/Capture-2024-05-16.jpg This is a problem because when a customer returns to the site they find no data. The order appears on the /admin/commerce/orders page, but the customer is "anonymous," and generated link is user/0.
    – Alexdezark
    Commented May 16 at 7:10
  • Perhaps you could give me some pointers so that I can place some Drupal::logger('TEST')->notice() in the right files to try to find the moment when the customer is not generated. I remain at your disposal to answer any questions, but also to provide you with a copy of the files used and the database for further testing if necessary.
    – Alexdezark
    Commented May 16 at 7:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.