Tagged: decimal quantity, woocommerce
-
AuthorPosts
-
January 12, 2017 at 3:27 pm #732669
I’m using the “Quantities and Units for WooCommerce” plugin to enable decimal quantities and Kg as units in WooCommerce.
I disabled the Enfold +/- as suggested by Josue in his first answer here https://kriesi.at/support/topic/disable-woocommerce-quantity-feature/#post-732609 but this is not sufficient since:
– the quantity field is classified as a Text input field instead of a number input field (as you can see the std increase and decrease HTML buttons are not appearing also in the cart )
– the header cart show quantities with ‘.’ instead of ‘,’
https://drive.google.com/file/d/0B7baurTblFiQQWloLUVmeEJCN2M/view?usp=sharing
https://drive.google.com/file/d/0B7baurTblFiQX0x0X2pwRGF1V1U/view?usp=sharingSo i tried to change the /enfold/config-woocommerce/woocommerce-mod.js to this (only changed parseInt to parseFloat in lines 7,17,22) :
function avia_apply_quant_btn() { jQuery(".quantity input[type=number]").each(function() { var number = $(this), max = parseFloat( number.attr( 'max' ) ), min = parseFloat( number.attr( 'min' ) ), step = parseFloat( number.attr( 'step' ) ), newNum = jQuery(jQuery('<div />').append(number.clone(true)).html().replace('number','text')).insertAfter(number); number.remove(); setTimeout(function(){ if(newNum.next('.plus').length == 0) { var minus = jQuery('<input type="button" value="-" class="minus">').insertBefore(newNum), plus = jQuery('<input type="button" value="+" class="plus">').insertAfter(newNum); minus.on('click', function(){ var the_val = parseFloat( newNum.val() ) - step; the_val = the_val < 0 ? 0 : the_val; the_val = the_val < min ? min : the_val; newNum.val(the_val).trigger("change"); }); plus.on('click', function(){ var the_val = parseFloat( newNum.val() ) + step; the_val = the_val > max ? max : the_val; newNum.val(the_val).trigger("change"); }); } },10); }); }
In this case, the ‘+’ and ‘-‘ buttons works well, increase and decrease are stepped by 0.5, and the HTML seems to be what i expected:
<form class="cart" method="post" enctype='multipart/form-data'> <div class="quantity"> <input type="number" step="0.5" min="0.5" max="" name="quantity" value="1" title="Qtà" class="input-text qty text" size="4" pattern="" inputmode="" /> </div> <input type="hidden" name="add-to-cart" value="21" /> <button type="submit" class="single_add_to_cart_button button alt">Acquista</button> </form>
BUT … i get the browser verification error “Respect the required format” on field input (see this: https://drive.google.com/file/d/0B7baurTblFiQZHkyMURxNEVIM2M/view?usp=sharing ).
Can i have your suggestions to solve this empasse?
I need decimal quantities and increase/decrease buttons in input fields (standard html or – better – enfold theme).January 16, 2017 at 5:32 pm #734231Hey tipinoncomuni,
what is WooCommerce telling you about this? would be best to contact them, as they know their plugin best.
Best regards,
Andy -
AuthorPosts
- You must be logged in to reply to this topic.