wc_maybe_increase_stock_levels( int $order_id )
When a payment is cancelled, restore stock.
Description Description
Parameters Parameters
- $order_id
-
(Required) Order ID.
Source Source
File: includes/wc-stock-functions.php
function wc_maybe_increase_stock_levels( $order_id ) { $order = wc_get_order( $order_id ); if ( ! $order ) { return; } $stock_reduced = $order->get_data_store()->get_stock_reduced( $order_id ); $trigger_increase = (bool) $stock_reduced; // Only continue if we're increasing stock. if ( ! $trigger_increase ) { return; } wc_increase_stock_levels( $order ); // Ensure stock is not marked as "reduced" anymore. $order->get_data_store()->set_stock_reduced( $order_id, false ); }
Changelog Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |