Bug on decimal quantities

Forums Min Max Default Quantity for WooCommerce Bug on decimal quantities

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #104151
    Lilian Domin
    Participant

    Hello, I bought the plugin today and have the following two problems.

    1. I set a product with decimal quantities: min: 0.5, step: 0.1.
    Now when I open the single product page, the quantity starts with the min value. After I pressed the quantity plus button three times, the quantity is not 0.8, it is 0,7999999999999999. Have the problems always after a few plus or minus adjustments (also e.q. 1,8000000000000003). It works finde with 0.5 steps btw.
    2. If I have the same setup like in 1. and open the single product page (with quantity 0.5) and immediately add the product to card, it adds it with quantity 1, not 0.5. After changing the quantity it adds the product to card correctly. (I enabled “Force initial quantity on single product page” to min quantity)

    I look forward to your help.

    • This topic was modified 1 year, 10 months ago by Omar Dabbas.
    #104152
    WPWhale
    Moderator

    Hello Lilian,

    That looks like an odd case, it’s possible that the +/- buttons are controlled by specific code, does this happen if you increase the quantity using keyboard up arrow?

    Is it possible to grant access to your site to check? If so, please add my email [email protected]

    Omar

    #104153
    Lilian Domin
    Participant

    Hello Omar,

    It works finde with the keyboard arrows. Okay, then it seems to be an error in the theme JS. I already changed it, because it does only parse integers. But my JS is not the best and it doesn’t work with mobile chorme (mobile firefox works fine). Maybe someone can help me:

    productQuantityAdjust: function() {
    			// Increase
    			jQuery(document).on('click', '.qty-plus', function(e) {
    				e.preventDefault();
    				var quantityInput = jQuery(this).parents('.quantity').find('input.qty'),
    					step = parseFloat(quantityInput.attr('step'), 10),
    					newValue = parseFloat(quantityInput.val(), 10) + step,
    					maxValue = parseFloat(quantityInput.attr('max'), 10);
    
    				if (!maxValue) {
    					maxValue = 9999999999;
    				}
    
    				if ( newValue = minValue ) {
    					quantityInput.val(newValue);
    					quantityInput.change();
    				}
    			});
    		}
    #104154
    Lilian Domin
    Participant
    #104155
    Lilian Domin
    Participant

    Hey Omar,

    thanks for you’re help, but I fixed it. But 2. is still a problem.

    Thanks

    #104156
    WPWhale
    Moderator

    Hi Lilian, glad to know you got it for the first problem.
    As for number two, it looks that default quantity (when you open the page) is also controlled by theme JS, you can check that by increasing quantity to 0.6 and then change it back to 0.5, it will add 0.5 to the cart.
    So it looks the theme overwrites the default quantity settings by WooCommerce (which the plugin overwrites), can you please check this as well?
    Here is the function that controls it by your theme.
    Please let me know if you still need any further help, and if you found the support useful, please leave us a rating.
    Omar
     

    #104157
    Aaron Boyd
    Participant

    Hi Lilian, I am experiencing the same issue as your first problem. Just wondering what code you used to correct this? And where did you add the code?
    I have a site ready to go live apart from this one annoyance.
    Hope you can help?!

    #104158
    WPWhale
    Moderator

    Hi Aaron,

    Please contact us at [email protected] with a link to your store, I might be able to tell you where exactly you have to change.

    Omar

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.