* Bug fixes for the low in stock endpoint

* post_parent type should be int

* type should be either simple or variation

* Remove cache-control
This commit is contained in:
Moon 2021-07-20 20:13:31 -07:00 committed by GitHub
parent 199b042e77
commit 8ce0808578
1 changed files with 2 additions and 3 deletions

View File

@ -77,7 +77,6 @@ final class ProductsLowInStock extends \WC_REST_Products_Controller {
$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'] );
$response->header( 'Cache-Control', 'max-age=300' );
return $response;
}
@ -205,9 +204,9 @@ final class ProductsLowInStock extends \WC_REST_Products_Controller {
'low_stock_amount' => $query_result->low_stock_amount,
'last_order_date' => wc_rest_prepare_date_response( $query_result->last_order_date ),
'name' => $query_result->post_title,
'parent_id' => $query_result->post_parent,
'parent_id' => (int) $query_result->post_parent,
'stock_quantity' => (int) $query_result->stock_quantity,
'type' => 'product_variation' === $query_result->post_type ? 'variation' : 'product',
'type' => 'product_variation' === $query_result->post_type ? 'variation' : 'simple',
);
}