Code Duplication    Length = 6-6 lines in 3 locations

includes/class-wc-order-item-meta.php 2 locations

@@ 125-130 (lines=6) @@
122
				$meta_value    = $meta->value;
123
124
				// If this is a term slug, get the term's nice name
125
				if ( taxonomy_exists( $attribute_key ) ) {
126
					$term = get_term_by( 'slug', $meta_value, $attribute_key );
127
128
					if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) {
129
						$meta_value = $term->name;
130
					}
131
				}
132
133
				$formatted_meta[ $meta_id ] = array(
@@ 169-174 (lines=6) @@
166
				$attribute_key = urldecode( str_replace( 'attribute_', '', $meta_key ) );
167
168
				// If this is a term slug, get the term's nice name
169
				if ( taxonomy_exists( $attribute_key ) ) {
170
					$term = get_term_by( 'slug', $meta_value, $attribute_key );
171
					if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) {
172
						$meta_value = $term->name;
173
					}
174
				}
175
176
				// Unique key required
177
				$formatted_meta_key = $meta_key;

includes/class-wc-order-item.php 1 location

@@ 307-312 (lines=6) @@
304
			$display_key   = wc_attribute_label( $attribute_key, is_callable( array( $this, 'get_product' ) ) ? $this->get_product() : false );
305
			$display_value = $meta->value;
306
307
			if ( taxonomy_exists( $attribute_key ) ) {
308
				$term = get_term_by( 'slug', $meta->value, $attribute_key );
309
				if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) {
310
					$display_value = $term->name;
311
				}
312
			}
313
314
			$formatted_meta[ $meta->meta_id ] = (object) array(
315
				'key'           => $meta->key,