WC_REST_Products_V1_Controller::get_taxonomy_terms() protected WC 1.0
Get taxonomy terms.
{} It's a method of the class: WC_REST_Products_V1_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.
Code of WC_REST_Products_V1_Controller::get_taxonomy_terms() WC REST Products V1 Controller::get taxonomy terms WC 5.0.0
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;
}