Created
May 5, 2025 06:54
-
-
Save arfinmilondev/dac93a345dff60da0978df8af2d34728 to your computer and use it in GitHub Desktop.
Increase the default number limit of variations for a product in WooCommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( 'woocommerce_ajax_variation_threshold', function(){ | |
| return 100; | |
| }); | |
| // Add this code to your function.php file | |
| add_filter( 'woocommerce_ajax_variation_threshold', function( $quantity, $product ) { | |
| return 50; | |
| }, 10, 2 ); | |
| /* | |
| In that code, we’re just returning a new quantity of 50 for the maximum value allowed for variations. | |
| If you wanted to do this for just a single product, here’s what that would look like: | |
| ================================================================================================ | |
| */ | |
| add_filter( 'woocommerce_ajax_variation_threshold', function( $quantity, $product ) { | |
| // If you want change the default limit for just one product, set the ID here: | |
| if ( 401 === $product->get_id() ) { | |
| return 100; | |
| } | |
| }, 10, 2 ); | |
| /*If you have any questions or suggestions for improvements, let me know!*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment