diff --git a/includes/wc-order-item-functions.php b/includes/wc-order-item-functions.php index c4e0e0bc8e6..9c4a4bef44a 100644 --- a/includes/wc-order-item-functions.php +++ b/includes/wc-order-item-functions.php @@ -44,10 +44,10 @@ function wc_add_order_item( $order_id, $item_array ) { /** * Update an item for an order. * + * @since 2.2 * @param int $item_id Item ID. * @param array $args Either `order_item_type` or `order_item_name`. * - * @since 2.2 * @throws Exception When `WC_Data_Store::load` validation fails. * @return bool True if successfully updated, false otherwise. */ @@ -67,13 +67,12 @@ function wc_update_order_item( $item_id, $args ) { /** * Delete an item from the order it belongs to based on item id. * - * @param int $item_id Item ID. - * @param bool $adjust_stock True or false. If the item had it's stock reduced, this will restore the stock and make a note. + * @param int $item_id Item ID. * * @throws Exception When `WC_Data_Store::load` validation fails. * @return bool */ -function wc_delete_order_item( $item_id, $adjust_stock = false ) { +function wc_delete_order_item( $item_id ) { $item_id = absint( $item_id ); if ( ! $item_id ) { @@ -84,30 +83,6 @@ function wc_delete_order_item( $item_id, $adjust_stock = false ) { do_action( 'woocommerce_before_delete_order_item', $item_id ); - if ( $adjust_stock ) { - $item = WC_Order_Factory::get_order_item( $item_id ); - - if ( $item->is_type( 'line_item' ) ) { - $order_id = wc_get_order_id_by_order_item_id( $item_id ); - $order = wc_get_order( $order_id ); - $product = $item->get_product(); - $item_stock_reduced = $item->get_meta( '_reduced_stock', true ); - - if ( $order && $product && $item_stock_reduced && $product->managing_stock() ) { - $item_name = $product->get_formatted_name(); - $new_stock = wc_update_product_stock( $product, $item_stock_reduced, 'increase' ); - - if ( is_wp_error( $new_stock ) ) { - /* translators: %s item name. */ - $order->add_order_note( sprintf( __( 'Unable to restore stock for item %s.', 'woocommerce' ), $item_name ) ); - } else { - /* translators: %1$s: item name, %2$s stock change */ - $order->add_order_note( sprintf( __( '%1$s stock increased %2$s.', 'woocommerce' ), $item_name, ( $new_stock - $item_stock_reduced ) . '→' . $new_stock ) ); - } - } - } - } - $data_store->delete_order_item( $item_id ); do_action( 'woocommerce_delete_order_item', $item_id ); @@ -195,7 +170,7 @@ function wc_get_order_item_meta( $item_id, $key, $single = true ) { /** * Get order ID by order item ID. * - * @param int $item_id Item ID. + * @param int $item_id Item ID. * * @throws Exception When `WC_Data_Store::load` validation fails. * @return int