Skip to content

Instantly share code, notes, and snippets.

@kartikparmar
Last active March 15, 2021 11:54
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kartikparmar/60037567c5628386f6613aa9ed2843fb to your computer and use it in GitHub Desktop.
Save kartikparmar/60037567c5628386f6613aa9ed2843fb to your computer and use it in GitHub Desktop.
Changing Min/Max quantity using filters in WooCommerce
<?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