Okay
  Public Ticket #3554642
Hide the WooCommerce Quantity Selector if a clickable prcing table is present
Closed

Comments

  •  7
    Julien started the conversation

    I want to suggest fixed quantity intervals for my customers, for example: 

    1, 5, 10, 50, 100, 200, 400, 1.000

    besides these given quantities, i do not want to sell the products due to different reasons ( ease of production, packaging, etc...)


    Therefore, i want to hide the native quantity selector of woocommerce for products that have a clickable pricing table 

    Attached files:  Bildschirmfoto 2024-01-04 um 14.06.58.png

  •  2,218
    WebWizards replied

    Hi Julien,

    I wrote a code snippet that I believe can help achieve this. 

    The snippet is:

    add_action('wp_head', function(){
        ?>
        <script>
            jQuery(document).ready(function(){
                if (jQuery('.b2bking_tiered_price_table').length === 1){
                    // tiered table exists, hide quantity input field
                    jQuery('.quantity .qty').css('display','none');
                }
            });
        </script>
        <?php
    });
    

    Basically when the page loads it checks whether there's a pricing table, and if there is, it hides the input quantity field.


    This could be a bit dependent on your theme, so if this does not work for you, please send me a link to your site / a page with a product, so I can check the classes of the input field on your site.

    Kind regards,

    Stefan

  •  7
    Julien replied

    somehow i cannot make it work, but i think you said it might only work on single products, not on variable products?

  •  2,218
    WebWizards replied

    Hmm, it could be related to that but I am not completely sure. It could also be just that ".quantity .qty" does not correctly select the input quantity field, this can depend on the theme / other plugins, etc.

    It would help if I could check your site / URL - I could then run that snippet in my browser and see what the issue is.

  •  7
  •  2,218
    WebWizards replied

    Please try replacing it with:

    add_action('wp_head', function(){
        ?>
        <script>
            jQuery(document).ready(function(){
                if (jQuery('.b2bking_tiered_price_table').length === 1){
                   // tiered table exists, hide quantity input field
                   jQuery('.quantity-wrapper').css('display','none');
                }
            });
        </script>
        <?php
    });
    

    If that doesn't work, please share an admin login with us to your staging site, and we can then troubleshoot directly.

  •   Julien replied privately
  •  2,218
    WebWizards replied

    Sure, please use our email at [email protected] for the account

  •  7
    Julien replied

    Please check if you have received the email for the staging account. 

  •  2,218
    WebWizards replied

    I just want to confirm I have received the email and I am able to access the site backend.


    I will look into this and get back to you here with another message as soon as possible,

  •  2,218
    WebWizards replied

    I believe I've been able to resolve it.


    For future reference, I changed the snippet to the following one:

    add_action('wp_head', function(){
        ?>
        <script>
            jQuery(document).ready(function(){
                hideqty(0);
                hideqty(50);
                hideqty(125);
                hideqty(250);
                hideqty(500);
            });
            function hideqty(time){
                setTimeout(function(){
                    if (jQuery('.b2bking_tiered_price_table').length === 1){
                       // tiered table exists, hide quantity input field
                       if (jQuery('.b2bking_tiered_price_table').length === 1){    
                            jQuery('.quantity-wrapper').css('display','none');
                       }
                    }
                }, time);
                
            }
        </script>
        <?php
    });
    

    Let me know if you see any issue,

  •  7
    Julien replied

    thank you so much, this is exactly what i needed! 

    is there any way to thank you by giving you a well deserved 5 star rating for excellent customer support??


  •  2,218
    WebWizards replied

    Glad to hear that's working!

    I would be very happy it if you are able to leave a rating here https://wordpress.org/support/plugin/b2bking-wholesale-for-woocommerce/reviews/?rate=5#new-post - it's a big help to us! Thank you