Remove the notes registration condition from action callback

We will use the `is_enabled` method for dynamic note registration
This commit is contained in:
Narek Zakarian 2025-08-15 20:26:16 +04:00
parent 6d926b9dcc
commit e8c01c216c
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7
2 changed files with 6 additions and 18 deletions

View file

@ -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 );
}
}

View file

@ -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() );