From 72efcbb71dc129a0384e9a2c36e9086e7cc60f10 Mon Sep 17 00:00:00 2001 From: dinamiko Date: Tue, 29 Mar 2022 11:37:22 +0200 Subject: [PATCH] Only init pui if gateway is enabled --- modules/ppcp-wc-gateway/src/WCGatewayModule.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/WCGatewayModule.php b/modules/ppcp-wc-gateway/src/WCGatewayModule.php index 30fb8061d..697d90654 100644 --- a/modules/ppcp-wc-gateway/src/WCGatewayModule.php +++ b/modules/ppcp-wc-gateway/src/WCGatewayModule.php @@ -173,7 +173,7 @@ class WCGatewayModule implements ModuleInterface { assert( $settings instanceof Settings ); try { - if ( $settings->get( '3d_secure_contingency' ) === '3D_SECURE' ) { + if ( $settings->has( '3d_secure_contingency' ) && $settings->get( '3d_secure_contingency' ) === '3D_SECURE' ) { $settings->set( '3d_secure_contingency', 'SCA_ALWAYS' ); $settings->persist(); } @@ -186,7 +186,10 @@ class WCGatewayModule implements ModuleInterface { add_action( 'init', function () use ( $c ) { - if ( 'DE' === $c->get( 'api.shop.country' ) ) { + $gateway_settings = get_option( 'woocommerce_ppcp-pay-upon-invoice-gateway_settings' ); + $gateway_enabled = $gateway_settings['enabled'] ?? ''; + + if ( 'yes' === $gateway_enabled && 'DE' === $c->get( 'api.shop.country' ) ) { ( $c->get( 'wcgateway.pay-upon-invoice' ) )->init(); } }