From 7e43288f74e1eed1aa5ed67c2c433e8327b6fc42 Mon Sep 17 00:00:00 2001 From: Narek Zakarian Date: Mon, 4 Aug 2025 17:50:56 +0400 Subject: [PATCH] Register the notes in 'Inbox' Woo section --- .../ppcp-wc-gateway/src/WCGatewayModule.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/ppcp-wc-gateway/src/WCGatewayModule.php b/modules/ppcp-wc-gateway/src/WCGatewayModule.php index 08e4b6460..f6d22371f 100644 --- a/modules/ppcp-wc-gateway/src/WCGatewayModule.php +++ b/modules/ppcp-wc-gateway/src/WCGatewayModule.php @@ -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. *