wc_maybe_reduce_stock_levels

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

Description

wc_maybe_reduce_stock_levels( (int) $order_id ); 

Parameters (1)

0. $order_id (int)
The order id.

Usage

  1. if ( !function_exists( 'wc_maybe_reduce_stock_levels' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-stock-functions.php'; 
  3.  
  4. // The order id. 
  5. $order_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wc_maybe_reduce_stock_levels($order_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-stock-functions.php  
  1. function wc_maybe_reduce_stock_levels( $order_id ) { 
  2. $order = wc_get_order( $order_id ); 
  3. if ( apply_filters( 'woocommerce_payment_complete_reduce_order_stock', $order && ! $order->get_data_store()->get_stock_reduced( $order_id ), $order_id ) ) {