Automattic\WooCommerce\Checkout\Helpers
ReserveStock::get_reserved_stock()
Query for any existing holds on stock for this item.
Method of the class: ReserveStock{}
No Hooks.
Return
Int
. Amount of stock already reserved.
Usage
$ReserveStock = new ReserveStock(); $ReserveStock->get_reserved_stock( $product, $exclude_order_id );
- $product(\WC_Product) (required)
- Product to get reserved stock for.
- $exclude_order_id(int)
- Optional order to exclude from the results.
ReserveStock::get_reserved_stock() ReserveStock::get reserved stock code WC 9.4.2
public function get_reserved_stock( $product, $exclude_order_id = 0 ) { global $wpdb; if ( ! $this->is_enabled() ) { return 0; } // phpcs:ignore WordPress.DB.PreparedSQL.InterpolatedNotPrepared, WordPress.DB.PreparedSQL.NotPrepared return (int) $wpdb->get_var( $this->get_query_for_reserved_stock( $product->get_stock_managed_by_id(), $exclude_order_id ) ); }