Code Duplication    Length = 12-13 lines in 2 locations

includes/wc-product-functions.php 1 location

@@ 669-681 (lines=13) @@
666
		 * Attempt to get full version of the text attribute from the parent.
667
		 */
668
		if ( sanitize_title( $value[0] ) === $value[0] && version_compare( get_post_meta( $parent_id, '_product_version', true ), '2.4.0', '<' ) ) {
669
			foreach ( $parent_attributes as $attribute ) {
670
				if ( $name !== 'attribute_' . sanitize_title( $attribute['name'] ) ) {
671
					continue;
672
				}
673
				$text_attributes = wc_get_text_attributes( $attribute['value'] );
674
675
				foreach ( $text_attributes as $text_attribute ) {
676
					if ( sanitize_title( $text_attribute ) === $value[0] ) {
677
						$value[0] = $text_attribute;
678
						break;
679
					}
680
				}
681
			}
682
		}
683
684
		$variation_attributes[ $name ] = $value[0];

includes/class-wc-product-variable.php 1 location

@@ 708-719 (lines=12) @@
705
						continue;
706
					}
707
					if ( sanitize_title( $value[0] ) === $value[0] ) {
708
						foreach ( $parent_attributes as $attribute ) {
709
							if ( $name !== 'attribute_' . sanitize_title( $attribute['name'] ) ) {
710
								continue;
711
							}
712
							$text_attributes = wc_get_text_attributes( $attribute['value'] );
713
							foreach ( $text_attributes as $text_attribute ) {
714
								if ( sanitize_title( $text_attribute ) === $value[0] ) {
715
									update_post_meta( $child_id, $name, $text_attribute );
716
									break;
717
								}
718
							}
719
						}
720
					}
721
				}
722
			}