Add setting to enable local apms feature

This commit is contained in:
Emili Castells Guasch 2024-08-22 15:47:38 +02:00
parent 2699629b90
commit 9a4b6e63c5
3 changed files with 23 additions and 7 deletions

View file

@ -15,6 +15,7 @@ use WooCommerce\PayPalCommerce\Vendor\Dhii\Container\ServiceProvider;
use WooCommerce\PayPalCommerce\Vendor\Dhii\Modular\Module\ModuleInterface;
use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface;
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
/**
* Class LocalAlternativePaymentMethodsModule
@ -35,6 +36,13 @@ class LocalAlternativePaymentMethodsModule implements ModuleInterface {
* {@inheritDoc}
*/
public function run( ContainerInterface $c ): void {
$settings = $c->get( 'wcgateway.settings' );
assert( $settings instanceof Settings );
if ( ! $settings->has( 'allow_local_apm_gateways' ) || $settings->get( 'allow_local_apm_gateways' ) !== true ) {
return;
}
add_filter(
'woocommerce_payment_gateways',
/**