private function duplicate_post_taxonomies($id, $new_id, $post_type) { $exclude = array_filter(apply_filters('woocommerce_duplicate_product_exclude_taxonomies', array())); $taxonomies = array_diff(get_object_taxonomies($post_type), $exclude); foreach ($taxonomies as $taxonomy) { $post_terms = wc_get_object_terms($id, $taxonomy); $post_terms_count = sizeof($post_terms); for ($i = 0; $i < $post_terms_count; $i++) { wp_set_object_terms($new_id, $post_terms[$i]->slug, $taxonomy, true); } } }