Merge pull request #23249 from woocommerce/fix/23247

Avoid post update in `wc_update_product_stock`
This commit is contained in:
Mike Jolley 2019-04-18 11:10:36 +01:00 committed by GitHub
commit f0c5209f2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -43,7 +43,6 @@ function wc_update_product_stock( $product, $stock_quantity = null, $operation =
// Re-read product data after updating stock, then have stock status calculated and saved.
$product_with_stock = wc_get_product( $product_id_with_stock );
$product_with_stock->set_stock_status();
$product_with_stock->set_date_modified( current_time( 'timestamp', true ) );
$product_with_stock->save();
if ( $product_with_stock->is_type( 'variation' ) ) {
@ -216,7 +215,8 @@ function wc_trigger_stock_change_notifications( $order, $changes ) {
if ( $change['to'] < 0 ) {
do_action(
'woocommerce_product_on_backorder', array(
'woocommerce_product_on_backorder',
array(
'product' => wc_get_product( $change['product']->get_id() ),
'order_id' => $order->get_id(),
'quantity' => abs( $change['from'] - $change['to'] ),
@ -320,7 +320,7 @@ function wc_get_held_stock_quantity( $product, $exclude_order_id = 0 ) {
/**
* Return low stock amount to determine if notification needs to be sent
*
* @param WC_Product $product
* @param WC_Product $product Product to get data from.
* @since 3.5.0
* @return int
*/