Code Duplication    Length = 12-13 lines in 2 locations

includes/wc-product-functions.php 1 location

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

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

@@ 716-727 (lines=12) @@
713
						continue;
714
					}
715
					if ( sanitize_title( $value[0] ) === $value[0] ) {
716
						foreach ( $parent_attributes as $attribute ) {
717
							if ( 'attribute_' . sanitize_title( $attribute['name'] ) !== $name ) {
718
								continue;
719
							}
720
							$text_attributes = wc_get_text_attributes( $attribute['value'] );
721
							foreach ( $text_attributes as $text_attribute ) {
722
								if ( sanitize_title( $text_attribute ) === $value[0] ) {
723
									update_post_meta( $child_id, $name, $text_attribute );
724
									break;
725
								}
726
							}
727
						}
728
					}
729
				}
730
			}