This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

📣 Try the fastest hosting platform with pay-as-you-go pricing & 24/7 expert support! MIGRATE NOW →

How to Hide or Remove Quantity Field From WooCommerce Product Pages

Updated on May 24, 2021

3 Min Read
hide woocommerce quantity field

WooCommerce is a great platform for ecommerce stores simply because of the many features and customization options. In many cases, developers could customize the store exactly to the requirements of the business model.

There are cases where WooCommerce is used to create a bulk order store that deals in fixed order sizes. In other cases, the store just deals in a single physical or digital product. In both cases, the field of Item Quantity becomes extraneous. The best strategy in this scenario is to remove the field completely from the page.

Fortunately, WooCommerce provides a filter to remove this field from the store. All you have to do is to paste the following code in the functions.php of the installed theme.

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

Hide Particular Type of Product

Another scenario is when the store owners must remove a particular product type from the item order page. For this, add the following code to the functions.php of the theme:

add_filter( 'woocommerce_is_sold_individually', 'cw_remove_quantity_fields');
function cw_remove_quantity_fields( $return, $product ) {
switch ( $product->product_type ) :

case "grouped":
return true;
break;
case "external":
return true;
break;
case "variable":
return true;
break;
default:
return true;
break;
endswitch;
}

Here is how this code would change the page:

Grouped Product

Hide From All Product Type

If you want to hide WooCommerce product quantity field, then add the following snippet to the functions.php:

function cw_remove_quantity_fields( $return, $product ) {
    return true;
}
add_filter( 'woocommerce_is_sold_individually', 'cw_remove_quantity_fields', 10, 2 );

Product Result

WooCommerce Stores Need a Reliable Hosting Stack

See how Cloudways helped Silicon Dales to manage their hosting stack

Conclusion

In this short tutorial, I demonstrate how to remove the order quantity field from the WooCommerce product page. All it takes is an addition of simple code snippets to the functions.php file. If you need help, just drop a comment below, and I will get back to you.

Q. How do I hide quantity in WooCommerce product page?

You can hide the quantity field in WooCommerce product pages by adding custom CSS code to your theme’s stylesheet or using a plugin like “WooCommerce Customizer.” The CSS code typically targets the quantity input field and sets its display property to “none,” effectively hiding it from view.

Q. How do I hide product fields in WooCommerce?

You can hide other product fields in WooCommerce, such as SKU or categories, using plugins like “WooCommerce Custom Fields” or “Advanced Custom Fields for WooCommerce.” These plugins allow you to customize which fields are displayed on the product pages and can hide specific fields based on your preferences.

Q. How do I change the product quantity field in WooCommerce?

Changing the product quantity field in WooCommerce requires a bit of customization. You can do this by modifying the theme’s functions.php file or by using a plugin like “WooCommerce Customizer.” In either case, you’ll need to override the default WooCommerce template for the product page and customize the HTML markup for the quantity field to match your desired layout or functionality.

Q. How do I hide stock count in WooCommerce?

Follow the steps below to hide stock count in WooCommerce:

  • Access your WooCommerce dashboard.
  • Go to the “Products” tab.
  • Click on “Inventory.”
  • Locate the “Enable stock management at product level” option.
  • Uncheck the box next to this option to hide the stock count.

Share your opinion in the comment section. COMMENT NOW

Share This Article

Owais Alam

is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform and a seasoned PHP developer. He loves to develop all sorts of websites on WordPress and is in love with WooCommerce in particular. You can email him at [email protected]

×

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour

CYBER WEEK SAVINGS

  • 0

    Days

  • 0

    Hours

  • 0

    Mints

  • 0

    Sec

GET OFFER

For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now