Automattic\WooCommerce\Checkout\Helpers
ReserveStock::get_reserved_stock()
Query for any existing holds on stock for this item.
Метод класса: ReserveStock{}
Хуков нет.
Возвращает
Int
. Amount of stock already reserved.
Использование
$ReserveStock = new ReserveStock(); $ReserveStock->get_reserved_stock( $product, $exclude_order_id );
- $product(\WC_Product) (обязательный)
- 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 WC 9.2.3
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 ) ); }