• Resolved improntadivino

    (@improntadivino)


    Hi, I saw that you have already opened a ticket for my problem, but the recommended solution does not solve my problem. I want to hide the quantity of products from above the “add to cart” button from all product pages. the code I report did not solve my problem 🙁

    .single-product .single-product-wrapper .quantity { display: none; }

    (I give you the link to one of the pages but should be removed from all of them – http://improntadivino.com/?uncodeblock=botte )

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

Viewing 10 replies - 1 through 10 (of 10 total)
  • You can use a code snippet to disable the quantity input field from showing on products.

    add_filter( 'woocommerce_quantity_input_min', 'hide_woocommerce_quantity_input', 10, 2 );
    add_filter( 'woocommerce_quantity_input_max', 'hide_woocommerce_quantity_input', 10, 2 );
    function hide_woocommerce_quantity_input( $quantity, $product ) {
    // only on the product page
    if ( ! is_product() ) {
    return $quantity;
    }
    return 1;
    }

    https://stackoverflow.com/questions/14757373/how-to-disable-the-quantity-field-in-the-product-detail-page-in-woocommerce

    Thread Starter improntadivino

    (@improntadivino)

    where should this code be inserted? I have tried inserting it in appearance-customise-additional-css, but it does not solve the problem

    Thread Starter improntadivino

    (@improntadivino)

    the quantity above add to cart is always present
    Roxy

    (@beautyofcode)

    Hi @improntadivino ,

    Thanks for reaching out!

    where should this code be inserted? I have tried inserting it in appearance-customise-additional-css, but it does not solve the problem

    The code snippet provided by @lukefiretoss needs to be added to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code snippets plugin.

    Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update the theme.

    Hope this helps!

    Thread Starter improntadivino

    (@improntadivino)

    ok thank you very much I’ll try it right away!

    Roxy

    (@beautyofcode)

    Hi @improntadivino ,

    That sounds like a plan, we are happy to help!

    Let us know if this works as expected on your end after adding this accordingly 🙂

    Cheers!

    Thread Starter improntadivino

    (@improntadivino)

    i don’t have a child theme, so i had to create a folder and then a style.css , but i still haven’t managed to hide the quantity in the product pages. i will try to download the recommended plugin and see if it works

    Roxy

    (@beautyofcode)

    Hi @improntadivino ,

    i don’t have a child theme, so i had to create a folder and then a style.css , but i still haven’t managed to hide the quantity in the product pages. i will try to download the recommended plugin and see if it works

    Testing this code on my staging site, it seems to be working as expected:

    Before the code snippet is added:

    After the code snippet is added:

    Should the code not work as expected on your end when using the Code Snippets plugin, then it’s possible that this is being overwritten by a theme/plugin setting or other custom code.

    Hope this helps!

    Thread Starter improntadivino

    (@improntadivino)

    I finally managed to hide the quantity from the product pages! I downloaded the code snippet plugin and inserted the following php code.

    thanks guys for the help!

    add_action( 'wp_head', 'quantity_wp_head' );
        function quantity_wp_head() {
        if ( is_product() ) {
            ?>
        <style type="text/css">.quantity, .buttons_added { width:0; height:0; display: none; visibility: hidden; }</style>
    <?php
     
        } else { ?>
       
        <?php }
        }    

    Hi @improntadivino

    You are most welcome and we’re glad that worked! 🙂

    Meanwhile, if you have a moment to spare, we would love it if you could share your thoughts with us by leaving a review or feedback. Your experience and feedback are important to help us improve and ensure we’re always providing the best possible support.

    Thanks!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘hide the quantity above the add to cart button’ is closed to new replies.