Register the notes in 'Inbox' Woo section

This commit is contained in:
Narek Zakarian 2025-08-04 17:50:56 +04:00
parent 0108779972
commit 7e43288f74
No known key found for this signature in database
GPG key ID: 07AFD7E7A9C164A7

View file

@ -62,6 +62,7 @@ use WooCommerce\PayPalCommerce\WcGateway\Settings\SectionsRenderer;
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsListener;
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsRenderer;
use WooCommerce\PayPalCommerce\WcGateway\Settings\WcInboxNotes\InboxNoteRegistrar;
use WooCommerce\PayPalCommerce\WcGateway\Settings\WcTasks\Registrar\TaskRegistrarInterface;
/**
@ -95,6 +96,7 @@ class WCGatewayModule implements ServiceModule, ExtendingModule, ExecutableModul
$this->register_columns( $c );
$this->register_checkout_paypal_address_preset( $c );
$this->register_wc_tasks( $c );
$this->register_woo_inbox_notes( $c );
$this->register_void_button( $c );
if ( ! $c->get( 'wcgateway.settings.admin-settings-enabled' ) ) {
@ -957,6 +959,26 @@ class WCGatewayModule implements ServiceModule, ExtendingModule, ExecutableModul
);
}
/**
* Registers inbox notes in the WooCommerce Admin inbox section.
*/
protected function register_woo_inbox_notes( ContainerInterface $container ): void {
add_action(
'admin_init',
static function () use ( $container ): void {
$logger = $container->get( 'woocommerce.logger.woocommerce' );
assert( $logger instanceof LoggerInterface );
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() );
}
},
);
}
/**
* Registers the assets and ajax endpoint for the void button.
*