This PHP code removes the quantity field on the single product page when the checkbox on the Inventory tab is checked to Sold Individually.
![](https://wpsites.net/wp-content/uploads/2024/07/sold-indivually.png)
Add the following PHP code to the end of your child themes functions file or code snippets plugin.
add_action( 'wp', 'remove_quantity_field_for_sold_individually_products' );
function remove_quantity_field_for_sold_individually_products() {
if ( is_product() ) {
global $product;
if ( is_object( $product ) && $product->is_sold_individually() ) {
// Remove the quantity field
remove_action( 'woocommerce_before_add_to_cart_quantity', 'woocommerce_template_single_add_to_cart', 10 );
remove_action( 'woocommerce_after_add_to_cart_quantity', 'woocommerce_template_single_add_to_cart', 10 );
}
}
}
Not exactly what you’re looking for?
Was This Tutorial Helpful?