Order again item meta should store term slug instead of term value.
In case `taxonomy_is_product_attribute( $meta->key )` is true, `$meta->value` is the term slug, therefore we can refactor the if statement using the condition `taxonomy_is_product_attribute( $meta->key ) || meta_is_product_attribute( $meta->key, $meta->value, $product_id )`,  assign `$variations[ $meta->key ] = $meta->value`, and drop the `else` statement.
This commit is contained in:
Alexandre Froger 2022-07-27 18:58:52 +08:00 committed by GitHub
parent aaa20f556b
commit f26e62502c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 5 deletions

View File

@ -371,12 +371,9 @@ final class WC_Cart_Session {
if ( ! $product->is_in_stock() ) {
continue;
}
foreach ( $item->get_meta_data() as $meta ) {
if ( taxonomy_is_product_attribute( $meta->key ) ) {
$term = get_term_by( 'slug', $meta->value, $meta->key );
$variations[ $meta->key ] = $term ? $term->name : $meta->value;
} elseif ( meta_is_product_attribute( $meta->key, $meta->value, $product_id ) ) {
if ( taxonomy_is_product_attribute( $meta->key ) || meta_is_product_attribute( $meta->key, $meta->value, $product_id ) ) {
$variations[ $meta->key ] = $meta->value;
}
}