Code Duplication    Length = 8-9 lines in 2 locations

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

@@ 933-940 (lines=8) @@
930
			}
931
932
			// Customer ID.
933
			if ( isset( $request['customer_id'] ) && $request['customer_id'] != $order->get_user_id() ) {
934
				// Make sure customer exists.
935
				if ( false === get_user_by( 'id', $request['customer_id'] ) ) {
936
					throw new WC_REST_Exception( 'woocommerce_rest_invalid_customer_id', __( 'Customer ID is invalid.', 'woocommerce' ), 400 );
937
				}
938
939
				update_post_meta( $order->id, '_customer_user', $request['customer_id'] );
940
			}
941
942
			// Update addresses.
943
			if ( is_array( $request['billing'] ) ) {

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

@@ 446-454 (lines=9) @@
443
			}
444
445
			// customer ID
446
			if ( isset( $data['customer_id'] ) && $data['customer_id'] != $order->get_user_id() ) {
447
448
				// make sure customer exists
449
				if ( false === get_user_by( 'id', $data['customer_id'] ) ) {
450
					throw new WC_CLI_Exception( 'woocommerce_cli_invalid_customer_id', __( 'Customer ID is invalid', 'woocommerce' ) );
451
				}
452
453
				update_post_meta( $order->id, '_customer_user', $data['customer_id'] );
454
			}
455
456
			// billing/shipping address
457
			$this->set_order_addresses( $order, $data );