WordPress at Your Fingertips
function is not described

wc_maybe_increase_stock_levels() WC 3.0.0

When a payment is cancelled, restore stock.

No Hooks.

Return

null. Nothing.

Usage

wc_maybe_increase_stock_levels( $order_id );
$order_id(int) (required)
Order ID.

Changelog

Since 3.0.0 Introduced.

Code of wc_maybe_increase_stock_levels() WC 5.6.0

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 );
}