* Fixes issue #33335

Check for an empty string instead of an empty variable.

* Update wc-product-functions.php

* Update wc-product-functions.php

* Changelog

* Fix cases when $term is false or empty array

Co-authored-by: Peter Fabian <peter.fabian.github@gmail.com>
This commit is contained in:
Dekadinious 2022-06-24 17:48:17 +02:00 committed by GitHub
parent d2967e0ee8
commit 2c721c7c88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Correct generation of variation name when attribute is 0.

View File

@ -392,7 +392,7 @@ function wc_get_formatted_variation( $variation, $flat = false, $include_names =
// If this is a term slug, get the term's nice name.
if ( taxonomy_exists( $name ) ) {
$term = get_term_by( 'slug', $value, $name );
if ( ! is_wp_error( $term ) && ! empty( $term->name ) ) {
if ( ! is_wp_error( $term ) && $term && null !== $term->name && '' !== $term->name ) {
$value = $term->name;
}
}