Code Duplication    Length = 9-9 lines in 2 locations

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

@@ 935-943 (lines=9) @@
932
933
		// variations must each have a key & value
934
		$variation_id = 0;
935
		if ( isset( $item['variations'] ) && is_array( $item['variations'] ) ) {
936
			foreach ( $item['variations'] as $key => $value ) {
937
				if ( ! $key || ! $value ) {
938
					throw new WC_CLI_Exception( 'woocommerce_cli_invalid_product_variation', __( 'The product variation is invalid', 'woocommerce' ) );
939
				}
940
			}
941
			$item_args['variation'] = $item['variations'];
942
			$variation_id = $this->get_variation_id( wc_get_product( $product_id ), $item_args['variation'] );
943
		}
944
945
		$product = wc_get_product( $variation_id ? $variation_id : $product_id );
946

includes/api/class-wc-api-orders.php 1 location

@@ 930-938 (lines=9) @@
927
928
		// variations must each have a key & value
929
		$variation_id = 0;
930
		if ( isset( $item['variations'] ) && is_array( $item['variations'] ) ) {
931
			foreach ( $item['variations'] as $key => $value ) {
932
				if ( ! $key || ! $value ) {
933
					throw new WC_API_Exception( 'woocommerce_api_invalid_product_variation', __( 'The product variation is invalid', 'woocommerce' ), 400 );
934
				}
935
			}
936
			$item_args['variation'] = $item['variations'];
937
			$variation_id = $this->get_variation_id( wc_get_product( $product_id ), $item_args['variation'] );
938
		}
939
940
		$product = wc_get_product( $variation_id ? $variation_id : $product_id );
941