Merge pull request #27441 from Rahmon/patch-1

Ensure that the return of get_the_terms is not a WP error
This commit is contained in:
Ron Rennick 2020-08-25 10:13:45 -03:00 committed by GitHub
commit bdb1451f2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -1708,7 +1708,7 @@ class WC_Product_Data_Store_CPT extends WC_Data_Store_WP implements WC_Object_Da
$product_type = 'variation';
} elseif ( 'product' === $post_type ) {
$terms = get_the_terms( $product_id, 'product_type' );
$product_type = ! empty( $terms ) ? sanitize_title( current( $terms )->name ) : 'simple';
$product_type = ! empty( $terms ) && ! is_wp_error( $terms ) ? sanitize_title( current( $terms )->name ) : 'simple';
} else {
$product_type = false;
}