Code Duplication    Length = 11-16 lines in 2 locations

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

@@ 624-634 (lines=11) @@
621
			$item_args['totals']['subtotal_tax'] = floatval( $item['subtotal_tax'] );
622
		}
623
624
		if ( $creating ) {
625
			$item_id = $order->add_product( $product, $item_args['qty'], $item_args );
626
			if ( ! $item_id ) {
627
				throw new WC_REST_Exception( 'woocommerce_rest_cannot_create_line_item', __( 'Cannot create line item, try again.', 'woocommerce' ), 500 );
628
			}
629
		} else {
630
			$item_id = $order->update_product( $item['id'], $product, $item_args );
631
			if ( ! $item_id ) {
632
				throw new WC_REST_Exception( 'woocommerce_rest_cannot_update_line_item', __( 'Cannot update line item, try again.', 'woocommerce' ), 500 );
633
			}
634
		}
635
	}
636
637
	/**

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
	/**