mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Merge pull request #46 from woocommerce/issue-34-disable-dcc-when-gateway-disabled
Disable both gateways when gateway setting 'enabled' is false
This commit is contained in:
commit
92276f9aa9
1 changed files with 17 additions and 4 deletions
|
@ -60,10 +60,7 @@ class DisableGateways {
|
|||
if ( ! isset( $methods[ PayPalGateway::ID ] ) && ! isset( $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;
|
||||
|
@ -87,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue