-
-
Save jameskoster/6061298 to your computer and use it in GitHub Desktop.
// 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; | |
} |
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!
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;
}
Thanks for this, I've set the default value displayed to '0' which works perfectly, except it overrides the quantity displaying in the cart to '0' (even though prices are correct).
Any fix for this?