Tell me if you need to add a fractional quantity to the product. meters 0.5.
After adding the code, everything works, but the cart is still 1 by default, how can I fix it?
//
add_filter( ‘woocommerce_quantity_input_args’, ‘custom_quantity_input’, 9000, 2 );
function custom_quantity_input( $args, $product ) {
if ( ! is_cart() ) {
$args[‘input_value’] = 0.5;
}
$args[‘min_value’] = 0.5;
$args[‘step’] = 0.1;
return $args;
}
//AJAX
add_filter( ‘woocommerce_loop_add_to_cart_args’, ‘custom_loop_add_to_cart_args’, 10, 2 );
function custom_loop_add_to_cart_args( $args, $product ) {
$args[‘quantity’] = 0.5;
return $args;
}
add_filter( ‘woocommerce_available_variation’, ‘filter_wc_available_variation_price_html’, 10, 3 );
function filter_wc_available_variation_price_html( $data, $product, $variation ) {
$data[‘min_qty’] = 0.5;
return $data;
}