From 01e5f5403954669bce5817c852698dea20cfd4c0 Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Mon, 14 Oct 2024 12:54:48 +0200 Subject: [PATCH 1/3] Ensure setting exist before getting it --- modules/ppcp-blocks/src/BlocksModule.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/ppcp-blocks/src/BlocksModule.php b/modules/ppcp-blocks/src/BlocksModule.php index 1b03d078f..3d422ef3b 100644 --- a/modules/ppcp-blocks/src/BlocksModule.php +++ b/modules/ppcp-blocks/src/BlocksModule.php @@ -17,6 +17,7 @@ use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ModuleClassNameIdTrait; use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ServiceModule; use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface; +use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings; /** * Class BlocksModule @@ -70,9 +71,10 @@ function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void { $payment_method_registry->register( $c->get( 'blocks.method' ) ); $settings = $c->get( 'wcgateway.settings' ); + assert( $settings instanceof Settings ); // Include ACDC in the Block Checkout only in case Axo doesn't exist or is not available or the user is logged in. - if ( ! $settings->get( 'axo_enabled' ) || is_user_logged_in() ) { + if ( $settings->has( 'axo_enabled' ) && ! $settings->get( 'axo_enabled' ) || is_user_logged_in() ) { $payment_method_registry->register( $c->get( 'blocks.advanced-card-method' ) ); } } From b2b3a35774ac5e4c8602a6cb2414e0d199ac7a77 Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Mon, 14 Oct 2024 14:01:55 +0200 Subject: [PATCH 2/3] Wrap multiple condition in parenthesis --- modules/ppcp-blocks/src/BlocksModule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ppcp-blocks/src/BlocksModule.php b/modules/ppcp-blocks/src/BlocksModule.php index 3d422ef3b..6208f82ee 100644 --- a/modules/ppcp-blocks/src/BlocksModule.php +++ b/modules/ppcp-blocks/src/BlocksModule.php @@ -74,7 +74,7 @@ function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void { assert( $settings instanceof Settings ); // Include ACDC in the Block Checkout only in case Axo doesn't exist or is not available or the user is logged in. - if ( $settings->has( 'axo_enabled' ) && ! $settings->get( 'axo_enabled' ) || is_user_logged_in() ) { + if ( ($settings->has( 'axo_enabled' ) && ! $settings->get( 'axo_enabled' )) || is_user_logged_in() ) { $payment_method_registry->register( $c->get( 'blocks.advanced-card-method' ) ); } } From a16ab58dd8d8cea1e4ac426cb528437040c4f6fd Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Mon, 14 Oct 2024 14:02:35 +0200 Subject: [PATCH 3/3] Wrap multiple condition in parenthesis --- modules/ppcp-blocks/src/BlocksModule.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ppcp-blocks/src/BlocksModule.php b/modules/ppcp-blocks/src/BlocksModule.php index 6208f82ee..dc30664f4 100644 --- a/modules/ppcp-blocks/src/BlocksModule.php +++ b/modules/ppcp-blocks/src/BlocksModule.php @@ -74,7 +74,7 @@ function( PaymentMethodRegistry $payment_method_registry ) use ( $c ): void { assert( $settings instanceof Settings ); // Include ACDC in the Block Checkout only in case Axo doesn't exist or is not available or the user is logged in. - if ( ($settings->has( 'axo_enabled' ) && ! $settings->get( 'axo_enabled' )) || is_user_logged_in() ) { + if ( ( $settings->has( 'axo_enabled' ) && ! $settings->get( 'axo_enabled' ) ) || is_user_logged_in() ) { $payment_method_registry->register( $c->get( 'blocks.advanced-card-method' ) ); } }