Merge pull request #13460 from woocommerce/fix-13458

Set line item prices on legacy API order create
This commit is contained in:
Claudio Sanches 2017-03-03 15:45:53 -03:00 committed by GitHub
commit ee276e10a4
2 changed files with 8 additions and 0 deletions

View File

@ -918,6 +918,10 @@ class WC_API_Orders extends WC_API_Resource {
} }
if ( isset( $item['total'] ) ) { if ( isset( $item['total'] ) ) {
$line_item->set_total( floatval( $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'] ) ) { if ( isset( $item['total_tax'] ) ) {
$line_item->set_total_tax( floatval( $item['total_tax'] ) ); $line_item->set_total_tax( floatval( $item['total_tax'] ) );

View File

@ -967,6 +967,10 @@ class WC_API_Orders extends WC_API_Resource {
} }
if ( isset( $item['total'] ) ) { if ( isset( $item['total'] ) ) {
$line_item->set_total( floatval( $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'] ) ) { if ( isset( $item['total_tax'] ) ) {
$line_item->set_total_tax( floatval( $item['total_tax'] ) ); $line_item->set_total_tax( floatval( $item['total_tax'] ) );