diff --git a/includes/api/class-wc-api-products.php b/includes/api/class-wc-api-products.php index cb0f5ffbe90..b78bddd9766 100644 --- a/includes/api/class-wc-api-products.php +++ b/includes/api/class-wc-api-products.php @@ -1136,13 +1136,13 @@ class WC_API_Products extends WC_API_Resource { // Product categories if ( isset( $data['categories'] ) && is_array( $data['categories'] ) ) { - $terms = array_map( 'wc_clean', $data['categories'] ); - wp_set_object_terms( $product_id, $terms, 'product_cat' ); + $term_ids = array_unique( array_map( 'intval', $data['categories'] ) ); + wp_set_object_terms( $product_id, $term_ids, 'product_cat' ); } // Product tags if ( isset( $data['tags'] ) && is_array( $data['tags'] ) ) { - $terms = array_map( 'wc_clean', $data['tags'] ); + $term_ids = array_unique( array_map( 'intval', $data['tags'] ) ); wp_set_object_terms( $product_id, $terms, 'product_tag' ); }