/**
* Save taxonomy terms.
*
* @param WC_Product $product Product instance.
* @param array $terms Terms data.
* @param string $taxonomy Taxonomy name.
* @return WC_Product
*/
protected function save_taxonomy_terms($product, $terms, $taxonomy = 'cat')
{
$term_ids = wp_list_pluck($terms, 'id');
$term_ids = array_unique(array_map('intval', $term_ids));
if ('cat' === $taxonomy) {
$product->set_category_ids($term_ids);
} elseif ('tag' === $taxonomy) {
$product->set_tag_ids($term_ids);
}
return $product;
}