Check for WP_Error while getting/creating tags and shipping classes

This commit is contained in:
Claudio Sanches 2017-05-24 06:47:12 -03:00
parent 83f08ec18d
commit 86036d7040
1 changed files with 2 additions and 2 deletions

View File

@ -234,7 +234,7 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
foreach ( $names as $name ) {
$term = get_term_by( 'name', $name, 'product_tag' );
if ( ! $term ) {
if ( ! $term || is_wp_error( $term ) ) {
$term = (object) wp_insert_term( $name, 'product_tag' );
}
@ -253,7 +253,7 @@ class WC_Product_CSV_Importer extends WC_Product_Importer {
protected function parse_shipping_class_field( $field ) {
$term = get_term_by( 'name', $field, 'product_shipping_class' );
if ( ! $term ) {
if ( ! $term || is_wp_error( $term ) ) {
$term = (object) wp_insert_term( $name, 'product_shipping_class' );
}