Skip to content

Commit

Permalink
fix(ras): remove modal checkout logic (#2781)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelpeixe authored Dec 20, 2023
1 parent 70f7dcb commit 6aad17d
Showing 1 changed file with 0 additions and 37 deletions.
37 changes: 0 additions & 37 deletions includes/reader-activation/class-reader-activation.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public static function init() {
\add_filter( 'retrieve_password_notification_email', [ __CLASS__, 'password_reset_configuration' ], 10, 4 );
\add_action( 'lostpassword_post', [ __CLASS__, 'set_password_reset_mail_content_type' ] );
\add_filter( 'lostpassword_errors', [ __CLASS__, 'rate_limit_lost_password' ], 10, 2 );
\add_filter( 'woocommerce_checkout_customer_id', [ __CLASS__, 'associate_existing_woo_users_with_transactions_on_checkout' ] );
\add_filter( 'woocommerce_checkout_posted_data', [ __CLASS__, 'dont_force_registration_for_existing_woo_users' ], 11 );
}
}

Expand Down Expand Up @@ -1838,40 +1836,5 @@ public static function rate_limit_lost_password( $errors, $user_data ) {
}
return $errors;
}

/**
* If a reader tries to make a recurring donation with an email address that
* has been previously registered, automatically associate the transaction with the user.
*
* @param int $customer_id Current customer ID.
* @return int Modified $customer_id
*/
public static function associate_existing_woo_users_with_transactions_on_checkout( $customer_id ) {
$billing_email = filter_input( INPUT_POST, 'billing_email', FILTER_SANITIZE_EMAIL );
if ( $billing_email ) {
$customer = \get_user_by( 'email', $billing_email );
if ( $customer ) {
$customer_id = $customer->ID;
}
}
return $customer_id;
}

/**
* Don't force account registration/login on Woo purchases for existing users.
*
* @param array $data Array of Woo checkout data.
* @return array Modified $data.
*/
public static function dont_force_registration_for_existing_woo_users( $data ) {
$email = $data['billing_email'];
$customer = \get_user_by( 'email', $email );
if ( $customer ) {
$data['createaccount'] = 0;
\add_filter( 'woocommerce_checkout_registration_required', '__return_false', 9999 );
}

return $data;
}
}
Reader_Activation::init();

0 comments on commit 6aad17d

Please sign in to comment.