Home Forums WoodMart support forum Add a fractional quantity to an item

Add a fractional quantity to an item

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #539280

    -_Vitalii_-
    Participant

    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;
    }

    #539284

    -_Vitalii_-
    Participant

    The problem is solved, this code only works after applying the template to the checkout page!

    #539612

    Hung Pham
    Keymaster

    Hi -_Vitalii_-,

    Thanks for reaching to us.

    Glad to hear your issue has been resolved. Keep us in mind for future questions and concerns, we’re always here to help!

    Regards,

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)