From 98ccecab194d17def353002b134fd8fa9a93487c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=BCsken?= Date: Mon, 13 Jan 2025 16:05:34 +0100 Subject: [PATCH 1/2] Remove tokens from Block Checkout page --- modules/ppcp-vaulting/src/VaultingModule.php | 28 ++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/modules/ppcp-vaulting/src/VaultingModule.php b/modules/ppcp-vaulting/src/VaultingModule.php index 37074b41e..673543dc7 100644 --- a/modules/ppcp-vaulting/src/VaultingModule.php +++ b/modules/ppcp-vaulting/src/VaultingModule.php @@ -136,6 +136,34 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule 3 ); + // Remove tokens from Block checkout page. + add_filter( + 'woocommerce_saved_payment_methods_list', + function( $methods ) { + + // Found no other way to manipulate the data only on that place + $exception = new \Exception(); + $trace = $exception->getTrace(); + $found = false; + foreach ( $trace as $value ) { + if ( $value['function'] === 'hydrate_customer_payment_methods' && $value['class'] === \Automattic\WooCommerce\Blocks\BlockTypes\Checkout::class ) { + $found = true; + break; + } + } + + if ( ! $found ) { + return $methods; + } + + unset( $methods['paypal'] ); + unset( $methods['venmo'] ); + unset( $methods['applepay'] ); + + return $methods; + } + ); + add_filter( 'woocommerce_payment_methods_list_item', /** From e2ce69fd0b28498ec192bb6a12a5b588c9e6211b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20H=C3=BCsken?= Date: Tue, 14 Jan 2025 08:43:34 +0100 Subject: [PATCH 2/2] use existing code to remove tokens --- modules/ppcp-vaulting/src/VaultingModule.php | 30 +------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/modules/ppcp-vaulting/src/VaultingModule.php b/modules/ppcp-vaulting/src/VaultingModule.php index 673543dc7..c6d52c12d 100644 --- a/modules/ppcp-vaulting/src/VaultingModule.php +++ b/modules/ppcp-vaulting/src/VaultingModule.php @@ -124,7 +124,7 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule && ! $is_post // Don't check on POST so we have all payment methods on form submissions. ) { foreach ( $tokens as $index => $token ) { - if ( $token instanceof PaymentTokenApplePay ) { + if ( $token instanceof PaymentTokenApplePay || $token instanceof PaymentTokenPayPal || $token instanceof PaymentTokenVenmo ) { unset( $tokens[ $index ] ); } } @@ -136,34 +136,6 @@ class VaultingModule implements ServiceModule, ExtendingModule, ExecutableModule 3 ); - // Remove tokens from Block checkout page. - add_filter( - 'woocommerce_saved_payment_methods_list', - function( $methods ) { - - // Found no other way to manipulate the data only on that place - $exception = new \Exception(); - $trace = $exception->getTrace(); - $found = false; - foreach ( $trace as $value ) { - if ( $value['function'] === 'hydrate_customer_payment_methods' && $value['class'] === \Automattic\WooCommerce\Blocks\BlockTypes\Checkout::class ) { - $found = true; - break; - } - } - - if ( ! $found ) { - return $methods; - } - - unset( $methods['paypal'] ); - unset( $methods['venmo'] ); - unset( $methods['applepay'] ); - - return $methods; - } - ); - add_filter( 'woocommerce_payment_methods_list_item', /**