Get updated product before doing low stock actions

This commit is contained in:
claudiulodro 2017-04-19 15:32:51 -07:00
parent c90e71e890
commit 01a6b3bae0
1 changed files with 3 additions and 0 deletions

View File

@ -96,6 +96,9 @@ function wc_reduce_stock_levels( $order_id ) {
/* translators: 1: item name 2: old stock quantity 3: new stock quantity */
$order->add_order_note( sprintf( __( '%1$s stock reduced from %2$s to %3$s.', 'woocommerce' ), $item_name, $new_stock + $qty, $new_stock ) );
// Get the latest product data.
$product = wc_get_product( $product->get_id() );
if ( '' !== get_option( 'woocommerce_notify_no_stock_amount' ) && $new_stock <= get_option( 'woocommerce_notify_no_stock_amount' ) ) {
do_action( 'woocommerce_no_stock', $product );
} elseif ( '' !== get_option( 'woocommerce_notify_low_stock_amount' ) && $new_stock <= get_option( 'woocommerce_notify_low_stock_amount' ) ) {