WordPress at Your Fingertips
function is not described

WC_REST_Products_V2_Controller::save_taxonomy_terms() protected WC 1.0

Save taxonomy terms.

{} It's a method of the class: WC_REST_Products_V2_Controller{}

No Hooks.

Return

WC_Product.

Usage

// protected - for code of main (parent) or child class
$result = $this->save_taxonomy_terms( $product, $terms, $taxonomy );
$product(WC_Product) (required)
Product instance.
$terms(array) (required)
Terms data.
$taxonomy(string)
Taxonomy name.
Default: 'cat'

Code of WC_REST_Products_V2_Controller::save_taxonomy_terms() WC 5.9.0

protected function save_taxonomy_terms( $product, $terms, $taxonomy = 'cat' ) {
	$term_ids = wp_list_pluck( $terms, 'id' );

	if ( 'cat' === $taxonomy ) {
		$product->set_category_ids( $term_ids );
	} elseif ( 'tag' === $taxonomy ) {
		$product->set_tag_ids( $term_ids );
	}

	return $product;
}