Skip to content

Instantly share code, notes, and snippets.

@codeagencybe
Last active August 4, 2018 09:45
Show Gist options
  • Save codeagencybe/7a7429334fa504338e45812601dc53a3 to your computer and use it in GitHub Desktop.
Save codeagencybe/7a7429334fa504338e45812601dc53a3 to your computer and use it in GitHub Desktop.
WooCommerce order step values
/**
* @description Minimum, maximum, incremental and start quantity for products | WooCommerce
* @author Fabio Tielen / Code Agency / https://codeagency.be
* @testedwith WooCommerce 3.3
*/
add_filter( 'woocommerce_quantity_input_args', 'ca_woocommerce_quantity_increment_changes', 10, 2 );
function ca_woocommerce_quantity_increment_changes( $args, $product ) {
if ( is_singular( 'product' ) ) {
$args['input_value'] = 20; // Start quantity for the product (default = 1)
$args['max_value'] = 200; // Maximum quantity that can be added to cart (default = n/a)
$args['min_value'] = 2; // Minimum quantity that can be added to cart (default = 1)
$args['step'] = 2; // Step value Increment or decrement by this quantity (default = 1)
return $args;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment