Automattic\WooCommerce\Internal\StockNotifications

StockNotifications::maybe_init_services │ public │ WC 1.0

Wire up the services, unless the feature is disabled.

Runs on init priority 1: after the textdomain is loaded, and before WC_Install::check_version() (priority 5) fires woocommerce_installed.

Method of the class: StockNotifications{}

No Hooks.

Returns

null. Nothing (null).

Usage

$StockNotifications = new StockNotifications();
$StockNotifications->maybe_init_services(): void;

StockNotifications::maybe_init_services() code WC 11.2.1

public function maybe_init_services(): void {
	if ( ! self::is_enabled() ) {
		return;
	}

	add_filter( 'woocommerce_data_stores', array( $this, 'register_data_stores' ) );

	$container = wc_get_container();
	$container->get( EmailManager::class );
	$container->get( StockSyncController::class );
	$container->get( NotificationsProcessor::class );
	$container->get( PrivacyEraser::class );
	$container->get( DataRetentionController::class );
	$container->get( Telemetry::class );

	$container->get( NotificationManagementService::class );
	$container->get( MyAccountEndpoint::class );

	// The settings filters must attach outside admin too, or the REST settings
	// API (`is_admin()` is false there) never sees the feature's settings.
	$container->get( SettingsController::class );

	if ( is_admin() ) {
		$container->get( AdminManager::class );
	}

	// Frontend only.
	if ( ! is_admin() || wp_doing_ajax() ) {
		$container->get( EmailActionController::class );
		$container->get( ProductPageIntegration::class );
		$container->get( FormHandlerService::class );
	}
}