diff --git a/modules/ppcp-wc-gateway/src/Checkout/class-disablegateways.php b/modules/ppcp-wc-gateway/src/Checkout/class-disablegateways.php index d5f291a37..46e4eeb89 100644 --- a/modules/ppcp-wc-gateway/src/Checkout/class-disablegateways.php +++ b/modules/ppcp-wc-gateway/src/Checkout/class-disablegateways.php @@ -60,16 +60,7 @@ class DisableGateways { if ( ! isset( $methods[ PayPalGateway::ID ] ) && ! isset( $methods[ CreditCardGateway::ID ] ) ) { return $methods; } - if ( ! $this->settings->has( 'enabled' ) || ! $this->settings->get( 'enabled' ) ) { - - unset( $methods[ PayPalGateway::ID ] ); - unset( $methods[ CreditCardGateway::ID ] ); - return $methods; - } - if ( - ! $this->settings->has( 'merchant_email' ) - || ! is_email( $this->settings->get( 'merchant_email' ) ) - ) { + if ( $this->disable_both_gateways() ) { unset( $methods[ PayPalGateway::ID ] ); unset( $methods[ CreditCardGateway::ID ] ); return $methods; @@ -93,6 +84,22 @@ class DisableGateways { return array( PayPalGateway::ID => $methods[ PayPalGateway::ID ] ); } + /** + * Whether both gateways should be disabled or not. + * + * @return bool + */ + private function disable_both_gateways() : bool { + if ( ! $this->settings->has( 'enabled' ) || ! $this->settings->get( 'enabled' ) ) { + return true; + } + if ( ! $this->settings->has( 'merchant_email' ) || ! is_email( $this->settings->get( 'merchant_email' ) ) ) { + return true; + } + + return false; + } + /** * Whether the Gateways need to be disabled. When we come to the checkout with a running PayPal * session, we need to disable the other Gateways, so the customer can smoothly sail through the