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)
Does anyone know if something like this is possible?
CodePudding user response:
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
}
CodePudding user response:
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.