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

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