Automattic\WooCommerce\Blocks\BlockTypes

FeaturedCategory::resolve_category_id │ private static │ WC 1.0

Resolve the selected or inherited product category ID.

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

Хуков нет.

Возвращает

int.

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

$result = FeaturedCategory::resolve_category_id( $attributes, $context ): int;
$attributes(массив) (обязательный)
Block attributes.
$context(массив) (обязательный)
Block context.

Код FeaturedCategory::resolve_category_id() WC 11.3.0

private static function resolve_category_id( array $attributes, array $context ): int {
	if ( ! empty( $attributes['categoryId'] ) ) {
		return absint( $attributes['categoryId'] );
	}

	$taxonomy = $context['termTaxonomy'] ?? $context['taxonomy'] ?? '';
	return 'product_cat' === $taxonomy ? absint( $context['termId'] ?? 0 ) : 0;
}