Last active
March 15, 2021 11:54
-
-
Save kartikparmar/60037567c5628386f6613aa9ed2843fb to your computer and use it in GitHub Desktop.
Changing Min/Max quantity using filters in WooCommerce
This file contains 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 | |
/* | |
* Changing the minimum quantity to 2 for all the WooCommerce products | |
*/ | |
function woocommerce_quantity_input_min_callback( $min, $product ) { | |
$min = 2; | |
return $min; | |
} | |
add_filter( 'woocommerce_quantity_input_min', 'woocommerce_quantity_input_min_callback', 10, 2 ); | |
/* | |
* Changing the maximum quantity to 5 for all the WooCommerce products | |
*/ | |
function woocommerce_quantity_input_max_callback( $max, $product ) { | |
$max = 5; | |
return $max; | |
} | |
add_filter( 'woocommerce_quantity_input_max', 'woocommerce_quantity_input_max_callback', 10, 2 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment