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

@@ 663-673 (lines=11) @@
660
			$item_args['totals']['subtotal_tax'] = floatval( $item['subtotal_tax'] );
661
		}
662
663
		if ( $creating ) {
664
			$item_id = $order->add_product( $product, $item_args['qty'], $item_args );
665
			if ( ! $item_id ) {
666
				throw new WC_REST_Exception( 'woocommerce_rest_cannot_create_line_item', __( 'Cannot create line item, try again.', 'woocommerce' ), 500 );
667
			}
668
		} else {
669
			$item_id = $order->update_product( $item['id'], $product, $item_args );
670
			if ( ! $item_id ) {
671
				throw new WC_REST_Exception( 'woocommerce_rest_cannot_update_line_item', __( 'Cannot update line item, try again.', 'woocommerce' ), 500 );
672
			}
673
		}
674
	}
675
676
	/**