woocommerce_ajax_variation_threshold
Filter the number of variations threshold.
Использование
add_filter( 'woocommerce_ajax_variation_threshold', 'wp_kama_woocommerce_ajax_variation_threshold_filter', 10, 2 ); /** * Function for `woocommerce_ajax_variation_threshold` filter-hook. * * @param int $threshold Maximum number of variations to load upfront. * @param WC_Product $product Product object. * * @return int */ function wp_kama_woocommerce_ajax_variation_threshold_filter( $threshold, $product ){ // filter... return $threshold; }
- $threshold(int)
- Maximum number of variations to load upfront.
- $product(WC_Product)
- Product object.
Список изменений
С версии 9.7.0 | Введена. |
Где вызывается хук
woocommerce_ajax_variation_threshold
woocommerce_ajax_variation_threshold
woocommerce/src/Blocks/BlockTypes/AddToCartWithOptionsVariationSelector.php 174
$get_variations = count( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );
woocommerce/includes/wc-template-functions.php 1950
$get_variations = count( $product->get_children() ) <= apply_filters( 'woocommerce_ajax_variation_threshold', 30, $product );