WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Schemas

ProductSchema::get_term_list() protected WC 1.0

Returns a list of terms assigned to the product.

{} It's a method of the class: ProductSchema{}

No Hooks.

Return

Array. Array of terms (id, name, slug).

Usage

// protected - for code of main (parent) or child class
$result = $this->get_term_list( $product, $taxonomy );
$product(WC_Product) (required)
Product object.
$taxonomy(string)
Taxonomy name.
Default: ''

Code of ProductSchema::get_term_list() WC 5.6.0

protected function get_term_list( \WC_Product $product, $taxonomy = '' ) {
	if ( ! $taxonomy ) {
		return [];
	}

	$terms = get_the_terms( $product->get_id(), $taxonomy );

	if ( ! $terms || is_wp_error( $terms ) ) {
		return [];
	}

	$return           = [];
	$default_category = (int) get_option( 'default_product_cat', 0 );

	foreach ( $terms as $term ) {
		$link = get_term_link( $term, $taxonomy );

		if ( is_wp_error( $link ) ) {
			continue;
		}

		if ( $term->term_id === $default_category ) {
			continue;
		}

		$return[] = (object) [
			'id'   => $term->term_id,
			'name' => $term->name,
			'slug' => $term->slug,
			'link' => $link,
		];
	}

	return $return;
}