Created
August 4, 2023 09:08
-
-
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
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 | |
/* | |
* @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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
set min max and step product quantity at single product page and cart page