Use wc_update_product_stock instead of manually adding and subtracting.

This commit is contained in:
Gerhard 2019-01-22 15:14:41 +02:00
parent 683111b4a5
commit bfda9c0ac8
1 changed files with 3 additions and 3 deletions

View File

@ -633,15 +633,15 @@ class WC_Admin_Post_Types {
$change_stock = absint( $_REQUEST['change_stock'] );
switch ( $change_stock ) {
case 2:
$stock_amount = wc_stock_amount( $product->get_stock_quantity() + $stock_amount );
wc_update_product_stock( $product, $stock_amount, 'increase' );
break;
case 3:
$stock_amount = wc_stock_amount( $product->get_stock_quantity() - $stock_amount );
wc_update_product_stock( $product, $stock_amount, 'decrease' );
break;
default:
wc_update_product_stock( $product, $stock_amount, 'set' );
break;
}
$product->set_stock_quantity( $stock_amount );
}
// Apply product type constraints to stock status.