mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
extract logic for disabling both gateways into a helper function
This commit is contained in:
parent
cc1365d5e9
commit
8c6cb68b0c
1 changed files with 17 additions and 10 deletions
|
@ -60,16 +60,7 @@ class DisableGateways {
|
||||||
if ( ! isset( $methods[ PayPalGateway::ID ] ) && ! isset( $methods[ CreditCardGateway::ID ] ) ) {
|
if ( ! isset( $methods[ PayPalGateway::ID ] ) && ! isset( $methods[ CreditCardGateway::ID ] ) ) {
|
||||||
return $methods;
|
return $methods;
|
||||||
}
|
}
|
||||||
if ( ! $this->settings->has( 'enabled' ) || ! $this->settings->get( 'enabled' ) ) {
|
if ( $this->disable_both_gateways() ) {
|
||||||
|
|
||||||
unset( $methods[ PayPalGateway::ID ] );
|
|
||||||
unset( $methods[ CreditCardGateway::ID ] );
|
|
||||||
return $methods;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
! $this->settings->has( 'merchant_email' )
|
|
||||||
|| ! is_email( $this->settings->get( 'merchant_email' ) )
|
|
||||||
) {
|
|
||||||
unset( $methods[ PayPalGateway::ID ] );
|
unset( $methods[ PayPalGateway::ID ] );
|
||||||
unset( $methods[ CreditCardGateway::ID ] );
|
unset( $methods[ CreditCardGateway::ID ] );
|
||||||
return $methods;
|
return $methods;
|
||||||
|
@ -93,6 +84,22 @@ class DisableGateways {
|
||||||
return array( PayPalGateway::ID => $methods[ PayPalGateway::ID ] );
|
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
|
* 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
|
* session, we need to disable the other Gateways, so the customer can smoothly sail through the
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue