
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:
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 );
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. Why would I want to hide or remove the quantity field in WooCommerce?
A. Hiding the quantity field simplifies the purchasing process for products sold as single units or services. It improves user experience and prevents customers from accidentally increasing quantities.
Q. Can I hide the quantity field without using a plugin?
A. Yes, you can hide the quantity field by adding a small custom code snippet to your theme’s functions.php file or using CSS to visually hide the field.
Q. Are there plugins to remove the quantity field in WooCommerce?
A. Yes, plugins like WooCommerce Customizer or Advanced Product Fields for WooCommerce allow you to easily hide or remove the quantity field without coding.
Q. Will hiding the quantity field affect my WooCommerce functionality?
A. No, hiding the quantity field doesn’t affect core functionality. Customers can still add items to their cart, but they’ll only be able to purchase a single unit per product.
Q. How do I hide quantity in WooCommerce product page?
A. 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?
A. 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?
A. 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?
A. 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.
Owais Khan
Owais works as a Marketing Manager at Cloudways (managed hosting platform) where he focuses on growth, demand generation, and strategic partnerships. With more than a decade of experience in digital marketing and B2B, Owais prefers to build systems that help teams achieve their full potential.