Cart is getting empty while registration in Woocommerce

I am using this plugin( for email verification process and verification is working fine.

Problem: Suppose I added some products in cart after that I am going to register, once you clicked on register button cart gets emptied just because of verification plugin.

you can test the cart behaviour on the below mentioned link

I just went inside the woo-confirmation-email plugin file and found what is creating problem.

New User Registration Function(this function will send the verification email with the link)

   public function new_user_registeration($customer, $user_id) {
    $current_user = get_user_by('id', $user_id);
    $this->user_id = $current_user->ID;
    $this->email_id = $current_user->user_email;
    $scret_code = md5($this->user_id . time());
    update_user_meta($user_id, "wcemailverifiedcode", $scret_code);
    wc_add_notice(__('Please check email inbox form confirmation email', 'woocommerce'), "notice");

    $_SESSION["verify_email"] = array("verify_email_user" => $user_id);
    //setcookie("verify_email", $user_meta[1], time() + 3600);
    return $customer;

Validation Before Login to check whether user is verified or not

`    public function authorized_is_valid_user($redirect, $user) {
        global $wpdb;
        $user_ID = $user->ID;
        $status = get_user_meta((int) $user_ID, "wcemailverified", true);
        if (!is_super_admin()) {
            if ($status != "true") {
                $myaccount_id = get_option('woocommerce_myaccount_page_id');
                $location = get_the_permalink($myaccount_id);
                wc_add_notice(__('Your email address is not verified please confirm your email address', 'woocommerce'), "notice");
                //$_SESSION["verify_email"] = array("verify_email_user" => $user_ID);       //wp_logout resetting the cart 
                // wp_logout();
            } else {
                //  setcookie("emailverification_failed", $user_ID, time() - 3600);
                return $redirect;
        } else {
            echo $redirect;

In above both the functions wp_logout is there, whenever user is registering they are forcing to user logout that’s why cart item is getting erased

But If I am commenting wp_logout function cart is working fine(items are not getting erased) but user can log in without the verification of email, but I want once email is verified then only user can login with the cart items.

Please suggest me how we can keep item’s in cart while registeration with email verification
I am struggling on this problem from one weak please suggest something

Read more here: Cart is getting empty while registration in Woocommerce

Leave a Reply

Your email address will not be published. Required fields are marked *