Magento 2 – Remove Login on Checkout if Email is Already Registered

checkoutmagento2

Currently at the checkout, if you enter an email that has already been registered in the system, Magento ask you to enter your password.

This is a problem because many customers don't remember their passwords.

How could I remove this login from the checkout? (i.e even if the email has been used before, allow to checkout normally without needing to log in)

Best Answer

You need to override vendor/magento/module-checkout/view/frontend/web/js/view/form/element/email.js file in your theme and force self.isPasswordVisible(false);.

Around line 58, you will find the code like below:

/**
 * Callback on changing email property
 */
emailHasChanged: function () {
    var self = this;

    clearTimeout(this.emailCheckTimeout);

    if (self.validateEmail()) {
        quote.guestEmail = self.email();
        checkoutData.setValidatedEmailValue(self.email());
    }
    this.emailCheckTimeout = setTimeout(function () {
        if (self.validateEmail()) {
            self.checkEmailAvailability();
        } else {
            self.isPasswordVisible(false);
        }
    }, self.checkDelay);

    checkoutData.setInputFieldEmailValue(self.email());
},

You need to change it like below code:

/**
 * Callback on changing email property
 */
emailHasChanged: function () {
    var self = this;

    clearTimeout(this.emailCheckTimeout);

    if (self.validateEmail()) {
        quote.guestEmail = self.email();
        checkoutData.setValidatedEmailValue(self.email());
    }


    // this.emailCheckTimeout = setTimeout(function () {
    //     if (self.validateEmail()) {
    //         self.checkEmailAvailability();
    //     } else {
    //         self.isPasswordVisible(false);
    //     }
    // }, self.checkDelay);
    self.isPasswordVisible(false);

    checkoutData.setInputFieldEmailValue(self.email());
},
Related Topic