WC_Payment_Tokens::get_tokens( array $args )
Gets valid tokens from the database based on user defined criteria.
Description Description
Parameters Parameters
- $args
-
(Required) Query arguments { 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. }
Return Return
(WC_Payment_Token[])
Source Source
File: includes/class-wc-payment-tokens.php
public static function get_tokens( $args ) { $args = wp_parse_args( $args, array( 'token_id' => '', 'user_id' => '', 'gateway_id' => '', 'type' => '', ) ); $data_store = WC_Data_Store::load( 'payment-token' ); $token_results = $data_store->get_tokens( $args ); $tokens = array(); if ( ! empty( $token_results ) ) { foreach ( $token_results as $token_result ) { $_token = self::get( $token_result->token_id, $token_result ); if ( ! empty( $_token ) ) { $tokens[ $token_result->token_id ] = $_token; } } } return $tokens; }
Changelog Changelog
Version | Description |
---|---|
2.6.0 | Introduced. |