• Resolved himanshujain1987

    (@himanshujain1987)


    Hello,

    I let users create an account on checkout,
    The problem is, if they come back to make a second purchase with that same email address they will not be able to proceed.
    They will be faced by the following error:
    An account is already registered with your email address. Please log in.

    Woocommerce basically tries to create an account and then of course throws this error because the email exists.

    To remove this I used the following code. I works well for normal product. But it doesn’t work for woo subscriptions and woo memberships. The moment I activate any of these 2 plugins the following code stops working

    
    // Create user if one does not exist
    function tn_checkout_create_acct( $post_data ) {
    	$user = get_user_by( 'email', $post_data['billing_email'] );
    	if ( $user ) {
    		$post_data['createaccount'] = 0;
    	} else {
    		$post_data['createaccount'] = 1;
    	}
    	return $post_data;
    }
    
    add_filter('woocommerce_checkout_posted_data', 'tn_checkout_create_acct');
    
    // Attach order to existing account if user not logged in
    function tn_checkout_set_customer_id( $current_user_id ) { 
    	if ( !$current_user_id ) {
    		$user = get_user_by('email', $_POST['billing_email']);
    		if ( $user ) {
    			$current_user_id = $user->ID;
    		}
    	}
    	return $current_user_id;
    } 
    add_filter('woocommerce_checkout_customer_id', 'tn_checkout_set_customer_id')
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Raif D. a11n

    (@rdeari)

    Hi @himanshujain1987 !

    This is usually handled by WooCommerce automatically without needing to add the code snippet.

    Can you please share a screenshot from WooCommerce > Settings > accounts & Privacy

    Note: Please ensure that both the Guest checkout and Account creation can be seen.

    Also, please share with us any other detail that would help us try and replicate the issue on our end ??

    Thank you!

    We haven’t heard back from you, so I’m marking this thread as resolved – we’ll be here if and/or when you are ready to continue.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘An account is already registered with your email address. Please log in.’ is closed to new replies.