WooCommerce Code Reference

Search results

WC_Payment_Tokens

Payment tokens class.

Table of Contents

get_tokens() Gets valid tokens from the database based on user defined criteria. \WC_Payment_Token[]
get_customer_tokens() Returns an array of payment token objects associated with the passed customer ID. \WC_Payment_Token[]
get_customer_default_token() Returns a customers default token or NULL if there is no default token. WC_Payment_Token|null
get_order_tokens() Returns an array of payment token objects associated with the passed order ID. \WC_Payment_Token[]
get() Get a token object by ID. null|WC_Payment_Token
delete() Remove a payment token from the database by ID. mixed
set_users_default() Loops through all of a users payment tokens and sets is_default to false for all but a specific token. mixed
get_token_type_by_id() Returns what type (credit card, echeck, etc) of token a token is by ID. string
get_token_classname() Get classname based on token type. string

Methods

get_tokens()

Gets valid tokens from the database based on user defined criteria.

public static get_tokens( $args : array ) : \WC_Payment_Token[]
Parameters
$args : array

Query argyments { Array of query parameters.

@type string $token_id   Token ID.
@type string $user_id    User ID.
@type string $gateway_id Gateway ID.
@type string $type       Token type.

}

Tags
since
Return values
\WC_Payment_Token[]

get_customer_tokens()

Returns an array of payment token objects associated with the passed customer ID.

public static get_customer_tokens( $customer_id : int [, $gateway_id : string = '' ] ) : \WC_Payment_Token[]
Parameters
$customer_id : int

Customer ID.

$gateway_id : string = ''

Optional Gateway ID for getting tokens for a specific gateway.

Tags
since
Return values
\WC_Payment_Token[]

Array of token objects.

get_customer_default_token()

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

public static get_customer_default_token( $customer_id : int ) : WC_Payment_Token|null
Parameters
$customer_id : int

Customer ID.

Tags
since
Return values
WC_Payment_Token|null

get_order_tokens()

Returns an array of payment token objects associated with the passed order ID.

public static get_order_tokens( $order_id : int ) : \WC_Payment_Token[]
Parameters
$order_id : int

Order ID.

Tags
since
Return values
\WC_Payment_Token[]

Array of token objects.

get()

Get a token object by ID.

public static get( $token_id : int [, $token_result : object = null ] ) : null|WC_Payment_Token
Parameters
$token_id : int

Token ID.

$token_result : object = null

Token result.

Tags
since
Return values
null|WC_Payment_Token

Returns a valid payment token or null if no token can be found.

delete()

Remove a payment token from the database by ID.

public static delete( $token_id : int ) : mixed
Parameters
$token_id : int

Token ID.

Tags
since
Return values
mixed

set_users_default()

Loops through all of a users payment tokens and sets is_default to false for all but a specific token.

public static set_users_default( $user_id : int , $token_id : int ) : mixed
Parameters
$user_id : int

User to set a default for.

$token_id : int

The ID of the token that should be default.

Tags
since
Return values
mixed

get_token_type_by_id()

Returns what type (credit card, echeck, etc) of token a token is by ID.

public static get_token_type_by_id( $token_id : int ) : string
Parameters
$token_id : int

Token ID.

Tags
since
Return values
string

Type.

get_token_classname()

Get classname based on token type.

protected static get_token_classname( $type : string ) : string
Parameters
$type : string

Token type.

Tags
since
Return values
string
Back to the top