Last active
March 8, 2021 14:03
-
-
Save jameskoster/6061298 to your computer and use it in GitHub Desktop.
WooCommerce - Adjust the quantity incrementer
This file contains hidden or 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
// Simple products | |
add_filter( 'woocommerce_quantity_input_args', 'jk_woocommerce_quantity_input_args', 10, 2 ); | |
function jk_woocommerce_quantity_input_args( $args, $product ) { | |
$args['input_value'] = 2; // Starting value | |
$args['max_value'] = 80; // Maximum value | |
$args['min_value'] = 2; // Minimum value | |
$args['step'] = 2; // Quantity steps | |
return $args; | |
} | |
// Variations | |
add_filter( 'woocommerce_available_variation', 'jk_woocommerce_available_variation' ); | |
function jk_woocommerce_available_variation( $args ) { | |
$args['max_qty'] = 80; // Maximum value (variations) | |
$args['min_qty'] = 2; // Minimum value (variations) | |
return $args; | |
} |
is there a way to have a default quantity field in the admin, so i can enter a default quantity for each product?
hello there
I have set minimum_quantity as a custom field to each product.
how can i set it to quantity input value?
do this for admin order item qty
// admin set qty input steps
add_filter('woocommerce_quantity_input_step', 'adminApplyArgsStep', 10, 2);
function adminApplyArgsStep($step, $product) {
if(is_admin()) {
$step = 0.01; // Has to be 0.01 to not conflict with step intervals and allow the admin to totally customize the quantity in backend
}
return $step;
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Did you ever figure out how to solve your problem emilysnothere? I have the exact same issue.
Basically, I want to set a suggested product quantity (not a minimum quantity) in the shop, and leave it up to the customer how many items they add into the cart. But the cart quantity keep copying the starting input value from the shop...
Any idea how I fix this?
thanks!