wc_get_featured_product_ids()WC 2.1

Function that returns an array containing the IDs of the featured products.

Хуков нет.

Возвращает

Массив.

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

wc_get_featured_product_ids();

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

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

Код wc_get_featured_product_ids() WC 9.4.2

function wc_get_featured_product_ids() {
	// Load from cache.
	$featured_product_ids = get_transient( 'wc_featured_products' );

	// Valid cache found.
	if ( false !== $featured_product_ids ) {
		return $featured_product_ids;
	}

	$data_store           = WC_Data_Store::load( 'product' );
	$featured             = $data_store->get_featured_product_ids();
	$product_ids          = array_keys( $featured );
	$parent_ids           = array_values( array_filter( $featured ) );
	$featured_product_ids = array_unique( array_merge( $product_ids, $parent_ids ) );

	set_transient( 'wc_featured_products', $featured_product_ids, DAY_IN_SECONDS * 30 );

	return $featured_product_ids;
}