Save order before calculating totals if created via REST API (#37845)

This commit is contained in:
Alejandro Iglesias 2023-05-11 10:29:48 +02:00 committed by GitHub
parent 95ac08739b
commit 4688290463
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: fix
Save an order created via the REST API to prevent overrides from 3rd party plugins or themes if they try to add fees to the order.

View File

@ -768,6 +768,7 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller {
if ( $creating ) {
$object->set_created_via( 'rest-api' );
$object->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) );
$object->save();
$object->calculate_totals();
} else {
// If items have changed, recalculate order totals.

View File

@ -205,6 +205,7 @@ class WC_REST_Orders_Controller extends WC_REST_Orders_V2_Controller {
if ( $creating ) {
$object->set_created_via( 'rest-api' );
$object->set_prices_include_tax( 'yes' === get_option( 'woocommerce_prices_include_tax' ) );
$object->save();
$object->calculate_totals();
} else {
// If items have changed, recalculate order totals.