| @@ 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 | /** |
|
| @@ 614-624 (lines=11) @@ | ||
| 611 | $item_args['totals']['subtotal_tax'] = floatval( $item['subtotal_tax'] ); |
|
| 612 | } |
|
| 613 | ||
| 614 | if ( $creating ) { |
|
| 615 | $item_id = $order->add_product( $product, $item_args['qty'], $item_args ); |
|
| 616 | if ( ! $item_id ) { |
|
| 617 | throw new WC_REST_Exception( 'woocommerce_rest_cannot_create_line_item', __( 'Cannot create line item, try again.', 'woocommerce' ), 500 ); |
|
| 618 | } |
|
| 619 | } else { |
|
| 620 | $item_id = $order->update_product( $item['id'], $product, $item_args ); |
|
| 621 | if ( ! $item_id ) { |
|
| 622 | throw new WC_REST_Exception( 'woocommerce_rest_cannot_update_line_item', __( 'Cannot update line item, try again.', 'woocommerce' ), 500 ); |
|
| 623 | } |
|
| 624 | } |
|
| 625 | } |
|
| 626 | ||
| 627 | /** |
|