From e6b74ad62969a5c01e21958a0a73dcf3d15dc17d Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Mon, 16 May 2016 15:32:54 +0100 Subject: [PATCH] Allow filtering even when DB stored tokens are empty --- includes/class-wc-payment-tokens.php | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/includes/class-wc-payment-tokens.php b/includes/class-wc-payment-tokens.php index 886ff01a81e..7e0f4f08d47 100644 --- a/includes/class-wc-payment-tokens.php +++ b/includes/class-wc-payment-tokens.php @@ -35,16 +35,15 @@ class WC_Payment_Tokens { $customer_id ) ); - if ( empty( $token_results ) ) { - return array(); - } - $tokens = array(); - foreach ( $token_results as $token_result ) { - if ( empty( $gateway_id ) || $gateway_id === $token_result->gateway_id ) { - $_token = self::get( $token_result->token_id, $token_result ); - if ( ! empty( $_token ) ) { - $tokens[ $token_result->token_id ] = $_token; + + if ( ! empty( $token_results ) ) { + foreach ( $token_results as $token_result ) { + if ( empty( $gateway_id ) || $gateway_id === $token_result->gateway_id ) { + $_token = self::get( $token_result->token_id, $token_result ); + if ( ! empty( $_token ) ) { + $tokens[ $token_result->token_id ] = $_token; + } } } }