Code Duplication    Length = 6-6 lines in 3 locations

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

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

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

@@ 328-333 (lines=6) @@
325
			$display_key   = wc_attribute_label( $attribute_key, is_callable( array( $this, 'get_product' ) ) ? $this->get_product() : false );
326
			$display_value = $meta->value;
327
328
			if ( taxonomy_exists( $attribute_key ) ) {
329
				$term = get_term_by( 'slug', $meta->value, $attribute_key );
330
				if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) {
331
					$display_value = $term->name;
332
				}
333
			}
334
335
			$formatted_meta[ $meta_id ] = (object) array(
336
				'key'           => $meta->key,