WC_REST_Products_V2_Controller::get_taxonomy_terms
Get taxonomy terms.
Метод класса: WC_REST_Products_V2_Controller{}
Хуков нет.
Возвращает
Массив.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->get_taxonomy_terms( $product, $taxonomy );
- $product(WC_Product) (обязательный)
- Product instance.
- $taxonomy(строка)
- Taxonomy slug.
По умолчанию:'cat'
Код WC_REST_Products_V2_Controller::get_taxonomy_terms() WC REST Products V2 Controller::get taxonomy terms WC 10.5.2
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;
}