WordPress at Your Fingertips
function is not described

WC_REST_Controller::check_batch_limit() protected WC 1.0

Check batch limit.

{} It's a 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.

Code of WC_REST_Controller::check_batch_limit() WC 5.9.0

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'] ) ) {
		$total += count( $items['create'] );
	}

	if ( ! empty( $items['update'] ) ) {
		$total += count( $items['update'] );
	}

	if ( ! empty( $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;
}