WC_REST_Controller::check_batch_limit()
Check batch limit.
Метод класса: WC_REST_Controller{}
Хуки из метода
Возвращает
true|false|WP_Error
.
Использование
// protected - в коде основоного (родительского) или дочернего класса $result = $this->check_batch_limit( $items );
- $items(массив) (обязательный)
- Request items.
Код WC_REST_Controller::check_batch_limit() WC REST Controller::check batch limit WC 9.6.2
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; }