Automattic\WooCommerce\Internal\PushNotifications\Notifications

StockNotification::should_send_to_userpublicWC 10.9.0

{@inheritDoc}

Extends the base enabled-toggle check with per-event sub-flag filtering.

Method of the class: StockNotification{}

No Hooks.

Returns

true|false.

Usage

$StockNotification = new StockNotification();
$StockNotification->should_send_to_user( $pref_value ): bool;
$pref_value(mixed) (required)
The user's stored preference value, or null.

Changelog

Since 10.9.0 Introduced.

StockNotification::should_send_to_user() code WC 10.9.1

public function should_send_to_user( $pref_value ): bool {
	if ( ! parent::should_send_to_user( $pref_value ) ) {
		return false;
	}

	if ( ! is_array( $pref_value ) || ! array_key_exists( $this->event_type, $pref_value ) ) {
		return true;
	}

	return (bool) $pref_value[ $this->event_type ];
}