wc_get_held_stock_quantity()
See how much stock is being held in pending orders.
Hooks from the function
Returns
Int.
Usage
wc_get_held_stock_quantity( $product, $exclude_order_id );
- $product(WC_Product) (required)
- Product to check.
- $exclude_order_id(int)
- Order ID to exclude.
Changelog
| Since 3.5.0 | Introduced. |
wc_get_held_stock_quantity() wc get held stock quantity code WC 10.3.3
function wc_get_held_stock_quantity( WC_Product $product, $exclude_order_id = 0 ) {
/**
* Filter: woocommerce_hold_stock_for_checkout
* Allows enable/disable hold stock functionality on checkout.
*
* @since 4.3.0
* @param bool $enabled Default to true if managing stock globally.
*/
if ( ! apply_filters( 'woocommerce_hold_stock_for_checkout', wc_string_to_bool( get_option( 'woocommerce_manage_stock', 'yes' ) ) ) ) {
return 0;
}
$reserve_stock = new ReserveStock();
return $reserve_stock->get_reserved_stock( $product, $exclude_order_id );
}