514

How to Increase WooCommerce Variation Threshold to Show More Products

By default, WooCommerce only loads 30 variations on the front-end for variable products. If your product has more variations than that, WooCommerce will not fetch them until they’re selected in the drop-downs – which means that unavailable variations will show up in the drop-downs. This snippet loads 100 variations on the front end, improving your WooCommerce product display and variation threshold.


<?php
if ( ! function_exists( 'wpcodebox_wooco_variation_threshold' ) ) {
    function wpcodebox_wooco_variation_threshold ( $amount, $product ) {
        return 100; // change this to the amount of variations you want to load
    }
}

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

Other Snippets

WPCodeBox is a WordPress Code Snippets Manager that allows you to share your WordPress Code Snippets across your sites.