I need to hide the "quantity" field (where one enters the quantity before adding to cart) in Woocommerce on the product detail page, and only show the "add-to-cart"-button, which would then put the quantity of 1 in the cart. The reason is because I gather the quantity based on a Gravity Forms.
13 Answers
- Edit your product.
- Click "Inventory".
- Check the box that says "Sold Individually"

- 829
- 7
- 6
-
This is best for a product by product basis. Otherwise, filtering `woocommerce_is_sold_individually` works best for blanket application to all products. – helgatheviking Dec 07 '15 at 06:35
The safest way is to use WordPress builtin hook or filter
/**
* @desc Remove in all product type
*/
function wc_remove_all_quantity_fields( $return, $product ) {
return true;
}
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_all_quantity_fields', 10, 2 );
You can also remove Quantity selector in other product type, you can found our more here http://www.sutanaryan.com/how-to-remove-product-quantity-selectors-woocommerce/
Please be warned: using this option effictively makes it impossible to have a product more than once in your shopping cart. Subsequently clicking "Add to cart" will trigger a warning that this product can only be in your cart once. This might not be desirable for everyone.

- 81,193
- 17
- 104
- 128

- 6,076
- 1
- 20
- 14
-
3This is by far the best answer here and should be accepted as the answer to the question. – Reinoud van Santen Sep 18 '14 at 13:18
-
agree! it overwrites the setting in product data tab -> inventory. be aware of that. – nicmare Nov 15 '14 at 11:19
-
@Reinoud van Santen I dont think so - it relies on a hook that might change also `wc_remove_all_quantity_fields` seems like it could remove ANY quantity field.. – jave.web Mar 11 '15 at 23:20
-
1Please be warned: using this option effictively makes it impossible to have a product more than once in your shopping cart. Subsequently clicking "Add to cart" will trigger a warning that this product can only be in your cart once. This might not be desirable for everyone. – Aron Rotteveel Apr 02 '15 at 11:03
-
Voting down didn't help, if the above solution is not 100% or have some conflict or implications then please provide 110% solutions that works, this might old but it help other looking for solution. – Ryan S Apr 23 '15 at 08:49
-
2This can be simplified to: `add_filter( 'woocommerce_is_sold_individually', '__return_true' );` – Dylan Sep 22 '16 at 22:56
-
Why is this method "the safest"? I think it would depend on use case. My only concern is that anyone reading this may reasonably think it's "unsafe" to use @John Chandler's answer which is also perfectly fine. – armadadrive Jun 19 '17 at 14:23
-
i dont like this solution, since the warning you already placed there. to me its a difference, to hide the input and to manipulate ALL products to be sold individually, just to make the field dissapear.. – honk31 Nov 15 '17 at 10:44
-
See my answer if you want to know how to have a product more than once without the quantity field – Tofandel May 13 '19 at 14:00
There is no need to use a plugin or edit function.php just check the option shown in the image above.

- 955
- 15
- 12
-
I love it when I think something is going to be complicated, and then I run into an answer like this and it's just easy. – logos_164 Sep 19 '18 at 23:10
-
1Curiously enough, I have this and yet the quantity is still shown in the checkout. – j4hangir Jan 16 '19 at 18:24
There is a free plugin to remove the quantity selectors that might work for you. http://wordpress.org/extend/plugins/woocommerce-remove-quantity-fields/

- 91
- 3
I found a simple way to do it just in product single page, and keeping the quantity counter in cart. Just put the following code in functions.php
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 }
}
You can check the woocommerce documentation here: http://docs.woothemes.com/document/remov-product-content-based-on-category/

- 492
- 3
- 15

- 66
- 3
-
sorry, but this solution is just ugly. insert a style tag on pages that are single product..? why not use the default wordpress style.css with a decent selector in the first place?! – honk31 Nov 15 '17 at 10:33
There´s no need for plugin, for example you can hide it using css. But woocommerce let you sell just 1 product, with no choise to add more of same item to cart. Take a look on woocommerce->settings. It´s all there.

- 1,054
- 9
- 13
-
2I dispise this notion of hiding functionality in Wordpress via CSS. CSS is for presentation. – user3791372 Jan 05 '16 at 06:39
-
This should not be done using css - the woocommerce product settings do this – Natacha Beaugeais Oct 29 '17 at 06:21
-
2"But woocommerce let you sell just 1 product, with no choise to add more of same item to cart" Did you read that part? – rgdesign Oct 30 '17 at 15:20
You can also use the woocommerce_quantity_input_min
and woocommerce_quantity_input_max
hooks by setting both quantities to 1.
In fact, in the /woocommerce/global/quantity-input.php
template, the quantity field will be automatically hidden if min and max have the same value.
// hides the quantity field on the product page
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;
}
The code has been tested and works. Add it to your active theme's functions.php.

- 3,892
- 3
- 13
- 32
The template you need to edit is single-product/add-to-cart/variation-add-to-cart-button.php
.
So you can simply copy this template in your own theme and edit it to remove the quantity field. It would become something like:
<?php
/**
* Single variation cart button
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
global $product;
?>
<div class="woocommerce-variation-add-to-cart variations_button">
<button type="submit" class="single_add_to_cart_button button alt"><?php echo esc_html( $product->single_add_to_cart_text() ); ?></button>
<input type="hidden" name="add-to-cart" value="<?php echo absint( $product->id ); ?>" />
<input type="hidden" name="product_id" value="<?php echo absint( $product->id ); ?>" />
<input type="hidden" name="variation_id" class="variation_id" value="0" />
</div>

- 842
- 2
- 9
- 21
There is an edge case that is not being handled by other answers to this question, the 'is sold individually' option of woocommerce effectively removes the quantity input but prevents the same product to be added multiple times to the cart
In a use case where you have a product with custom attributes where you don't want the quantity to be editable but you still want to allow a user to add the same product to the cart with different attributes, then the 'is sold individually' option will not work
What you need in this case is this filter
add_filter( 'woocommerce_cart_item_quantity', function ( $qty, $item_key, $item ) {
if ( ! empty( $item['custom_data'] ) ) { //Here check for your custom attribute
return sprintf( '1 <input type="hidden" name="cart[%s][qty]" value="1" />', $item_key );
}
return $qty;
}, 10, 3 );

- 3,006
- 1
- 29
- 48
Setting the product (or the store as a whole) to 'sold individually' as explained by the other answers here now works for me, but I also found another solution: Hiding the quantity field on a particular page ID. If anyone wants the field to show on certain pages and not others for whatever reason, consider this alternative:
.page-id-11111 .woocommerce .quantity .qty {
Display:None!important;
}
This will let people add multiple times to cart, and edit quantities at checkout if they do, while still hiding the quantity field on the product shortcode/page. More info here: Remove quantity field from Woocommerce, without preventing multiple cart additions? (I have reworked the site so this solution isn't necessary for me anymore, but this may help someone.)

- 31
- 2
- 6
This code disables the quantity field only on the product page. You can still click on the add to cart button multiple times or change the quantity in the cart.
function theme_remove_quantity_field( $return, $product ) {
if(is_product()){
$return=true;
}
return $return;
}
add_filter( 'woocommerce_is_sold_individually', 'theme_remove_quantity_field', 10, 2 );

- 1,047
- 12
- 18
It's very simple, in woocommerce\includes\abstracts\abstract-wc-product.php
, find abstract-wc-product.php
file in woocommerce
Find below code in page
$availability = sprintf( __( '%s in stock', 'woocommerce' ), $this->get_total_stock() );
replace this code with
$availability = sprintf( __( '%s in stock', 'woocommerce' ),'');

- 132,869
- 46
- 340
- 423