WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

wc_maybe_reduce_stock_levels() WC 3.0.0

When a payment is complete, we can reduce stock levels for items within an order.

Возвращает

Null. Ничего.

Использование

wc_maybe_reduce_stock_levels( $order_id );
$order_id(число) (обязательный)
Order ID.

Список изменений

С версии 3.0.0 Введена.

Код wc maybe reduce stock levels: woocommerce/includes/wc-stock-functions.php WC 4.3.1

<?php
function wc_maybe_reduce_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_reduce = apply_filters( 'woocommerce_payment_complete_reduce_order_stock', ! $stock_reduced, $order_id );

	// Only continue if we're reducing stock.
	if ( ! $trigger_reduce ) {
		return;
	}

	wc_reduce_stock_levels( $order );

	// Ensure stock is marked as "reduced" in case payment complete or other stock actions are called.
	$order->get_data_store()->set_stock_reduced( $order_id, true );
}