Automattic\WooCommerce\Internal\StockNotifications\Utilities

EligibilityService::get_target_product_ids │ public │ WC 10.2.0

Get the product IDs that need to be checked for stock notifications.

For simple products, this returns just the product ID. For variable products, it returns both the parent product ID and the IDs of all variations whose stock is managed by the parent product.

This is used in two key scenarios:

  1. Checking if a product has any active notifications
  2. Determining which notifications need to be sent during a stock broadcast

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

Хуков нет.

Возвращает

array<int>. Array of product IDs to check for notifications.

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

$EligibilityService = new EligibilityService();
$EligibilityService->get_target_product_ids( $product ): array;
$product(WC_Product) (обязательный)
The product to check.

Список изменений

С версии 10.2.0 Введена.

Код EligibilityService::get_target_product_ids() WC 11.2.2

public function get_target_product_ids( WC_Product $product ): array {
	$lookup_ids = array( $product->get_id() );
	if ( $product->is_type( ProductType::VARIABLE ) ) {
		$children_ids = $this->stock_management_helper->get_managed_variations( $product );
		$lookup_ids   = array_merge( $lookup_ids, $children_ids );
	}

	return $lookup_ids;
}