Automattic\WooCommerce\Admin\API

Products::is_low_in_stock_request()privateWC 1.0

Check whether the request is for products low in stock.

It matches requests with parameters:

low_in_stock = true page = 1 fields[0] = id

Method of the class: Products{}

No Hooks.

Return

true|false. Whether the request matches.

Usage

// private - for code of main (parent) class only
$result = $this->is_low_in_stock_request( $request );
$request(string) (required)
WP REST API request.

Products::is_low_in_stock_request() code WC 8.7.0

private function is_low_in_stock_request( $request ) {
	if (
		$request->get_param( 'low_in_stock' ) === true &&
		$request->get_param( 'page' ) === 1 &&
		is_array( $request->get_param( '_fields' ) ) &&
		count( $request->get_param( '_fields' ) ) === 1 &&
		in_array( 'id', $request->get_param( '_fields' ), true )
	) {
		return true;
	}

	return false;
}