Automattic\WooCommerce\Admin\API
ProductsLowInStock::get_items()
Get low in stock products.
Method of the class: ProductsLowInStock{}
No Hooks.
Return
WP_REST_Response|WP_ERROR
.
Usage
$ProductsLowInStock = new ProductsLowInStock(); $ProductsLowInStock->get_items( $request );
- $request(WP_REST_Request) (required)
- request object.
ProductsLowInStock::get_items() ProductsLowInStock::get items code WC 9.6.0
public function get_items( $request ) { $query_results = $this->get_low_in_stock_products( $request->get_param( 'page' ), $request->get_param( 'per_page' ), $request->get_param( 'status' ) ); // set images and attributes. $query_results['results'] = array_map( function( $query_result ) { $product = wc_get_product( $query_result ); $query_result->images = $this->get_images( $product ); $query_result->attributes = $this->get_attributes( $product ); return $query_result; }, $query_results['results'] ); // set last_order_date. $query_results['results'] = $this->set_last_order_date( $query_results['results'] ); // convert the post data to the expected API response for the backward compatibility. $query_results['results'] = array_map( array( $this, 'transform_post_to_api_response' ), $query_results['results'] ); $response = rest_ensure_response( array_values( $query_results['results'] ) ); $response->header( 'X-WP-Total', $query_results['total'] ); $response->header( 'X-WP-TotalPages', $query_results['pages'] ); return $response; }