WC_Payment_Token_Data_Store::get_users_default_token()publicWC 3.0.0

Returns an stdObject of a token for a user's default token. Should contain the fields token_id, gateway_id, token, user_id, type, is_default.

Method of the class: WC_Payment_Token_Data_Store{}

No Hooks.

Return

Object.

Usage

$WC_Payment_Token_Data_Store = new WC_Payment_Token_Data_Store();
$WC_Payment_Token_Data_Store->get_users_default_token( $user_id );
$user_id(int) (required)
User ID.

Changelog

Since 3.0.0 Introduced.

WC_Payment_Token_Data_Store::get_users_default_token() code WC 9.4.2

public function get_users_default_token( $user_id ) {
	global $wpdb;
	return $wpdb->get_row(
		$wpdb->prepare(
			"SELECT * FROM {$wpdb->prefix}woocommerce_payment_tokens WHERE user_id = %d AND is_default = 1",
			$user_id
		)
	);
}