wc_get_product_term_ids

Retrieves product term ids for a taxonomy.

Description

(array) wc_get_product_term_ids( (int) $product_id, (string) $taxonomy ); 

Returns (array)

Parameters (2)

0. $product_id (int)
The product id.
1. $taxonomy (string)
Taxonomy slug.

Usage

  1. if ( !function_exists( 'wc_get_product_term_ids' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-product-functions.php'; 
  3.  
  4. // The product id. 
  5. $product_id = -1; 
  6.  
  7. // Taxonomy slug. 
  8. $taxonomy = ''; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_get_product_term_ids($product_id, $taxonomy); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-product-functions.php  
  1. function wc_get_product_term_ids( $product_id, $taxonomy ) { 
  2. $terms = get_the_terms( $product_id, $taxonomy ); 
  3. return ! empty( $terms ) ? wp_list_pluck( $terms, 'term_id' ) : array();