WC_Payment_Tokens::get_customer_default_token()public staticWC 2.6.0

Returns a customers default token or NULL if there is no default token.

Method of the class: WC_Payment_Tokens{}

No Hooks.

Return

WC_Payment_Token|null.

Usage

$result = WC_Payment_Tokens::get_customer_default_token( $customer_id );
$customer_id(int) (required)
Customer ID.

Changelog

Since 2.6.0 Introduced.

WC_Payment_Tokens::get_customer_default_token() code WC 8.7.0

public static function get_customer_default_token( $customer_id ) {
	if ( $customer_id < 1 ) {
		return null;
	}

	$data_store = WC_Data_Store::load( 'payment-token' );
	$token      = $data_store->get_users_default_token( $customer_id );

	if ( $token ) {
		return self::get( $token->token_id, $token );
	} else {
		return null;
	}
}