How to use decimal in quantity fields in WooCommerce for certain categories?

check this sample code :

add_filter('woocommerce_quantity_input_min', 'min_decimal', 10, 2);
function min_decimal($val, WC_Product $product) {
if(get_the_category($product->id) == 12) { // 12 = ID on the category you want it to work with
return 0.1;
}
return 1;
}
add_filter('woocommerce_quantity_input_step', 'step_decimal', 10, 2);
function step_decimal($val, WC_Product $product) {
if(get_the_category($product->id) == 12) { // 12 = ID on the category you want it to work with
return 0.1;
}

return 1;
}