WordPress is the most popular Content Management System (CMS), bar none. Over 42.3% of websites on the Internet use WordPress as their backends. Businesses and sellers run a huge portion of these websites.
This group favors WordPress because it’s compatible with many e-commerce plugins, like WooCommerce. Install the plugin on your system, and you’ll be able to set up an online storefront in no time.
If you’re a WooCommerce user and want to know how to remove quantity WooCommerce fields, here’s a guide.
- What Is a WooCommerce Quantity Field?
- Reasons to Remove the WooCommerce Quantity Field
- How to Remove Quantity WooCommerce Field
What Is a WooCommerce Quantity Field?
Whenever you add a product to WooCommerce, the system will add a Quantity field next to it by default. Customers can use it to indicate how many product units they wish to buy.
The field can take many forms. It can look like a box, and customers can manually type in the number of units. For a selector with a drop-down menu, customers can choose the amount they want from the options.
As the web admin, you can modify the quantity field however you’d like, including removing it.
Reasons to Remove the WooCommerce Quantity Field
You want to do away with the quantity field for many reasons.
If you’re selling services, for example, commission of a digital painting, having a quantity field doesn’t make sense.
Or, if you’re selling products in limited quantities with a ceiling of 1-product-per-customer, a quantity field wouldn’t have any use. That is to say, a quantity field just doesn’t work for certain shops or product types
These are just the two most popular reasons why people may choose to remove the quantity field in WooCommerce. But whatever the reason is, if you have the need to do it, this is the guide for you.
How to Remove Quantity WooCommerce Field
Fortunately, it’s not hard to remove quantity WooCommerce field. There are many methods you can use to do it.
This is how to remove quantity in WooCommerce in the quickest fashion.
#1 Activate a Plugin
There are several plugins for removing the quantity field in your WooCommerce theme. Some special plugins like Advanced Product Quantity and WPC Product Quantity for WooCommerce are worth checking out.
Both give you far more extensive control over the look and function of the quantity field compared to the default one. Fiddle a bit with the plugin settings, and you’ll be able to remove the quantity field from your website.
#2 Use a Hook
A “hook” is a code that interacts with another code at a specific spot. In this case, we’re using a hook to modify the coding of WooCommerce’s quantity field.
You can use a plugin like Code Snippets to insert a custom code to your WooCommerce theme quickly. Once you’ve got it set up and ready, copy and paste this code into the plugin:
function custom_remove_all_quantity_fields( $return, $product ) {return true;} add_filter( 'woocommerce_is_sold_individually','custom_remove_all_quantity_fields', 10, 2 );
This code will instantly remove the quantity field in every product on your website. So, if your store specializes in selling unique services or one-off purchases, this solution will be perfect.
However, the downside is that if you only want to remove the quantity field in some products only, this method won’t do. Instead, try the next one on the list.
#3 Utilize the Product Data Metabox
This method will work excellently for stores that don’t contain many products.
Navigate to the WooCommerce administrative panel. You can access it by logging into your WordPress admin area.
Click on one of the products you wish to remove the quantity field for. Then scroll down to the Product Data metabox.
Select Inventory from the side menu. You should now see a checkbox in the pop-up window with the title Sold individually.
Check the box, and voilà! The quantity field should now be gone from the product’s page.
Repeat this process for all the products you wish to have the quantity field removed. This takes a very long time and will be tedious if you own a large store with many products. This is why the method isn’t popular for web admins.
That’s where the next and last WooCommerce remove quantity from cart method comes into play.
#4 Apply Custom Code
We will change WooCommerce’s coding to erase the quantity field manually in this method. No need to worry if you don’t know how to code. We’ll provide you with the code templates. All you need to do is to copy and paste them into your WooCommerce theme.
Basic WordPress coding knowledge is still necessary to safely navigate and edit the core files of your website.
Plus, since we’re dealing with core files here, we highly recommend you backup your site before modifying the files. That way, if anything was to go wrong, you could still revert the website to earlier versions.
Hide the Quantity Field in a Particular Type of Product
In case you only want to remove the quantity field from a certain type of product, modify the functions.php with this code.
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; }
Conceal the Quantity Field in All Products
Wish to remove the quantity field from every product on your website? Add the following lines of code to your functions.php file.
function cw_remove_quantity_fields( $return, $product ) { return true; } add_filter( 'woocommerce_is_sold_individually', 'cw_remove_quantity_fields', 10, 2 );
Remove Quantity WooCommerce Field Like an Expert!
Similar to WordPress, the WooCommerce plugin is favored by sellers and businesses due to its flexibility. You can change just about every element in the theme. As we demonstrated, it only takes a few minutes to remove quantity WooCommerce field!
We hope you’ve found this short guide helpful. If you want to share your experience, don’t hesitate to reach out to us in the comment section below.
Besides the quantity field, there are other WordPress elements that you can remove. Check out how to remove “uncategorized” category in WordPress and remove related products in WooCommerce.