diff --git a/modules/ppcp-wc-gateway/src/WCGatewayModule.php b/modules/ppcp-wc-gateway/src/WCGatewayModule.php index d01287f67..ac052b54c 100644 --- a/modules/ppcp-wc-gateway/src/WCGatewayModule.php +++ b/modules/ppcp-wc-gateway/src/WCGatewayModule.php @@ -292,7 +292,12 @@ class WCGatewayModule implements ModuleInterface { add_filter( 'woocommerce_payment_gateways', static function ( $methods ) use ( $container ): array { - $methods[] = $container->get( 'wcgateway.paypal-gateway' ); + $paypal_gateway = $container->get( 'wcgateway.paypal-gateway' ); + assert( $paypal_gateway instanceof \WC_Payment_Gateway ); + + $paypal_gateway_enabled = wc_string_to_bool( $paypal_gateway->get_option( 'enabled' ) ); + + $methods[] = $paypal_gateway; $dcc_applies = $container->get( 'api.helpers.dccapplies' ); /** @@ -304,7 +309,7 @@ class WCGatewayModule implements ModuleInterface { $methods[] = $container->get( 'wcgateway.credit-card-gateway' ); } - if ( $container->get( 'wcgateway.settings.allow_card_button_gateway' ) ) { + if ( $paypal_gateway_enabled && $container->get( 'wcgateway.settings.allow_card_button_gateway' ) ) { $methods[] = $container->get( 'wcgateway.card-button-gateway' ); }