WooCommerce is good plugin for selling products online it comes
with lots of customization and options you can sell any kind ofproduct with it digital products as well some times we provide thatcustomer buy only one item at time or there is not need for Item Quantity Field and you realize later after adding lots of products. Now there is a filter you can apply using theme function file and the field will hide.Hide Quantity Field from All Product Types You can use below code paste it into function.php file of your theme and save.
Want Best WooCommerce themes Click here
Mothod 1: Hide From all product type
/**@ Remove in all product type*/ function baztro_remove_all_quantity_fields( $return, $product ) { return true; } add_filter( 'woocommerce_is_sold_individually', 'baztro_remove_all_quantity_fields', 10, 2 );
Method 2 If You want to hide from particular type of product
/** * @Hide from different product type group */ add_filter( 'woocommerce_is_sold_individually', 'baztro_wc_remove_all_quantity_fields', 10, 2 ); function baztro_wc_remove_all_quantity_fields( $return, $product ) { switch ( $product->product_type ) : case "variable": return true; break; case "grouped": return true; break; case "external": return true; break; default: // simple product type return true; break; endswitch; }
Method 3 Hide WooCommerce Input Field using CSS
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 } }
Method 4: Using Option Sold Individually in Edit Product Page
- Choose product where you don’t wish to show quantity field
- Edit Product
- From Bottom Click Inventory
- Check the box Sold Individually
- Update Product

These are some code that definitely work for you if any problem please discuss in below in comment.
3 Comments
Leave a Reply