Automattic\WooCommerce\Admin\API\Reports\Customers

DataStore::get_guest_id_by_email()public staticWC 1.0

Retrieve a guest ID (when user_id is null) by email.

Method of the class: DataStore{}

No Hooks.

Return

false|Array. Customer array if found, boolean false if not.

Usage

$result = DataStore::get_guest_id_by_email( $email );
$email(string) (required)
Email address.

DataStore::get_guest_id_by_email() code WC 8.7.0

public static function get_guest_id_by_email( $email ) {
	global $wpdb;

	$table_name  = self::get_db_table_name();
	$customer_id = $wpdb->get_var(
		$wpdb->prepare(
			// phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared
			"SELECT customer_id FROM {$table_name} WHERE email = %s AND user_id IS NULL LIMIT 1",
			$email
		)
	);

	return $customer_id ? (int) $customer_id : false;
}