Stock from orders can get added back to inventory for a variety of reasons: order was refunded, order was switched back to pending, or item was removed from an order.
Generally, this is what you would want WooCommerce to do. But in certain specific cases you may want to ensure stock is never returned to inventory. Here’s how:
// Defaults the edit order UI to not restock products on refund. add_filter( 'woocommerce_restock_refunded_items', '__return_false' ); // Prevents items from being returned to stock when status changes. add_filter( 'woocommerce_can_restore_order_stock', '__return_false' ); // Prevents items from being returned to stock when line item adjustment is made. add_filter( 'woocommerce_prevent_adjust_line_item_product_stock', '__return_true' );
Hey Devin, this was exactly what I was looking for. Thanks so much for publishing this less common snippet.