REST API: Check if stock should be adjusted when updating order line items (#47784)

* Check for stock adjustment during REST order update request

* Add changelog file
This commit is contained in:
Corey McKrill 2024-06-13 04:58:24 -07:00 committed by GitHub
parent 9cd84a44cb
commit 403ff183e0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Ensure available stock is updated correctly when updating line items in orders via the REST API.

View File

@ -930,6 +930,11 @@ class WC_REST_Orders_V2_Controller extends WC_REST_CRUD_Controller {
$this->maybe_set_item_props( $item, array( 'name', 'quantity', 'total', 'subtotal', 'tax_class' ), $posted ); $this->maybe_set_item_props( $item, array( 'name', 'quantity', 'total', 'subtotal', 'tax_class' ), $posted );
$this->maybe_set_item_meta_data( $item, $posted ); $this->maybe_set_item_meta_data( $item, $posted );
if ( 'update' === $action ) {
require_once WC_ABSPATH . 'includes/admin/wc-admin-functions.php';
wc_maybe_adjust_line_item_product_stock( $item );
}
return $item; return $item;
} }