• Resolved cullachie

    (@cullachie)


    We use a drop-down selector for the customer to select the quantity he/she wants to order because the price varies with the quantity ordered.
    We have each product set to “allow only one item to be purchased” but even with this setting, the default quantity selector is showing.
    The default qty selector disappears once a quantity has been chosen in the variation selector.
    Is there a bit of code that can be added to hide the default qty selector as soon as the product page is loaded?
    https://www.trapbarn.com/wp-content/uploads/2023/01/trap1.jpg

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hi,
    You can hide the default quantity selector on product pages by using the following code snippet:

    add_action( 'wp_footer', 'hide_quantity_input_field' );
    
    function hide_quantity_input_field() {
        ?>
        <style>
            form.cart .quantity {
                display: none;
            }
        </style>
        <?php
    }

    To use this code, you can add it to your child theme’s functions.php file, or you can create a custom plugin to add the code.

    Remember that this code will hide the quantity selector on all products. If you want to apply this only to specific products, you must modify the code to target specific products.

    Thread Starter cullachie

    (@cullachie)

    Hi Faisal, I will give it a go tomorrow. Sunday is my busiest day with orders.

    Many thanks

    Thread Starter cullachie

    (@cullachie)

    Sorry Faisal, I added it using “My Custom Functions” but it crashed the site. I have done a restore so we are back up running.

    Hi @cullachie,
    I’m sorry to hear that. To ensure everything runs smoothly, you should add the code to your child theme’s functions.php file. You can access the functions.php file via File Manager, FTP, or SFTP, so you can easily remove the code if anything goes wrong. I’m unsure how you added the code, but I’m here to help if needed.

    Hi @cullachie

    Thanks for reaching out!

    You can add the CSS code below under Appearance > Additional CSS:

    /* Hide Quantity Fields on the Site */
    
    .woocommerce div.product form.cart div.quantity {
        display: none !important;
    }

    Hope this helps!

    Thread Starter cullachie

    (@cullachie)

    Hi Xue,
    Marvellous!! That did exactly what was required.
    Many thanks

    Hi @cullachie

    You’re welcome, glad to know it’s working fine now. I am going to mark this thread resolve and if you have any new questions, please create a new ticket.

    Cheers!

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Hide default quantity selection’ is closed to new replies.