Added woocommerce_reduce_order_item_stock action hook to let other plugin hook functionalities without looping through the order items again and again. (#34721)
* Added woocommerce_reduce_order_item_stock action hook to let other plugins do somthing without looping again the order line items * changed "product data" to "change details" and updated docblock as instructed * maintained WP coding standards and change @since docblock tag
This commit is contained in:
parent
83fb31db8e
commit
92f94248cd
|
@ -0,0 +1,4 @@
|
|||
Significance: minor
|
||||
Type: enhancement
|
||||
|
||||
Added woocommerce_reduce_order_item_stock action hook
|
|
@ -197,11 +197,22 @@ function wc_reduce_stock_levels( $order_id ) {
|
|||
$item->add_meta_data( '_reduced_stock', $qty, true );
|
||||
$item->save();
|
||||
|
||||
$changes[] = array(
|
||||
$change = array(
|
||||
'product' => $product,
|
||||
'from' => $new_stock + $qty,
|
||||
'to' => $new_stock,
|
||||
);
|
||||
$changes[] = $change;
|
||||
|
||||
/**
|
||||
* Fires when stock reduced to a specific line item
|
||||
*
|
||||
* @param WC_Order_Item_Product $item Order item data.
|
||||
* @param array $change Change Details.
|
||||
* @param WC_Order $order Order data.
|
||||
* @since 7.6.0
|
||||
*/
|
||||
do_action( 'woocommerce_reduce_order_item_stock', $item, $change, $order );
|
||||
}
|
||||
|
||||
wc_trigger_stock_change_notifications( $order, $changes );
|
||||
|
|
Loading…
Reference in New Issue