Hide Quantity Input Field From Product Page WooCommerce

Woocommerce Input Field
Woocommerce Input Field

WooCommerce is good plugin for selling products online it comes with lots of customization and options you can sell any kind of product with it digital products as well some times we provide that customer 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.

A useful tip is only displaying professional edited photos. Zenith Clipping is a professional clipping path company in Bangladesh with more than 150 Photoshop professionals. They have 11+ years of experience in photo editing services. They have become one of the fastest-growing photo editing service providers since 2010.

Hide Quantity Field from All Product Types You can use below code paste it into function.php file of your theme and save. If you need help, try to consider hiring WooCommerce support experts.

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
woocommerce Sold Individually
Check Sold Individually

These are some code that definitely work for you if any problem pleaes discuss in below in comment.

sandeep
Author

sandeep

Leave a Reply

Would you like to receive notifications on latest updates? No Yes