Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wooxperto/8e3c484627ec256e17d70761d9a651f9 to your computer and use it in GitHub Desktop.
Save wooxperto/8e3c484627ec256e17d70761d9a651f9 to your computer and use it in GitHub Desktop.
Set Min, Max & Step Product quantity at single product page and cart page on WooCommerce
<?php
/*
* @snippet Min, Max, Increment & Default Value Quantity | WooCommerce
* @author WooXperto
* @date 04.08.2023
*/
add_filter( 'woocommerce_quantity_input_args', 'wooxperto_r_woocommerce_quantity_changes', 6666, 2 );
function wooxperto_r_woocommerce_quantity_changes( $args, $product ) {
if ( ! is_cart() ) {
$args['input_value'] = 10; // Start from this value (default = 1)
$args['max_value'] = 100; // Max quantity (default = -1)
$args['min_value'] = 10; // Min quantity (default = 0)
$args['step'] = 2; // Increment/decrement by this value (default = 1)
} else {
$args['max_value'] = 100; // Max quantity (default = -1)
$args['step'] = 2; // Increment/decrement by this value (default = 0)
}
return $args;
}
@wooxperto
Copy link
Author

set min max and step product quantity at single product page and cart page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment