Merge pull request #765 from woocommerce/pcp-841-card-button-no-paypal

Do not show card button gateway if PayPal gateway disabled
This commit is contained in:
Emili Castells 2022-08-10 09:21:17 +02:00 committed by GitHub
commit 46352ba16e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -291,7 +291,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' );
/**
@ -303,7 +308,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' );
}