Code Duplication    Length = 3-3 lines in 5 locations

includes/admin/meta-boxes/class-wc-meta-box-product-data.php 4 locations

@@ 814-816 (lines=3) @@
811
		// Dimensions
812
		if ( 'no' == $is_virtual ) {
813
814
			if ( isset( $_POST['_weight'] ) ) {
815
				update_post_meta( $post_id, '_weight', ( '' === $_POST['_weight'] ) ? '' : wc_format_decimal( $_POST['_weight'] ) );
816
			}
817
818
			if ( isset( $_POST['_length'] ) ) {
819
				update_post_meta( $post_id, '_length', ( '' === $_POST['_length'] ) ? '' : wc_format_decimal( $_POST['_length'] ) );
@@ 818-820 (lines=3) @@
815
				update_post_meta( $post_id, '_weight', ( '' === $_POST['_weight'] ) ? '' : wc_format_decimal( $_POST['_weight'] ) );
816
			}
817
818
			if ( isset( $_POST['_length'] ) ) {
819
				update_post_meta( $post_id, '_length', ( '' === $_POST['_length'] ) ? '' : wc_format_decimal( $_POST['_length'] ) );
820
			}
821
822
			if ( isset( $_POST['_width'] ) ) {
823
				update_post_meta( $post_id, '_width', ( '' === $_POST['_width'] ) ? '' : wc_format_decimal( $_POST['_width'] ) );
@@ 822-824 (lines=3) @@
819
				update_post_meta( $post_id, '_length', ( '' === $_POST['_length'] ) ? '' : wc_format_decimal( $_POST['_length'] ) );
820
			}
821
822
			if ( isset( $_POST['_width'] ) ) {
823
				update_post_meta( $post_id, '_width', ( '' === $_POST['_width'] ) ? '' : wc_format_decimal( $_POST['_width'] ) );
824
			}
825
826
			if ( isset( $_POST['_height'] ) ) {
827
				update_post_meta( $post_id, '_height', ( '' === $_POST['_height'] ) ? '' : wc_format_decimal( $_POST['_height'] ) );
@@ 826-828 (lines=3) @@
823
				update_post_meta( $post_id, '_width', ( '' === $_POST['_width'] ) ? '' : wc_format_decimal( $_POST['_width'] ) );
824
			}
825
826
			if ( isset( $_POST['_height'] ) ) {
827
				update_post_meta( $post_id, '_height', ( '' === $_POST['_height'] ) ? '' : wc_format_decimal( $_POST['_height'] ) );
828
			}
829
830
		} else {
831
			update_post_meta( $post_id, '_weight', '' );

includes/api/class-wc-rest-products-controller.php 1 location

@@ 766-768 (lines=3) @@
763
			update_post_meta( $product->id, '_width', '' );
764
			update_post_meta( $product->id, '_height', '' );
765
		} else {
766
			if ( isset( $data['weight'] ) ) {
767
				update_post_meta( $product->id, '_weight', '' === $data['weight'] ? '' : wc_format_decimal( $data['weight'] ) );
768
			}
769
770
			// Height.
771
			if ( isset( $data['dimensions']['height'] ) ) {