WC_Payment_Tokens::get_customer_tokens
Returns an array of payment token objects associated with the passed customer ID.
Method of the class: WC_Payment_Tokens{}
Hooks from the method
Returns
WC_Payment_Token[]. Array of token objects.
Usage
$result = WC_Payment_Tokens::get_customer_tokens( $customer_id, $gateway_id );
- $customer_id(int) (required)
- Customer ID.
- $gateway_id(string)
- Optional Gateway ID for getting tokens for a specific gateway.
Default:''
Changelog
| Since 2.6.0 | Introduced. |
WC_Payment_Tokens::get_customer_tokens() WC Payment Tokens::get customer tokens code WC 10.6.2
public static function get_customer_tokens( $customer_id, $gateway_id = '' ) {
if ( $customer_id < 1 ) {
return array();
}
$tokens = self::get_tokens(
array(
'user_id' => $customer_id,
'gateway_id' => $gateway_id,
/**
* Controls the maximum number of Payment Methods that will be listed via the My Account page.
*
* @since 7.2.0
*
* @param int $limit Defaults to the value of the `posts_per_page` option.
*/
'limit' => apply_filters( 'woocommerce_get_customer_payment_tokens_limit', get_option( 'posts_per_page' ) ),
)
);
return apply_filters( 'woocommerce_get_customer_payment_tokens', $tokens, $customer_id, $gateway_id );
}