From e8c01c216c25dcc2a88ee6608be92743f6588d29 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Fri, 15 Aug 2025 20:26:16 +0400 Subject: [PATCH] Remove the notes registration condition from action callback We will use the `is_enabled` method for dynamic note registration --- .../WcInboxNotes/InboxNoteFactory.php | 3 ++- .../ppcp-wc-gateway/src/WCGatewayModule.php | 21 ++++--------------- 2 files changed, 6 insertions(+), 18 deletions(-) diff --git a/modules/ppcp-wc-gateway/src/Settings/WcInboxNotes/InboxNoteFactory.php b/modules/ppcp-wc-gateway/src/Settings/WcInboxNotes/InboxNoteFactory.php index cebe19724..7b6d83d2e 100644 --- a/modules/ppcp-wc-gateway/src/Settings/WcInboxNotes/InboxNoteFactory.php +++ b/modules/ppcp-wc-gateway/src/Settings/WcInboxNotes/InboxNoteFactory.php @@ -18,8 +18,9 @@ class InboxNoteFactory { string $type, string $name, string $status, + bool $is_enabled, InboxNoteActionInterface $action ): InboxNoteInterface { - return new InboxNote( $title, $content, $type, $name, $status, $action ); + return new InboxNote( $title, $content, $type, $name, $status, $is_enabled, $action ); } } diff --git a/modules/ppcp-wc-gateway/src/WCGatewayModule.php b/modules/ppcp-wc-gateway/src/WCGatewayModule.php index c39bedbbf..94722ad7e 100644 --- a/modules/ppcp-wc-gateway/src/WCGatewayModule.php +++ b/modules/ppcp-wc-gateway/src/WCGatewayModule.php @@ -966,26 +966,13 @@ class WCGatewayModule implements ServiceModule, ExtendingModule, ExecutableModul add_action( 'admin_init', static function () use ( $container ): void { - $settings = $container->get( 'wcgateway.settings' ); - assert( $settings instanceof Settings ); - - $is_working_capital_feature_flag_enabled = apply_filters( - // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores -- feature flags use this convention - 'woocommerce.feature-flags.woocommerce_paypal_payments.working_capital_enabled', - getenv( 'PCP_WORKING_CAPITAL_ENABLED' ) === '1' - ); - - $is_working_capital_eligible = $container->get( 'api.shop.country' ) === 'US' && $settings->has( 'stay_updated' ) && $settings->get( 'stay_updated' ); - - if ( ! $is_working_capital_feature_flag_enabled || ! $is_working_capital_eligible ) { - return; - } - $logger = $container->get( 'woocommerce.logger.woocommerce' ); assert( $logger instanceof LoggerInterface ); + + $inbox_note_registrar = $container->get( 'wcgateway.settings.inbox-note-registrar' ); + assert( $inbox_note_registrar instanceof InboxNoteRegistrar ); + try { - $inbox_note_registrar = $container->get( 'wcgateway.settings.inbox-note-registrar' ); - assert( $inbox_note_registrar instanceof InboxNoteRegistrar ); $inbox_note_registrar->register(); } catch ( Exception $exception ) { $logger->error( 'Failed to add note to the WooCommerce inbox section. ' . $exception->getMessage() );