Try this in your functions.php:
add_filter( 'woocommerce_quantity_input_args', 'control_product_qty_input', 20, 2 );
function control_product_qty_input( $args, $product ) {
$settings = array('49' => 3, '48' => 10); // for product id 49 3 products set
foreach ($settings as $k => $v) {
if($k === $product->get_id()){
$args['max_value'] = $v;
$args['min_value'] = $v;
}
}
return $args;
}
Note: Woocommerce hide the input number when min and max are same.
Note #2: This code’ll work only on single product view.
EDIT: You can have multiple values in dropdown like this:
(But I still have a little problem with the existing input and I do not catch why. Try this code with me:)
add_filter( 'woocommerce_quantity_input_args', 'control_product_qty_input', 20, 2 );
function control_product_qty_input( $args, $product ) {
$settings = array('49' => array(5, 8, 10, 13), '48' => array(2, 4));
$options="";
$defaults = array(
'input_name' => 'quantity',
'input_value' => '1',
'max_value' => apply_filters( 'woocommerce_quantity_input_max', '', $product ),
'min_value' => apply_filters( 'woocommerce_quantity_input_min', '', $product ),
'step' => apply_filters( 'woocommerce_quantity_input_step', '1', $product ),
'style' => apply_filters( 'woocommerce_quantity_style', 'float:left; margin-right:10px;', $product )
);
$html="<div class="quantity_select" style="" . $defaults['style'] . '"><select name="' . esc_attr( $defaults['input_name'] ) . '" title="' . _x( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) . '" class="qty">';
foreach ($settings as $k => $v) {
if($k === $product->get_id()){
foreach ($v as $v) {
$options .= '<option value="' . $v . '">' . $v . '</option>';
}
}
}
$html .= $options . '</select></div>';
echo $html;
}