Code Duplication    Length = 10-10 lines in 2 locations

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

@@ 1078-1087 (lines=10) @@
1075
1076
		// Product Type
1077
		$product_type = null;
1078
		if ( isset( $data['type'] ) ) {
1079
			$product_type = wc_clean( $data['type'] );
1080
			wp_set_object_terms( $product_id, $product_type, 'product_type' );
1081
		} else {
1082
			$_product_type = get_the_terms( $product_id, 'product_type' );
1083
			if ( is_array( $_product_type ) ) {
1084
				$_product_type = current( $_product_type );
1085
				$product_type  = $_product_type->slug;
1086
			}
1087
		}
1088
1089
		// Virtual
1090
		if ( isset( $data['virtual'] ) ) {

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

@@ 901-910 (lines=10) @@
898
899
		// Product Type.
900
		$product_type = null;
901
		if ( isset( $request['type'] ) ) {
902
			$product_type = wc_clean( $request['type'] );
903
			wp_set_object_terms( $product->id, $product_type, 'product_type' );
904
		} else {
905
			$_product_type = get_the_terms( $product->id, 'product_type' );
906
			if ( is_array( $_product_type ) ) {
907
				$_product_type = current( $_product_type );
908
				$product_type  = $_product_type->slug;
909
			}
910
		}
911
912
		// Default total sales.
913
		add_post_meta( $product->id, 'total_sales', '0', true );