mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-08-30 05:00:51 +08:00
Remove the notes registration condition from action callback
We will use the `is_enabled` method for dynamic note registration
This commit is contained in:
parent
6d926b9dcc
commit
e8c01c216c
2 changed files with 6 additions and 18 deletions
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue