Increase product variation limit in woocommerce

Question

I want to increase the product variation limit in woocomerce.

In existing woocommerce code, The product variation limit is 100.

$limit = apply_filters( ‘woocommerce_rest_batch_items_limit’, 100, $this->get_normalized_rest_base() );

I changed the existing code product variation limit as 100 to 200.

$limit = apply_filters( ‘woocommerce_rest_batch_items_limit’, 200, $this->get_normalized_rest_base() );

It works but when I update my woocommerce plugin existing code changes are removed.

So I want that changes in function.php file. How to do it.

Base Code
( wordpress/plugin/woocommerce/includes/abstract/abstract-wc-rest-controller )

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;
}
0
kirubanidhi 3 years 2018-05-23T05:57:05-05:00 0 Answers 96 views 0

Leave an answer