Automattic\WooCommerce\Internal\PushNotifications\Notifications

StockNotification::__constructpublicWC 10.9.0

Creates a new StockNotification instance.

Method of the class: StockNotification{}

No Hooks.

Returns

null. Nothing (null).

Usage

$StockNotification = new StockNotification();
$StockNotification->__construct( $resource_id, $event_type, ?int $stock_quantity_at_trigger );
$resource_id(int) (required)
The product ID.
$event_type(string)
One of the EVENT_ constants.
Default: self::EVENT_LOW_STOCK*
?int $stock_quantity_at_trigger
.
Default: null

Changelog

Since 10.9.0 Introduced.

StockNotification::__construct() code WC 10.9.1

public function __construct( int $resource_id, string $event_type = self::EVENT_LOW_STOCK, ?int $stock_quantity_at_trigger = null ) {
	parent::__construct( $resource_id );

	if ( ! in_array( $event_type, self::VALID_EVENT_TYPES, true ) ) {
		// phpcs:ignore WordPress.Security.EscapeOutput.ExceptionNotEscaped
		throw new InvalidArgumentException( sprintf( 'Invalid stock notification event type: %s', $event_type ) );
	}

	$this->event_type                = $event_type;
	$this->stock_quantity_at_trigger = $stock_quantity_at_trigger;
}