Automattic\WooCommerce\Internal\PushNotifications\Notifications

StockNotification::get_suppression_reason │ public │ WC 11.3.0

{@inheritDoc}

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

Method of the class: StockNotification{}

No Hooks.

Returns

string|null. One of the SuppressionReason constants, or null to send.

Usage

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

Changelog

Since 11.3.0 Introduced.

StockNotification::get_suppression_reason() code WC 11.3.0

public function get_suppression_reason( $pref_value ): ?string {
	$reason = parent::get_suppression_reason( $pref_value );

	if ( null !== $reason ) {
		return $reason;
	}

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

	return $pref_value[ $this->event_type ] ? null : SuppressionReason::STOCK_ALERT_OFF;
}