WC_REST_Products_V2_Controller::get_taxonomy_terms()
Get taxonomy terms.
Method of the class: WC_REST_Products_V2_Controller{}
No Hooks.
Return
Array
.
Usage
// protected - for code of main (parent) or child class $result = $this->get_taxonomy_terms( $product, $taxonomy );
- $product(WC_Product) (required)
- Product instance.
- $taxonomy(string)
- Taxonomy slug.
Default: 'cat'
WC_REST_Products_V2_Controller::get_taxonomy_terms() WC REST Products V2 Controller::get taxonomy terms code WC 9.3.1
protected function get_taxonomy_terms( $product, $taxonomy = 'cat' ) { $terms = array(); foreach ( wc_get_object_terms( $product->get_id(), 'product_' . $taxonomy ) as $term ) { $terms[] = array( 'id' => $term->term_id, 'name' => $term->name, 'slug' => $term->slug, ); } return $terms; }