quantity input increasing by 2 instead of 1 in woocommerce pls help!
-
hi, somehow i managed to add buttons +/- to my quantity input by adding the below codes:
\wp-content\themes\LR\woocommerce\global\quantity-input.php<div class="quantity"> <input class="qtyminus" type="button" value="-"> <input type="number" step="<?php echo esc_attr( $step ); ?>" <?php if ( is_numeric( $min_value ) ) : ?>min="<?php echo esc_attr( $min_value ); ?>"<?php endif; ?> <?php if ( is_numeric( $max_value ) ) : ?>max="<?php echo esc_attr( $max_value ); ?>"<?php endif; ?> name="<?php echo esc_attr( $input_name ); ?>" value="<?php echo esc_attr( $input_value ); ?>" title="<?php _ex( 'Qty', 'Product quantity input tooltip', 'woocommerce' ) ?>" class="input-text qty text" size="4" /> <input class="qtyplus" type="button" value="+"> </div>
and adding a javascript:
$('.qtyplus').on('click',function(e){ var val = parseInt($(this).prev('input').val()); $(this).prev('input').val( val+1 ); }); $('.qtyminus').on('click',function(e){ var val = parseInt($(this).next('input').val()); if(val !== 0){ $(this).next('input').val( val-1 ); } });
now the problem is the quantity is incrementing by 2 for example like 2 4 6 8 10 etc. instead of 1 2 3 4 5 6 etc.
I even tried reducing the step value by 1 in functions.php but still its not workingplease help!
thanks
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘quantity input increasing by 2 instead of 1 in woocommerce pls help!’ is closed to new replies.