Code Duplication    Length = 12-13 lines in 2 locations

includes/wc-product-functions.php 1 location

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

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

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