wc_get_product_term_ids( int $product_id, string $taxonomy )

Retrieves product term ids for a taxonomy.


Description Description


Parameters Parameters

$product_id

(Required) Product ID.

$taxonomy

(Required) Taxonomy slug.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/wc-product-functions.php

function wc_get_product_term_ids( $product_id, $taxonomy ) {
	$terms = get_the_terms( $product_id, $taxonomy );
	return ( empty( $terms ) || is_wp_error( $terms ) ) ? array() : wp_list_pluck( $terms, 'term_id' );
}

Top ↑

Changelog Changelog

Changelog
Version Description
3.0.0 Introduced.


Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.