parent
10b121858a
commit
d4fbe0e45c
|
@ -2456,11 +2456,12 @@ abstract class WC_Abstract_Order {
|
|||
if ( $_product && $_product->exists() && $_product->managing_stock() ) {
|
||||
$qty = apply_filters( 'woocommerce_order_item_quantity', $item['qty'], $this, $item );
|
||||
$new_stock = $_product->reduce_stock( $qty );
|
||||
$item_name = $_product->get_sku() ? $_product->get_sku(): $item['product_id'];
|
||||
|
||||
if ( isset( $item['variation_id'] ) && $item['variation_id'] ) {
|
||||
$this->add_order_note( sprintf( __( 'Item #%s variation #%s stock reduced from %s to %s.', 'woocommerce' ), $item['product_id'], $item['variation_id'], $new_stock + $qty, $new_stock) );
|
||||
$this->add_order_note( sprintf( __( 'Item %s variation #%s stock reduced from %s to %s.', 'woocommerce' ), $item_name, $item['variation_id'], $new_stock + $qty, $new_stock) );
|
||||
} else {
|
||||
$this->add_order_note( sprintf( __( 'Item #%s stock reduced from %s to %s.', 'woocommerce' ), $item['product_id'], $new_stock + $qty, $new_stock) );
|
||||
$this->add_order_note( sprintf( __( 'Item %s stock reduced from %s to %s.', 'woocommerce' ), $item_name, $new_stock + $qty, $new_stock) );
|
||||
}
|
||||
$this->send_stock_notifications( $_product, $new_stock, $item['qty'] );
|
||||
}
|
||||
|
|
|
@ -1414,7 +1414,8 @@ class WC_AJAX {
|
|||
if ( $_product->exists() && $_product->managing_stock() && isset( $order_item_qty[ $item_id ] ) && $order_item_qty[ $item_id ] > 0 ) {
|
||||
$stock_change = apply_filters( 'woocommerce_reduce_order_stock_quantity', $order_item_qty[ $item_id ], $item_id );
|
||||
$new_stock = $_product->reduce_stock( $stock_change );
|
||||
$note = sprintf( __( 'Item #%s stock reduced from %s to %s.', 'woocommerce' ), $order_item['product_id'], $new_stock + $stock_change, $new_stock );
|
||||
$item_name = $_product->get_sku() ? $_product->get_sku() : $order_item['product_id'];
|
||||
$note = sprintf( __( 'Item %s stock reduced from %s to %s.', 'woocommerce' ), $item_name, $new_stock + $stock_change, $new_stock );
|
||||
$return[] = $note;
|
||||
|
||||
$order->add_order_note( $note );
|
||||
|
@ -1463,10 +1464,11 @@ class WC_AJAX {
|
|||
$_product = $order->get_product_from_item( $order_item );
|
||||
|
||||
if ( $_product->exists() && $_product->managing_stock() && isset( $order_item_qty[ $item_id ] ) && $order_item_qty[ $item_id ] > 0 ) {
|
||||
$old_stock = $_product->stock;
|
||||
$old_stock = $_product->get_stock_quantity();
|
||||
$stock_change = apply_filters( 'woocommerce_restore_order_stock_quantity', $order_item_qty[ $item_id ], $item_id );
|
||||
$new_quantity = $_product->increase_stock( $stock_change );
|
||||
$note = sprintf( __( 'Item #%s stock increased from %s to %s.', 'woocommerce' ), $order_item['product_id'], $old_stock, $new_quantity );
|
||||
$item_name = $_product->get_sku() ? $_product->get_sku(): $order_item['product_id'];
|
||||
$note = sprintf( __( 'Item %s stock increased from %s to %s.', 'woocommerce' ), $item_name, $old_stock, $new_quantity );
|
||||
$return[] = $note;
|
||||
|
||||
$order->add_order_note( $note );
|
||||
|
|
Loading…
Reference in New Issue