WordPress at Your Fingertips
function is not described


DataStore::get_customer_id_by_user_id() public WC 1.0

Retrieve a registered customer row id by user_id.

{} It's a method of the class: DataStore{}

No Hooks.


false|Int. Customer ID if found, boolean false if not.


$result = DataStore::get_customer_id_by_user_id( $user_id );
$user_id(string|int) (required)
User ID.

Code of DataStore::get_customer_id_by_user_id() WC 6.1.0

public static function get_customer_id_by_user_id( $user_id ) {
	global $wpdb;

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

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