woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.37k stars 10.76k forks source link

The login form on checkout does not appear or redirects to accounts page when login is required during checkout and login on checkout is disabled. #48739

Open imodouglas opened 3 months ago

imodouglas commented 3 months ago

Prerequisites

Describe the bug

When login is required during checkout like when a subscription product is being purchased and the customer is not logged in, the login form on checkout does not appear nor does the page redirects to the My Accounts page when the Please log in link is clicked. See screenshot: https://d.pr/i/i2nGIL

See a screenshot of the account and privacy settings: https://d.pr/i/fm40EP

Note: This only happens when the classic checkout is used.

Expected behavior

The page should redirect to the My Account page so the customer and log in and be redirected back to the checkout page.

Actual behavior

Nothing happens

Steps to reproduce

  1. Create a subscription product and switch the checkout from blocks to classic.
  2. Set the account and privacy settings to look like this: https://d.pr/i/fm40EP
  3. Open a browser that you're not logged in.
  4. Purchase the product using the email of an existing account.
  5. You will get a message to log in. Click the Please log in link and nothing will happen.

WordPress Environment

[]

Isolating the problem

mikejolley commented 3 months ago

Hi @imodouglas Thanks for documenting the problem.

I can see that this is a problem caused by subscriptions and its option to allowed registration for subscriptions checkout—under these circumstances, duplicate accounts would see this notice from core:

https://github.com/woocommerce/woocommerce/blob/00f7420f81bdcb00a2ae5fee8db6235a88945ab6/plugins/woocommerce/includes/wc-user-functions.php#L57

However that notice reveals the login form using JavaScript and assumes its present. With the case of subscriptions, it may not be.

@woocommerce/quark This may need some kind of resolution from the Subscriptions side to customise woocommerce_registration_error_email_exists or force the form to display.

@woocommerce/rubik On our side, we can look into including a link to the my account page instead of <a href="#".. to act as a fallback. The jQuery code may need tweaking so that it allows the link to work if the form does not exist on the page.

Adding this to the backlog.