From c60aa546dfca2d2976b06243ceb65e1f6f0a4e9e Mon Sep 17 00:00:00 2001 From: Himad M Date: Tue, 12 Nov 2024 19:06:23 -0400 Subject: [PATCH] Add local APM gateways only if PayPal gateway is enabled --- .../src/LocalAlternativePaymentMethodsModule.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php b/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php index 6db9de464..9c47d908c 100644 --- a/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php +++ b/modules/ppcp-local-alternative-payment-methods/src/LocalAlternativePaymentMethodsModule.php @@ -46,7 +46,7 @@ public function run( ContainerInterface $c ): bool { $settings = $c->get( 'wcgateway.settings' ); assert( $settings instanceof Settings ); - if ( ! $settings->has( 'allow_local_apm_gateways' ) || $settings->get( 'allow_local_apm_gateways' ) !== true ) { + if ( ! self::should_add_local_apm_gateways( $settings ) ) { return true; } @@ -216,4 +216,17 @@ private function is_local_apm( string $selected_payment_method, array $payment_m return false; } + + /** + * Check if the local APMs should be added to the available payment gateways. + * + * @param Settings $settings PayPal gateway settings. + * @return bool + */ + private function should_add_local_apm_gateways( Settings $settings ): bool { + return $settings->has( 'enabled' ) + && $settings->get( 'enabled' ) === true + && $settings->has( 'allow_local_apm_gateways' ) + && $settings->get( 'allow_local_apm_gateways' ) === true; + } }