WordPress at a glance
function is not described

Automattic\WooCommerce\Blocks\StoreApi\Utilities

CartController::get_remaining_stock_for_product() protected WC 1.0

Gets remaining stock for a product.

{} It's a method of the class: CartController{}

No Hooks.

Return

Int.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_remaining_stock_for_product( $product );
$product(\WC_Product) (required)
Product object.

Code of CartController::get_remaining_stock_for_product() WC 5.0.0

<?php
protected function get_remaining_stock_for_product( $product ) {
	$reserve_stock = new ReserveStock();
	$draft_order   = wc()->session->get( 'store_api_draft_order', 0 );
	$qty_reserved  = $reserve_stock->get_reserved_stock( $product, $draft_order );

	return $product->get_stock_quantity() - $qty_reserved;
}