Automattic\WooCommerce\Internal\PushNotifications\Notifications
StockNotification::__construct
Creates a new StockNotification instance.
Метод класса: StockNotification{}
Хуков нет.
Возвращает
null. Ничего (null).
Использование
$StockNotification = new StockNotification(); $StockNotification->__construct( $resource_id, $event_type, ?int $stock_quantity_at_trigger );
- $resource_id(int) (обязательный)
- The product ID.
- $event_type(строка)
- One of the EVENT_ constants.
По умолчанию:self::EVENT_LOW_STOCK* - ?int $stock_quantity_at_trigger
- .
По умолчанию:null
Список изменений
| С версии 10.9.0 | Введена. |
Код StockNotification::__construct() StockNotification:: construct WC 11.3.0
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;
}