Do not show card button gateway if paypal gateway disabled

This commit is contained in:
Alex P 2022-08-03 09:37:40 +03:00
parent f256134148
commit 40365c5afb

View file

@ -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' );
}