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; + } }