WC_REST_Controller::check_batch_limit()
Check batch limit.
Method of the class: WC_REST_Controller{}
Hooks from the method
Return
true|false|WP_Error
.
Usage
// protected - for code of main (parent) or child class $result = $this->check_batch_limit( $items );
- $items(array) (required)
- Request items.
WC_REST_Controller::check_batch_limit() WC REST Controller::check batch limit code WC 9.7.1
protected function check_batch_limit( $items ) { $limit = apply_filters( 'woocommerce_rest_batch_items_limit', 100, $this->get_normalized_rest_base() ); $total = 0; if ( ! empty( $items['create'] ) && is_countable( $items['create'] ) ) { $total += count( $items['create'] ); } if ( ! empty( $items['update'] ) && is_countable( $items['update'] ) ) { $total += count( $items['update'] ); } if ( ! empty( $items['delete'] ) && is_countable( $items['delete'] ) ) { $total += count( $items['delete'] ); } if ( $total > $limit ) { /* translators: %s: items limit */ return new WP_Error( 'woocommerce_rest_request_entity_too_large', sprintf( __( 'Unable to accept more than %s items for this request.', 'woocommerce' ), $limit ), array( 'status' => 413 ) ); } return true; }