Add local APM gateways only if PayPal gateway is enabled

This commit is contained in:
Himad M 2024-11-12 19:06:23 -04:00
parent 594c9eb63b
commit 0f6ca42200
No known key found for this signature in database
GPG key ID: 5FC769E9888A7B98

View file

@ -47,7 +47,7 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
$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;
}
@ -210,4 +210,17 @@ class LocalAlternativePaymentMethodsModule implements ServiceModule, ExtendingMo
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;
}
}