I tried to allow decimal value for quantity in WooCommerce from the solution written here and also from documentation::
add_filter('woocommerce_quantity_input_min', 'min_decimal');
function min_decimal($val) {
return 0.5;
}
add_filter('woocommerce_quantity_input_step', 'nsk_allow_decimal');
function nsk_allow_decimal($val) {
return 0.5;
}
remove_filter('woocommerce_stock_amount', 'intval');
add_filter('woocommerce_stock_amount', 'floatval');
add_filter( 'woocommerce_quantity_input_args', 'jk_woocommerce_quantity_input_args', 10, 2 ); // Simple products
function jk_woocommerce_quantity_input_args( $args, $product ) {
$args['step'] = 0.5;
return $args;
}
It's all ok when the customer makes an order. But whenever you want to change the order status in order admin, It won't work when the quantity of product is decimal. And the other needed change is that you can not manually create an order in admin with decimal quantity (steps are still int value).
How can I allow also float value in order admin and also allow float steps for adding new order manually from admin?