• Resolved evtihii

    (@evtihii)


    Hello! I found an issues in your plugin:
    1) I’m using WooCommerce Quantity Increment plugin. For some reasons if product in stock count for example 2, but customer press “+” button Place Order in cart freezes. So I create little snippet to fix it
    var global_val_greater_max;//global function to place into your plugin in at the bottom “wacPostCallback”
    function val_greater_max() { //function that checks that input value is equals to max value
    $(‘.cart_item’).each(function () {//each container that contains input increment
    var max = $(this).find(‘input[type=”number”]’).attr(‘max’);
    var val = $(this).find(‘input[type=”number”]’).val();
    if (val === max ){
    $(this).find(‘input[value=”+”]’).css(‘display’,’none’);//if value equals to max hide “+” button }
    else {
    $(this).find(‘input[value=”+”]’).css(‘display’,’block’);
    }
    });
    }
    val_greater_max();
    global_val_greater_max = val_greater_max;
    2) If I turn on “Show -/+ buttons around item quantity on cart page” in your plugin, there no any check how much products in stock.

    Best regards,
    Artem Evtihii

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author moiseh

    (@moiseh)

    Hi, based on your snippet idea, i made this and updated in plugin:

    + // hide or show the “+” button based on max stock limit (snippet based on @evtihii idea)
    + maxStock = el_qty.attr(‘max’);
    + if ( maxStock > 0 ) {
    + incrementButton = el_qty.parent().find(‘.wac-btn-inc’).parent().parent();
    +
    + ( el_qty.val() >= maxStock ) ? incrementButton.hide() : incrementButton.show();
    + }

    Thanks nice idea!

    Thread Starter evtihii

    (@evtihii)

    Hello, I’ve updated my code with new feature. Earlier if you click very quickly “+” button you can go beyond max. I fixed it.
    function val_greater_max() {
    $(‘.cart_item’).each(function () {
    var max = $(this).find(‘input[type=”number”]’).attr(‘max’);
    var val = $(this).find(‘input[type=”number”]’).val();
    if (val === max || max < val ){ //NEW CHECK
    $(this).find(‘.wac-qty-button .wac-btn-inc’).closest(‘.wac-qty-button’).css(‘display’,’none’);// new rules
    $(this).find(“input[type=’number’]”).val(max);// Assign the value of the maximum number value
    }
    else {
    $(this).find(‘.wac-qty-button .wac-btn-inc’).closest(‘.wac-qty-button’).css(‘display’,’block’);// new rules
    }
    });
    }

    Thread Starter evtihii

    (@evtihii)

    By the way, I have error on front page http://newz.celerart.com you can check it.
    When I clicking “add to cart” firstly fires ajax but then page reloading. In the shop page all ok(only ajax as must be)

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘feature request(my own code)’ is closed to new replies.