Automattic\WooCommerce\Internal\StockNotifications\AsyncTasks

NotificationsProcessor::parse_args │ private │ WC 1.0

Parse the product ID from the arguments.

Метод класса: NotificationsProcessor{}

Хуков нет.

Возвращает

int.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->parse_args( $product_id ): int;
$product_id(int) (обязательный)
The product ID.

Код NotificationsProcessor::parse_args() WC 11.2.2

private function parse_args( $product_id ): int {
	if ( empty( $product_id ) || ! is_numeric( $product_id ) ) {
		throw new \Exception( 'Invalid arguments.' );
	}

	$product_id = (int) $product_id;
	if ( $product_id <= 0 ) {
		throw new \Exception( 'Product ID is required.' );
	}

	return $product_id;
}