You can use the following code to add some custom CSS to your page which will hide the quantity input only if the product has the hide_quantity_input meta key.
To add this, you can use the Custom Fields meta box in the product edit screen. Click “Enter New” and then enter hide_quantity_input as the name and any value you wish. When you are done click Add Custom Field.
<?php
function sv_hide_quantity_input() {
$post_id = get_queried_object_id();
if ( is_product() && metadata_exists( 'post', $post_id, 'hide_quantity_input' ) ) {
?>
<style type="text/css">
form.cart div.quantity {
display: none !important;
}
</style>
<?php
}
}
add_action( 'wp_head', 'sv_hide_quantity_input' );
?>
That’s it!