skip to Main Content

A lot of the Q&A I’m finding online is about increasing the amount of variations you can make on a woocommerce variable product but I’m trying to limit the amount to 30. The reason being on some client sites I have done, they have like over 1000 variations which makes the product take an age to load. I’m creating a multivendor site so I’m trying to prevent problematic products from the get go. Some of the functions I have tried are:

add_filter( 'woocommerce_ajax_variation_threshold', 'ww_ajax_variation_threshold', 10, 2 );

function ww_ajax_variation_threshold( $default, $product ) {
    return 30;
}

and also

function wpse_rest_batch_items_limit( $limit ) {
    $limit = 30;

    return $limit;
}
add_filter( 'woocommerce_rest_batch_items_limit', 'wpse_rest_batch_items_limit' );

These don’t seem to work for me unfortunately. I also want to try and replicate this in the variation popup message. (see below)

enter image description here

Does anyone know if something like this is possible?

2

Answers


  1. There is a cut-off at 30 variations.

    Only from this number on AJAX takes over loading the data.

    add_filter( 'woocommerce_ajax_variation_threshold', 'ww_ajax_variation_threshold', 10, 2 );
    
    function ww_ajax_variation_threshold( $default, $product ) {
        return 31; //     > 30
    }
    
    Login or Signup to reply.
  2. If you want to add a limit for "per add" in admin area, add define(WC_MAX_LINKED_VARIATIONS,30) constant in wp-config.php and the popup you mentioned will show this number automatically. But consider that its just a interface limit for creating at time, and will NOT limit total variations user can build on product.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search