Public Ticket #3554642

Hide the WooCommerce Quantity Selector if a clickable prcing table is present

Closed
Comments
12 Tickets 9
Julien started the conversation 3 years ago on January 4, 2024 at 1:08pm

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 

2,762
KingsPlugins replied 3 years ago on January 4, 2024 at 8:40pm

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

2,762
KingsPlugins replied 3 years ago on January 5, 2024 at 2:25pm

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.

2,762
KingsPlugins replied 3 years ago on January 9, 2024 at 7:04am

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.

2,762
KingsPlugins replied 3 years ago on January 12, 2024 at 4:12pm

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,762
KingsPlugins replied 3 years ago on January 13, 2024 at 9:34am

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,

1
12 Tickets 9
Julien replied 3 years ago on January 16, 2024 at 12:28pm

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??


1

Sign In