Save order before calculating totals if created via REST API (#37845)
This commit is contained in:
parent
95ac08739b
commit
4688290463
|
@ -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.
|
|
@ -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.
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue