From 51c5910866e8998fe799a6574acc3dd96e84757d Mon Sep 17 00:00:00 2001 From: Claudiu Lodromanean Date: Fri, 3 Mar 2017 09:26:08 -0800 Subject: [PATCH] Set line item prices on legacy API order create --- includes/api/legacy/v2/class-wc-api-orders.php | 4 ++++ includes/api/legacy/v3/class-wc-api-orders.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/includes/api/legacy/v2/class-wc-api-orders.php b/includes/api/legacy/v2/class-wc-api-orders.php index b7b58bfda35..beab8c3d428 100644 --- a/includes/api/legacy/v2/class-wc-api-orders.php +++ b/includes/api/legacy/v2/class-wc-api-orders.php @@ -918,6 +918,10 @@ class WC_API_Orders extends WC_API_Resource { } if ( isset( $item['total'] ) ) { $line_item->set_total( floatval( $item['total'] ) ); + } elseif ( $creating ) { + $total = wc_get_price_excluding_tax( $product, array( 'qty' => $line_item->get_quantity() ) ); + $line_item->set_total( $total ); + $line_item->set_subtotal( $total ); } if ( isset( $item['total_tax'] ) ) { $line_item->set_total_tax( floatval( $item['total_tax'] ) ); diff --git a/includes/api/legacy/v3/class-wc-api-orders.php b/includes/api/legacy/v3/class-wc-api-orders.php index fa51944e8cc..9d26268f230 100644 --- a/includes/api/legacy/v3/class-wc-api-orders.php +++ b/includes/api/legacy/v3/class-wc-api-orders.php @@ -967,6 +967,10 @@ class WC_API_Orders extends WC_API_Resource { } if ( isset( $item['total'] ) ) { $line_item->set_total( floatval( $item['total'] ) ); + } elseif ( $creating ) { + $total = wc_get_price_excluding_tax( $product, array( 'qty' => $line_item->get_quantity() ) ); + $line_item->set_total( $total ); + $line_item->set_subtotal( $total ); } if ( isset( $item['total_tax'] ) ) { $line_item->set_total_tax( floatval( $item['total_tax'] ) );