Code Duplication    Length = 11-16 lines in 2 locations

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

@@ 991-1006 (lines=16) @@
988
989
		$item_args = apply_filters( 'woocommerce_cli_order_line_item_args', $item_args, $item, $order, $action );
990
991
		if ( $creating ) {
992
993
			$item_id = $order->add_product( $product, $item_args['qty'], $item_args );
994
995
			if ( ! $item_id ) {
996
				throw new WC_CLI_Exception( 'woocommerce_cannot_create_line_item', __( 'Cannot create line item, try again', 'woocommerce' ) );
997
			}
998
999
		} else {
1000
1001
			$item_id = $order->update_product( $item['id'], $product, $item_args );
1002
1003
			if ( ! $item_id ) {
1004
				throw new WC_CLI_Exception( 'woocommerce_cannot_update_line_item', __( 'Cannot update line item, try again', 'woocommerce' ) );
1005
			}
1006
		}
1007
	}
1008
1009
	/**

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

@@ 674-684 (lines=11) @@
671
			$item_args['totals']['subtotal_tax'] = floatval( $item['subtotal_tax'] );
672
		}
673
674
		if ( $creating ) {
675
			$item_id = $order->add_product( $product, $item_args['qty'], $item_args );
676
			if ( ! $item_id ) {
677
				throw new WC_REST_Exception( 'woocommerce_rest_cannot_create_line_item', __( 'Cannot create line item, try again.', 'woocommerce' ), 500 );
678
			}
679
		} else {
680
			$item_id = $order->update_product( $item['id'], $product, $item_args );
681
			if ( ! $item_id ) {
682
				throw new WC_REST_Exception( 'woocommerce_rest_cannot_update_line_item', __( 'Cannot update line item, try again.', 'woocommerce' ), 500 );
683
			}
684
		}
685
	}
686
687
	/**